sequence
stringlengths 492
15.9k
| code
stringlengths 75
8.58k
|
---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:put_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:file; 6, identifier:object_type; 7, identifier:object_id; 8, identifier:width; 9, identifier:height; 10, identifier:mimetype; 11, identifier:reproducible; 12, block; 12, 13; 13, raise_statement; 13, 14; 14, call; 14, 15; 14, 16; 15, identifier:NotImplementedError; 16, argument_list; 16, 17; 17, string:'put_file() has to be implemented' | def put_file(self, file, object_type, object_id, width, height, mimetype,
reproducible):
raise NotImplementedError('put_file() has to be implemented') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_original_images; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 44; 7, 178; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:test; 10, parameters; 10, 11; 11, identifier:image; 12, block; 12, 13; 12, 21; 12, 42; 13, if_statement; 13, 14; 13, 18; 14, not_operator; 14, 15; 15, attribute; 15, 16; 15, 17; 16, identifier:image; 17, identifier:original; 18, block; 18, 19; 19, return_statement; 19, 20; 20, False; 21, for_statement; 21, 22; 21, 25; 21, 30; 22, pattern_list; 22, 23; 22, 24; 23, identifier:filter; 24, identifier:value; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:kwargs; 28, identifier:items; 29, argument_list; 30, block; 30, 31; 31, if_statement; 31, 32; 31, 39; 32, comparison_operator:!=; 32, 33; 32, 38; 33, call; 33, 34; 33, 35; 34, identifier:getattr; 35, argument_list; 35, 36; 35, 37; 36, identifier:image; 37, identifier:filter; 38, identifier:value; 39, block; 39, 40; 40, return_statement; 40, 41; 41, False; 42, return_statement; 42, 43; 43, True; 44, if_statement; 44, 45; 44, 55; 44, 155; 45, comparison_operator:is; 45, 46; 45, 54; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:Session; 49, identifier:object_session; 50, argument_list; 50, 51; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:instance; 54, None; 55, block; 55, 56; 55, 60; 55, 81; 55, 90; 55, 129; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:images; 59, list:[]; 60, for_statement; 60, 61; 60, 64; 60, 67; 61, pattern_list; 61, 62; 61, 63; 62, identifier:image; 63, identifier:store; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:_stored_images; 67, block; 67, 68; 68, if_statement; 68, 69; 68, 73; 69, call; 69, 70; 69, 71; 70, identifier:test; 71, argument_list; 71, 72; 72, identifier:image; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:images; 78, identifier:append; 79, argument_list; 79, 80; 80, identifier:image; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:state; 84, call; 84, 85; 84, 86; 85, identifier:instance_state; 86, argument_list; 86, 87; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:instance; 90, try_statement; 90, 91; 90, 106; 90, 110; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:added; 95, attribute; 95, 96; 95, 105; 96, subscript; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:state; 99, identifier:committed_state; 100, attribute; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:self; 103, identifier:attr; 104, identifier:key; 105, identifier:added_items; 106, except_clause; 106, 107; 106, 108; 107, identifier:KeyError; 108, block; 108, 109; 109, pass_statement; 110, else_clause; 110, 111; 111, block; 111, 112; 112, for_statement; 112, 113; 112, 114; 112, 115; 113, identifier:image; 114, identifier:added; 115, block; 115, 116; 116, if_statement; 116, 117; 116, 121; 117, call; 117, 118; 117, 119; 118, identifier:test; 119, argument_list; 119, 120; 120, identifier:image; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:images; 126, identifier:append; 127, argument_list; 127, 128; 128, identifier:image; 129, if_statement; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:self; 132, identifier:session; 133, block; 133, 134; 134, for_statement; 134, 135; 134, 136; 134, 141; 135, identifier:image; 136, attribute; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:session; 140, identifier:new; 141, block; 141, 142; 142, if_statement; 142, 143; 142, 147; 143, call; 143, 144; 143, 145; 144, identifier:test; 145, argument_list; 145, 146; 146, identifier:image; 147, block; 147, 148; 148, expression_statement; 148, 149; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:images; 152, identifier:append; 153, argument_list; 153, 154; 154, identifier:image; 155, else_clause; 155, 156; 156, block; 156, 157; 156, 170; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:query; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:filter_by; 164, argument_list; 164, 165; 164, 168; 165, keyword_argument; 165, 166; 165, 167; 166, identifier:original; 167, True; 168, dictionary_splat; 168, 169; 169, identifier:kwargs; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 173; 172, identifier:images; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:query; 176, identifier:all; 177, argument_list; 178, return_statement; 178, 179; 179, identifier:images | def _original_images(self, **kwargs):
def test(image):
if not image.original:
return False
for filter, value in kwargs.items():
if getattr(image, filter) != value:
return False
return True
if Session.object_session(self.instance) is None:
images = []
for image, store in self._stored_images:
if test(image):
images.append(image)
state = instance_state(self.instance)
try:
added = state.committed_state[self.attr.key].added_items
except KeyError:
pass
else:
for image in added:
if test(image):
images.append(image)
if self.session:
for image in self.session.new:
if test(image):
images.append(image)
else:
query = self.filter_by(original=True, **kwargs)
images = query.all()
return images |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:from_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:file; 6, default_parameter; 6, 7; 6, 8; 7, identifier:store; 8, identifier:current_store; 9, default_parameter; 9, 10; 9, 11; 10, identifier:extra_args; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:extra_kwargs; 14, None; 15, block; 15, 16; 15, 31; 15, 39; 15, 47; 15, 54; 16, if_statement; 16, 17; 16, 24; 17, call; 17, 18; 17, 19; 18, identifier:isinstance; 19, argument_list; 19, 20; 19, 21; 20, identifier:file; 21, attribute; 21, 22; 21, 23; 22, identifier:cgi; 23, identifier:FieldStorage; 24, block; 24, 25; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:file; 28, attribute; 28, 29; 28, 30; 29, identifier:file; 30, identifier:file; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:data; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:io; 37, identifier:BytesIO; 38, argument_list; 39, expression_statement; 39, 40; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:shutil; 43, identifier:copyfileobj; 44, argument_list; 44, 45; 44, 46; 45, identifier:file; 46, identifier:data; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:data; 51, identifier:seek; 52, argument_list; 52, 53; 53, integer:0; 54, return_statement; 54, 55; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:from_raw_file; 59, argument_list; 59, 60; 59, 61; 59, 62; 59, 65; 59, 68; 60, identifier:data; 61, identifier:store; 62, keyword_argument; 62, 63; 62, 64; 63, identifier:original; 64, True; 65, keyword_argument; 65, 66; 65, 67; 66, identifier:extra_args; 67, identifier:extra_args; 68, keyword_argument; 68, 69; 68, 70; 69, identifier:extra_kwargs; 70, identifier:extra_kwargs | def from_file(self, file, store=current_store,
extra_args=None, extra_kwargs=None):
if isinstance(file, cgi.FieldStorage):
file = file.file
data = io.BytesIO()
shutil.copyfileobj(file, data)
data.seek(0)
return self.from_raw_file(data, store, original=True,
extra_args=extra_args,
extra_kwargs=extra_kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:copy_modules; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:filespath; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:modules_path; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:verbose; 12, None; 13, block; 13, 14; 13, 16; 13, 113; 13, 125; 13, 143; 13, 156; 13, 173; 13, 217; 13, 229; 14, expression_statement; 14, 15; 15, string:''' Copy over the tree module files into your path '''; 16, if_statement; 16, 17; 16, 19; 17, not_operator; 17, 18; 18, identifier:modules_path; 19, block; 19, 20; 19, 29; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:modulepath; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:os; 26, identifier:getenv; 27, argument_list; 27, 28; 28, string:"MODULEPATH"; 29, if_statement; 29, 30; 29, 32; 29, 40; 30, not_operator; 30, 31; 31, identifier:modulepath; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:modules_path; 36, call; 36, 37; 36, 38; 37, identifier:input; 38, argument_list; 38, 39; 39, string:'Enter the root path for your module files:'; 40, else_clause; 40, 41; 41, block; 41, 42; 41, 51; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:split_mods; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:modulepath; 48, identifier:split; 49, argument_list; 49, 50; 50, string:':'; 51, if_statement; 51, 52; 51, 58; 51, 105; 52, comparison_operator:>; 52, 53; 52, 57; 53, call; 53, 54; 53, 55; 54, identifier:len; 55, argument_list; 55, 56; 56, identifier:split_mods; 57, integer:1; 58, block; 58, 59; 58, 67; 59, if_statement; 59, 60; 59, 61; 60, identifier:verbose; 61, block; 61, 62; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:print; 65, argument_list; 65, 66; 66, string:'Multiple module paths found. Finding all that contain a tree directory.'; 67, for_statement; 67, 68; 67, 69; 67, 70; 68, identifier:mfile; 69, identifier:split_mods; 70, block; 70, 71; 71, if_statement; 71, 72; 71, 88; 71, 102; 72, call; 72, 73; 72, 78; 73, attribute; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:os; 76, identifier:path; 77, identifier:exists; 78, argument_list; 78, 79; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:os; 83, identifier:path; 84, identifier:join; 85, argument_list; 85, 86; 85, 87; 86, identifier:mfile; 87, string:'tree'; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, call; 90, 91; 90, 92; 91, identifier:copy_modules; 92, argument_list; 92, 93; 92, 96; 92, 99; 93, keyword_argument; 93, 94; 93, 95; 94, identifier:filespath; 95, identifier:filespath; 96, keyword_argument; 96, 97; 96, 98; 97, identifier:modules_path; 98, identifier:mfile; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:verbose; 101, identifier:verbose; 102, else_clause; 102, 103; 103, block; 103, 104; 104, return_statement; 105, else_clause; 105, 106; 106, block; 106, 107; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:modules_path; 110, subscript; 110, 111; 110, 112; 111, identifier:split_mods; 112, integer:0; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:tree_mod; 116, call; 116, 117; 116, 122; 117, attribute; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:os; 120, identifier:path; 121, identifier:join; 122, argument_list; 122, 123; 122, 124; 123, identifier:modules_path; 124, string:'tree'; 125, if_statement; 125, 126; 125, 135; 126, not_operator; 126, 127; 127, call; 127, 128; 127, 133; 128, attribute; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:os; 131, identifier:path; 132, identifier:isdir; 133, argument_list; 133, 134; 134, identifier:tree_mod; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:os; 140, identifier:makedirs; 141, argument_list; 141, 142; 142, identifier:tree_mod; 143, if_statement; 143, 144; 143, 145; 144, identifier:verbose; 145, block; 145, 146; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 149; 148, identifier:print; 149, argument_list; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, string:'Copying modules from etc/ into {0}'; 153, identifier:format; 154, argument_list; 154, 155; 155, identifier:tree_mod; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:module_files; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:glob; 162, identifier:glob; 163, argument_list; 163, 164; 164, call; 164, 165; 164, 170; 165, attribute; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:os; 168, identifier:path; 169, identifier:join; 170, argument_list; 170, 171; 170, 172; 171, identifier:filespath; 172, string:'*.module'; 173, for_statement; 173, 174; 173, 175; 173, 176; 174, identifier:mfile; 175, identifier:module_files; 176, block; 176, 177; 176, 197; 176, 209; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:base; 180, subscript; 180, 181; 180, 196; 181, call; 181, 182; 181, 187; 182, attribute; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:os; 185, identifier:path; 186, identifier:splitext; 187, argument_list; 187, 188; 188, call; 188, 189; 188, 194; 189, attribute; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:os; 192, identifier:path; 193, identifier:basename; 194, argument_list; 194, 195; 195, identifier:mfile; 196, integer:0; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:tree_out; 200, call; 200, 201; 200, 206; 201, attribute; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:os; 204, identifier:path; 205, identifier:join; 206, argument_list; 206, 207; 206, 208; 207, identifier:tree_mod; 208, identifier:base; 209, expression_statement; 209, 210; 210, call; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:shutil; 213, identifier:copy2; 214, argument_list; 214, 215; 214, 216; 215, identifier:mfile; 216, identifier:tree_out; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:version; 220, call; 220, 221; 220, 226; 221, attribute; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:os; 224, identifier:path; 225, identifier:join; 226, argument_list; 226, 227; 226, 228; 227, identifier:filespath; 228, string:'.version'; 229, if_statement; 229, 230; 229, 238; 230, call; 230, 231; 230, 236; 231, attribute; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:os; 234, identifier:path; 235, identifier:isfile; 236, argument_list; 236, 237; 237, identifier:version; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:shutil; 243, identifier:copy2; 244, argument_list; 244, 245; 244, 246; 245, identifier:version; 246, identifier:tree_mod | def copy_modules(filespath=None, modules_path=None, verbose=None):
''' Copy over the tree module files into your path '''
if not modules_path:
modulepath = os.getenv("MODULEPATH")
if not modulepath:
modules_path = input('Enter the root path for your module files:')
else:
split_mods = modulepath.split(':')
if len(split_mods) > 1:
if verbose:
print('Multiple module paths found. Finding all that contain a tree directory.')
for mfile in split_mods:
if os.path.exists(os.path.join(mfile, 'tree')):
copy_modules(filespath=filespath, modules_path=mfile, verbose=verbose)
else:
return
else:
modules_path = split_mods[0]
tree_mod = os.path.join(modules_path, 'tree')
if not os.path.isdir(tree_mod):
os.makedirs(tree_mod)
if verbose:
print('Copying modules from etc/ into {0}'.format(tree_mod))
module_files = glob.glob(os.path.join(filespath, '*.module'))
for mfile in module_files:
base = os.path.splitext(os.path.basename(mfile))[0]
tree_out = os.path.join(tree_mod, base)
shutil.copy2(mfile, tree_out)
version = os.path.join(filespath, '.version')
if os.path.isfile(version):
shutil.copy2(version, tree_mod) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:_repr_html_; 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:indices; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:iops; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:lx; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:li; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:lls; 19, None; 20, block; 20, 21; 20, 27; 20, 33; 20, 47; 20, 86; 20, 111; 20, 146; 20, 150; 20, 157; 20, 164; 20, 178; 20, 206; 20, 232; 20, 243; 20, 302; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:filter_; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:_current_slice_; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:vals; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:flat; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:is; 34, 35; 34, 36; 35, identifier:indices; 36, None; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:indices; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:_indices; 45, argument_list; 45, 46; 46, identifier:filter_; 47, if_statement; 47, 48; 47, 51; 48, comparison_operator:is; 48, 49; 48, 50; 49, identifier:iops; 50, None; 51, block; 51, 52; 51, 61; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:ravi; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:_raveled_index; 59, argument_list; 59, 60; 60, identifier:filter_; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:iops; 64, call; 64, 65; 64, 66; 65, identifier:OrderedDict; 66, generator_expression; 66, 67; 66, 75; 67, list:[name, iop.properties_for(ravi)]; 67, 68; 67, 69; 68, identifier:name; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:iop; 72, identifier:properties_for; 73, argument_list; 73, 74; 74, identifier:ravi; 75, for_in_clause; 75, 76; 75, 79; 76, pattern_list; 76, 77; 76, 78; 77, identifier:name; 78, identifier:iop; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:_index_operations; 84, identifier:items; 85, argument_list; 86, if_statement; 86, 87; 86, 90; 87, comparison_operator:is; 87, 88; 87, 89; 88, identifier:lls; 89, None; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:lls; 94, list_comprehension; 94, 95; 94, 102; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:self; 98, identifier:_max_len_names; 99, argument_list; 99, 100; 99, 101; 100, identifier:iop; 101, identifier:name; 102, for_in_clause; 102, 103; 102, 106; 103, pattern_list; 103, 104; 103, 105; 104, identifier:name; 105, identifier:iop; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:iops; 109, identifier:items; 110, argument_list; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:header_format; 114, assignment; 114, 115; 114, 116; 115, identifier:header; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:header_format; 119, identifier:format; 120, argument_list; 120, 121; 120, 128; 120, 131; 121, keyword_argument; 121, 122; 121, 123; 122, identifier:x; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:hierarchy_name; 127, argument_list; 128, keyword_argument; 128, 129; 128, 130; 129, identifier:i; 130, identifier:__index_name__; 131, keyword_argument; 131, 132; 131, 133; 132, identifier:iops; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, string:"</b></th><th><b>"; 136, identifier:join; 137, argument_list; 137, 138; 138, call; 138, 139; 138, 140; 139, identifier:list; 140, argument_list; 140, 141; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:iops; 144, identifier:keys; 145, argument_list; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:to_print; 149, list:[
]; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:to_print; 154, identifier:append; 155, argument_list; 155, 156; 156, string:'<table class="tg">'; 157, expression_statement; 157, 158; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:to_print; 161, identifier:append; 162, argument_list; 162, 163; 163, identifier:header; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:format_spec; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:_format_spec; 171, argument_list; 171, 172; 171, 173; 171, 174; 171, 175; 171, 176; 171, 177; 172, identifier:indices; 173, identifier:iops; 174, identifier:lx; 175, identifier:li; 176, identifier:lls; 177, False; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 185; 180, subscript; 180, 181; 180, 182; 181, identifier:format_spec; 182, slice; 182, 183; 182, 184; 183, colon; 184, integer:2; 185, list:["<tr><td class=tg-left>{i}</td>".format(i=format_spec[0]), "<td class=tg-right>{i}</td>".format(i=format_spec[1])]; 185, 186; 185, 196; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, string:"<tr><td class=tg-left>{i}</td>"; 189, identifier:format; 190, argument_list; 190, 191; 191, keyword_argument; 191, 192; 191, 193; 192, identifier:i; 193, subscript; 193, 194; 193, 195; 194, identifier:format_spec; 195, integer:0; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, string:"<td class=tg-right>{i}</td>"; 199, identifier:format; 200, argument_list; 200, 201; 201, keyword_argument; 201, 202; 201, 203; 202, identifier:i; 203, subscript; 203, 204; 203, 205; 204, identifier:format_spec; 205, integer:1; 206, for_statement; 206, 207; 206, 208; 206, 216; 207, identifier:i; 208, call; 208, 209; 208, 210; 209, identifier:range; 210, argument_list; 210, 211; 210, 212; 211, integer:2; 212, call; 212, 213; 212, 214; 213, identifier:len; 214, argument_list; 214, 215; 215, identifier:format_spec; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 222; 219, subscript; 219, 220; 219, 221; 220, identifier:format_spec; 221, identifier:i; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, string:'<td class=tg-left>{c}</td>'; 225, identifier:format; 226, argument_list; 226, 227; 227, keyword_argument; 227, 228; 227, 229; 228, identifier:c; 229, subscript; 229, 230; 229, 231; 230, identifier:format_spec; 231, identifier:i; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:format_spec; 235, binary_operator:+; 235, 236; 235, 242; 236, call; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, string:""; 239, identifier:join; 240, argument_list; 240, 241; 241, identifier:format_spec; 242, string:'</tr>'; 243, for_statement; 243, 244; 243, 245; 243, 251; 244, identifier:i; 245, call; 245, 246; 245, 247; 246, identifier:range; 247, argument_list; 247, 248; 248, attribute; 248, 249; 248, 250; 249, identifier:self; 250, identifier:size; 251, block; 251, 252; 252, expression_statement; 252, 253; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:to_print; 256, identifier:append; 257, argument_list; 257, 258; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:format_spec; 261, identifier:format; 262, argument_list; 262, 263; 262, 268; 262, 279; 263, keyword_argument; 263, 264; 263, 265; 264, identifier:index; 265, subscript; 265, 266; 265, 267; 266, identifier:indices; 267, identifier:i; 268, keyword_argument; 268, 269; 268, 270; 269, identifier:value; 270, call; 270, 271; 270, 274; 271, attribute; 271, 272; 271, 273; 272, string:"{1:.{0}f}"; 273, identifier:format; 274, argument_list; 274, 275; 274, 276; 275, identifier:__precision__; 276, subscript; 276, 277; 276, 278; 277, identifier:vals; 278, identifier:i; 279, dictionary_splat; 279, 280; 280, call; 280, 281; 280, 282; 281, identifier:dict; 282, generator_expression; 282, 283; 282, 299; 283, tuple; 283, 284; 283, 285; 284, identifier:name; 285, call; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, string:' '; 288, identifier:join; 289, argument_list; 289, 290; 290, call; 290, 291; 290, 292; 291, identifier:map; 292, argument_list; 292, 293; 292, 294; 293, identifier:str; 294, subscript; 294, 295; 294, 298; 295, subscript; 295, 296; 295, 297; 296, identifier:iops; 297, identifier:name; 298, identifier:i; 299, for_in_clause; 299, 300; 299, 301; 300, identifier:name; 301, identifier:iops; 302, return_statement; 302, 303; 303, call; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, string:'\n'; 306, identifier:join; 307, argument_list; 307, 308; 308, identifier:to_print | def _repr_html_(self, indices=None, iops=None, lx=None, li=None, lls=None):
filter_ = self._current_slice_
vals = self.flat
if indices is None: indices = self._indices(filter_)
if iops is None:
ravi = self._raveled_index(filter_)
iops = OrderedDict([name, iop.properties_for(ravi)] for name, iop in self._index_operations.items())
if lls is None: lls = [self._max_len_names(iop, name) for name, iop in iops.items()]
header_format =
header = header_format.format(x=self.hierarchy_name(), i=__index_name__, iops="</b></th><th><b>".join(list(iops.keys())))
to_print = [
]
to_print.append('<table class="tg">')
to_print.append(header)
format_spec = self._format_spec(indices, iops, lx, li, lls, False)
format_spec[:2] = ["<tr><td class=tg-left>{i}</td>".format(i=format_spec[0]), "<td class=tg-right>{i}</td>".format(i=format_spec[1])]
for i in range(2, len(format_spec)):
format_spec[i] = '<td class=tg-left>{c}</td>'.format(c=format_spec[i])
format_spec = "".join(format_spec) + '</tr>'
for i in range(self.size):
to_print.append(format_spec.format(index=indices[i], value="{1:.{0}f}".format(__precision__, vals[i]), **dict((name, ' '.join(map(str, iops[name][i]))) for name in iops)))
return '\n'.join(to_print) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:optimize_restarts; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:num_restarts; 7, integer:10; 8, default_parameter; 8, 9; 8, 10; 9, identifier:robust; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, identifier:verbose; 13, True; 14, default_parameter; 14, 15; 14, 16; 15, identifier:parallel; 16, False; 17, default_parameter; 17, 18; 17, 19; 18, identifier:num_processes; 19, None; 20, dictionary_splat_pattern; 20, 21; 21, identifier:kwargs; 22, block; 22, 23; 22, 32; 22, 42; 22, 138; 22, 235; 22, 288; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:initial_length; 26, call; 26, 27; 26, 28; 27, identifier:len; 28, argument_list; 28, 29; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:optimization_runs; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:initial_parameters; 35, call; 35, 36; 35, 41; 36, attribute; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:optimizer_array; 40, identifier:copy; 41, argument_list; 42, if_statement; 42, 43; 42, 44; 43, identifier:parallel; 44, block; 44, 45; 45, try_statement; 45, 46; 45, 118; 46, block; 46, 47; 46, 58; 46, 73; 46, 90; 46, 106; 46, 112; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:pool; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:mp; 53, identifier:Pool; 54, argument_list; 54, 55; 55, keyword_argument; 55, 56; 55, 57; 56, identifier:processes; 57, identifier:num_processes; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:obs; 61, list_comprehension; 61, 62; 61, 67; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:copy; 66, argument_list; 67, for_in_clause; 67, 68; 67, 69; 68, identifier:i; 69, call; 69, 70; 69, 71; 70, identifier:range; 71, argument_list; 71, 72; 72, identifier:num_restarts; 73, expression_statement; 73, 74; 74, list_comprehension; 74, 75; 74, 82; 75, call; 75, 76; 75, 81; 76, attribute; 76, 77; 76, 80; 77, subscript; 77, 78; 77, 79; 78, identifier:obs; 79, identifier:i; 80, identifier:randomize; 81, argument_list; 82, for_in_clause; 82, 83; 82, 84; 83, identifier:i; 84, call; 84, 85; 84, 86; 85, identifier:range; 86, argument_list; 86, 87; 87, binary_operator:-; 87, 88; 87, 89; 88, identifier:num_restarts; 89, integer:1; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:jobs; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:pool; 96, identifier:map; 97, argument_list; 97, 98; 97, 99; 98, identifier:opt_wrapper; 99, list_comprehension; 99, 100; 99, 103; 100, tuple; 100, 101; 100, 102; 101, identifier:o; 102, identifier:kwargs; 103, for_in_clause; 103, 104; 103, 105; 104, identifier:o; 105, identifier:obs; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:pool; 110, identifier:close; 111, argument_list; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:pool; 116, identifier:join; 117, argument_list; 118, except_clause; 118, 119; 118, 120; 119, identifier:KeyboardInterrupt; 120, block; 120, 121; 120, 126; 120, 132; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 124; 123, identifier:print; 124, argument_list; 124, 125; 125, string:"Ctrl+c received, terminating and joining pool."; 126, expression_statement; 126, 127; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:pool; 130, identifier:terminate; 131, argument_list; 132, expression_statement; 132, 133; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:pool; 136, identifier:join; 137, argument_list; 138, for_statement; 138, 139; 138, 140; 138, 144; 139, identifier:i; 140, call; 140, 141; 140, 142; 141, identifier:range; 142, argument_list; 142, 143; 143, identifier:num_restarts; 144, block; 144, 145; 145, try_statement; 145, 146; 145, 208; 146, block; 146, 147; 146, 183; 147, if_statement; 147, 148; 147, 150; 147, 170; 148, not_operator; 148, 149; 149, identifier:parallel; 150, block; 150, 151; 150, 162; 151, if_statement; 151, 152; 151, 155; 152, comparison_operator:>; 152, 153; 152, 154; 153, identifier:i; 154, integer:0; 155, block; 155, 156; 156, expression_statement; 156, 157; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:randomize; 161, argument_list; 162, expression_statement; 162, 163; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:self; 166, identifier:optimize; 167, argument_list; 167, 168; 168, dictionary_splat; 168, 169; 169, identifier:kwargs; 170, else_clause; 170, 171; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 179; 174, attribute; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:self; 177, identifier:optimization_runs; 178, identifier:append; 179, argument_list; 179, 180; 180, subscript; 180, 181; 180, 182; 181, identifier:jobs; 182, identifier:i; 183, if_statement; 183, 184; 183, 185; 184, identifier:verbose; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, call; 187, 188; 187, 189; 188, identifier:print; 189, argument_list; 189, 190; 190, parenthesized_expression; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, string:"Optimization restart {0}/{1}, f = {2}"; 194, identifier:format; 195, argument_list; 195, 196; 195, 199; 195, 200; 196, binary_operator:+; 196, 197; 196, 198; 197, identifier:i; 198, integer:1; 199, identifier:num_restarts; 200, attribute; 200, 201; 200, 207; 201, subscript; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:self; 204, identifier:optimization_runs; 205, unary_operator:-; 205, 206; 206, integer:1; 207, identifier:f_opt; 208, except_clause; 208, 209; 208, 213; 209, as_pattern; 209, 210; 209, 211; 210, identifier:Exception; 211, as_pattern_target; 211, 212; 212, identifier:e; 213, block; 213, 214; 214, if_statement; 214, 215; 214, 216; 214, 231; 215, identifier:robust; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, call; 218, 219; 218, 220; 219, identifier:print; 220, argument_list; 220, 221; 221, parenthesized_expression; 221, 222; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, string:"Warning - optimization restart {0}/{1} failed"; 225, identifier:format; 226, argument_list; 226, 227; 226, 230; 227, binary_operator:+; 227, 228; 227, 229; 228, identifier:i; 229, integer:1; 230, identifier:num_restarts; 231, else_clause; 231, 232; 232, block; 232, 233; 233, raise_statement; 233, 234; 234, identifier:e; 235, if_statement; 235, 236; 235, 244; 235, 280; 236, comparison_operator:>; 236, 237; 236, 243; 237, call; 237, 238; 237, 239; 238, identifier:len; 239, argument_list; 239, 240; 240, attribute; 240, 241; 240, 242; 241, identifier:self; 242, identifier:optimization_runs; 243, identifier:initial_length; 244, block; 244, 245; 244, 266; 245, expression_statement; 245, 246; 246, assignment; 246, 247; 246, 248; 247, identifier:i; 248, call; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:np; 251, identifier:argmin; 252, argument_list; 252, 253; 253, list_comprehension; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:o; 256, identifier:f_opt; 257, for_in_clause; 257, 258; 257, 259; 258, identifier:o; 259, subscript; 259, 260; 259, 263; 260, attribute; 260, 261; 260, 262; 261, identifier:self; 262, identifier:optimization_runs; 263, slice; 263, 264; 263, 265; 264, identifier:initial_length; 265, colon; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:self; 270, identifier:optimizer_array; 271, attribute; 271, 272; 271, 279; 272, subscript; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:self; 275, identifier:optimization_runs; 276, binary_operator:+; 276, 277; 276, 278; 277, identifier:initial_length; 278, identifier:i; 279, identifier:x_opt; 280, else_clause; 280, 281; 281, block; 281, 282; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:self; 286, identifier:optimizer_array; 287, identifier:initial_parameters; 288, return_statement; 288, 289; 289, attribute; 289, 290; 289, 291; 290, identifier:self; 291, identifier:optimization_runs | def optimize_restarts(self, num_restarts=10, robust=False, verbose=True, parallel=False, num_processes=None, **kwargs):
initial_length = len(self.optimization_runs)
initial_parameters = self.optimizer_array.copy()
if parallel:
try:
pool = mp.Pool(processes=num_processes)
obs = [self.copy() for i in range(num_restarts)]
[obs[i].randomize() for i in range(num_restarts-1)]
jobs = pool.map(opt_wrapper, [(o,kwargs) for o in obs])
pool.close()
pool.join()
except KeyboardInterrupt:
print("Ctrl+c received, terminating and joining pool.")
pool.terminate()
pool.join()
for i in range(num_restarts):
try:
if not parallel:
if i > 0:
self.randomize()
self.optimize(**kwargs)
else:
self.optimization_runs.append(jobs[i])
if verbose:
print(("Optimization restart {0}/{1}, f = {2}".format(i + 1, num_restarts, self.optimization_runs[-1].f_opt)))
except Exception as e:
if robust:
print(("Warning - optimization restart {0}/{1} failed".format(i + 1, num_restarts)))
else:
raise e
if len(self.optimization_runs) > initial_length:
i = np.argmin([o.f_opt for o in self.optimization_runs[initial_length:]])
self.optimizer_array = self.optimization_runs[initial_length + i].x_opt
else:
self.optimizer_array = initial_parameters
return self.optimization_runs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:optimizer_array; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 42; 5, 102; 5, 123; 6, if_statement; 6, 7; 6, 28; 7, boolean_operator:or; 7, 8; 7, 19; 8, comparison_operator:is; 8, 9; 8, 18; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:__dict__; 14, identifier:get; 15, argument_list; 15, 16; 15, 17; 16, string:'_optimizer_copy_'; 17, None; 18, None; 19, comparison_operator:!=; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:size; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:_optimizer_copy_; 27, identifier:size; 28, block; 28, 29; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:_optimizer_copy_; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:np; 37, identifier:empty; 38, argument_list; 38, 39; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:size; 42, if_statement; 42, 43; 42, 47; 43, not_operator; 43, 44; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:_optimizer_copy_transformed; 47, block; 47, 48; 47, 60; 47, 96; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 55; 50, attribute; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:_optimizer_copy_; 54, identifier:flat; 55, attribute; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:param_array; 59, identifier:flat; 60, expression_statement; 60, 61; 61, list_comprehension; 61, 62; 61, 81; 61, 92; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:np; 65, identifier:put; 66, argument_list; 66, 67; 66, 70; 66, 71; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:_optimizer_copy_; 70, identifier:ind; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:c; 74, identifier:finv; 75, argument_list; 75, 76; 76, subscript; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:param_array; 80, identifier:ind; 81, for_in_clause; 81, 82; 81, 85; 82, pattern_list; 82, 83; 82, 84; 83, identifier:c; 84, identifier:ind; 85, call; 85, 86; 85, 91; 86, attribute; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:constraints; 90, identifier:items; 91, argument_list; 92, if_clause; 92, 93; 93, comparison_operator:!=; 93, 94; 93, 95; 94, identifier:c; 95, identifier:__fixed__; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:self; 100, identifier:_optimizer_copy_transformed; 101, True; 102, if_statement; 102, 103; 102, 108; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:_has_fixes; 107, argument_list; 108, block; 108, 109; 108, 115; 109, expression_statement; 109, 110; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:_ensure_fixes; 114, argument_list; 115, return_statement; 115, 116; 116, subscript; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:_optimizer_copy_; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:_fixes_; 123, return_statement; 123, 124; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:_optimizer_copy_ | def optimizer_array(self):
if self.__dict__.get('_optimizer_copy_', None) is None or self.size != self._optimizer_copy_.size:
self._optimizer_copy_ = np.empty(self.size)
if not self._optimizer_copy_transformed:
self._optimizer_copy_.flat = self.param_array.flat
[np.put(self._optimizer_copy_, ind, c.finv(self.param_array[ind])) for c, ind in self.constraints.items() if c != __fixed__]
self._optimizer_copy_transformed = True
if self._has_fixes():
self._ensure_fixes()
return self._optimizer_copy_[self._fixes_]
return self._optimizer_copy_ |
0, module; 0, 1; 1, ERROR; 1, 2; 1, 281; 2, function_definition; 2, 3; 2, 4; 2, 6; 3, function_name:_parse_content; 4, parameters; 4, 5; 5, identifier:fh; 6, block; 6, 7; 6, 14; 6, 18; 6, 104; 6, 159; 6, 170; 6, 181; 6, 191; 6, 249; 6, 256; 6, 262; 6, 268; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:content; 10, call; 10, 11; 10, 12; 11, identifier:iter; 12, argument_list; 12, 13; 13, identifier:fh; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:deps; 17, dictionary; 18, for_statement; 18, 19; 18, 20; 18, 21; 18, 92; 19, identifier:line; 20, identifier:content; 21, ERROR; 21, 22; 21, 28; 21, 57; 21, 60; 21, 63; 21, 69; 21, 72; 21, 75; 21, 76; 21, 77; 21, 82; 21, 89; 21, 90; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:not; 23, 24; 23, 25; 24, string:'fades'; 25, identifier:line; 26, block; 26, 27; 27, continue_statement; 28, if_statement; 28, 29; 28, 45; 28, 55; 29, ERROR; 29, 30; 29, 31; 29, 32; 29, 37; 29, 38; 29, 44; 30, identifier:continue; 31, identifier:line; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:line; 35, identifier:strip; 36, argument_list; 37, identifier:index_of_last_fades; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:line; 41, identifier:rfind; 42, argument_list; 42, 43; 43, string:'fades'; 44, identifier:index_of_first_hash; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:line; 48, identifier:index; 49, argument_list; 49, 50; 49, 52; 50, ERROR; 50, 51; 51, identifier:if; 52, comparison_operator:>; 52, 53; 52, 54; 53, identifier:index_of_first_hash; 54, identifier:index_of_last_fades; 55, block; 55, 56; 56, continue_statement; 57, pattern_list; 57, 58; 57, 59; 58, identifier:import_part; 59, identifier:fades_part; 60, attribute; 60, 61; 60, 62; 61, identifier:line; 62, identifier:rsplit; 63, comparison_operator:in; 63, 64; 63, 65; 63, 68; 64, string:"
if "; 65, ERROR; 65, 66; 65, 67; 66, identifier:fades; 67, identifier:not; 68, identifier:fades_part; 69, pattern_list; 69, 70; 69, 71; 70, identifier:import_part; 71, identifier:fades_part; 72, attribute; 72, 73; 72, 74; 73, identifier:import_part; 74, identifier:rsplit; 75, ERROR; 76, identifier:fades_part; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:fades_part; 80, identifier:strip; 81, argument_list; 82, not_operator; 82, 83; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:fades_part; 86, identifier:startswith; 87, argument_list; 87, 88; 88, string:"fades"; 89, ERROR; 90, not_operator; 90, 91; 91, identifier:import_part; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:import_part; 96, call; 96, 97; 96, 103; 97, attribute; 97, 98; 97, 102; 98, call; 98, 99; 98, 100; 99, identifier:next; 100, argument_list; 100, 101; 101, identifier:content; 102, identifier:strip; 103, argument_list; 104, if_statement; 104, 105; 104, 108; 104, 122; 104, 129; 104, 148; 105, attribute; 105, 106; 105, 107; 106, identifier:import_part; 107, identifier:startswith; 108, ERROR; 108, 109; 108, 111; 108, 112; 108, 117; 109, ERROR; 109, 110; 110, identifier:continue; 111, identifier:import_tokens; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:import_part; 115, identifier:split; 116, argument_list; 117, comparison_operator:==; 117, 118; 117, 121; 118, subscript; 118, 119; 118, 120; 119, identifier:import_tokens; 120, integer:0; 121, string:'import'; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:module_path; 126, subscript; 126, 127; 126, 128; 127, identifier:import_tokens; 128, integer:1; 129, elif_clause; 129, 130; 129, 141; 130, boolean_operator:and; 130, 131; 130, 136; 131, comparison_operator:==; 131, 132; 131, 135; 132, subscript; 132, 133; 132, 134; 133, identifier:import_tokens; 134, integer:0; 135, string:'from'; 136, comparison_operator:==; 136, 137; 136, 140; 137, subscript; 137, 138; 137, 139; 138, identifier:import_tokens; 139, integer:2; 140, string:'import'; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:module_path; 145, subscript; 145, 146; 145, 147; 146, identifier:import_tokens; 147, integer:1; 148, else_clause; 148, 149; 149, block; 149, 150; 149, 158; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:logger; 154, identifier:debug; 155, argument_list; 155, 156; 155, 157; 156, string:"Not understood import info: %s"; 157, identifier:import_tokens; 158, continue_statement; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:module; 162, subscript; 162, 163; 162, 169; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:module_path; 166, identifier:split; 167, argument_list; 167, 168; 168, string:"."; 169, integer:0; 170, if_statement; 170, 171; 170, 174; 171, comparison_operator:in; 171, 172; 171, 173; 172, identifier:module; 173, identifier:PKG_NAMES_DB; 174, block; 174, 175; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:module; 178, subscript; 178, 179; 178, 180; 179, identifier:PKG_NAMES_DB; 180, identifier:module; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 184; 183, identifier:module; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:module; 187, identifier:replace; 188, argument_list; 188, 189; 188, 190; 189, string:'_'; 190, string:'-'; 191, if_statement; 191, 192; 191, 212; 191, 223; 191, 239; 192, boolean_operator:or; 192, 193; 192, 199; 193, comparison_operator:==; 193, 194; 193, 198; 194, call; 194, 195; 194, 196; 195, identifier:len; 196, argument_list; 196, 197; 197, identifier:fades_part; 198, integer:5; 199, comparison_operator:in; 199, 200; 199, 211; 200, subscript; 200, 201; 200, 210; 201, call; 201, 202; 201, 209; 202, attribute; 202, 203; 202, 208; 203, subscript; 203, 204; 203, 205; 204, identifier:fades_part; 205, slice; 205, 206; 205, 207; 206, integer:5; 207, colon; 208, identifier:strip; 209, argument_list; 210, integer:0; 211, string:"<>=!"; 212, block; 212, 213; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 216; 215, identifier:requirement; 216, binary_operator:+; 216, 217; 216, 218; 217, identifier:module; 218, subscript; 218, 219; 218, 220; 219, identifier:fades_part; 220, slice; 220, 221; 220, 222; 221, integer:5; 222, colon; 223, elif_clause; 223, 224; 223, 229; 224, comparison_operator:!=; 224, 225; 224, 228; 225, subscript; 225, 226; 225, 227; 226, identifier:fades_part; 227, integer:5; 228, string:" "; 229, block; 229, 230; 229, 238; 230, expression_statement; 230, 231; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:logger; 234, identifier:warning; 235, argument_list; 235, 236; 235, 237; 236, string:"Not understood fades info: %r"; 237, identifier:fades_part; 238, continue_statement; 239, else_clause; 239, 240; 240, block; 240, 241; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:requirement; 244, subscript; 244, 245; 244, 246; 245, identifier:fades_part; 246, slice; 246, 247; 246, 248; 247, integer:5; 248, colon; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 252; 251, identifier:parsed_req; 252, call; 252, 253; 252, 254; 253, identifier:parse_fade_requirement; 254, argument_list; 254, 255; 255, identifier:requirement; 256, if_statement; 256, 257; 256, 260; 257, comparison_operator:is; 257, 258; 257, 259; 258, identifier:parsed_req; 259, None; 260, block; 260, 261; 261, continue_statement; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 267; 264, pattern_list; 264, 265; 264, 266; 265, identifier:repo; 266, identifier:dependency; 267, identifier:parsed_req; 268, expression_statement; 268, 269; 269, call; 269, 270; 269, 279; 270, attribute; 270, 271; 270, 278; 271, call; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:deps; 274, identifier:setdefault; 275, argument_list; 275, 276; 275, 277; 276, identifier:repo; 277, list:[]; 278, identifier:append; 279, argument_list; 279, 280; 280, identifier:dependency; 281, return_statement; 281, 282; 282, identifier:deps | def _parse_content(fh):
content = iter(fh)
deps = {}
for line in content:
if 'fades' not in line:
continue
if '
continue
line = line.strip()
index_of_last_fades = line.rfind('fades')
index_of_first_hash = line.index('
if index_of_first_hash > index_of_last_fades:
continue
import_part, fades_part = line.rsplit("
if "fades" not in fades_part:
import_part, fades_part = import_part.rsplit("
fades_part = fades_part.strip()
if not fades_part.startswith("fades"):
continue
if not import_part:
import_part = next(content).strip()
if import_part.startswith('
continue
import_tokens = import_part.split()
if import_tokens[0] == 'import':
module_path = import_tokens[1]
elif import_tokens[0] == 'from' and import_tokens[2] == 'import':
module_path = import_tokens[1]
else:
logger.debug("Not understood import info: %s", import_tokens)
continue
module = module_path.split(".")[0]
if module in PKG_NAMES_DB:
module = PKG_NAMES_DB[module]
module = module.replace('_', '-')
if len(fades_part) == 5 or fades_part[5:].strip()[0] in "<>=!":
requirement = module + fades_part[5:]
elif fades_part[5] != " ":
logger.warning("Not understood fades info: %r", fades_part)
continue
else:
requirement = fades_part[5:]
parsed_req = parse_fade_requirement(requirement)
if parsed_req is None:
continue
repo, dependency = parsed_req
deps.setdefault(repo, []).append(dependency)
return deps |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_docstring; 3, parameters; 3, 4; 4, identifier:fh; 5, block; 5, 6; 5, 17; 5, 51; 5, 70; 5, 136; 5, 143; 5, 158; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:find_fades; 9, attribute; 9, 10; 9, 16; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:re; 13, identifier:compile; 14, argument_list; 14, 15; 15, string:r'\b(fades)\b:'; 16, identifier:search; 17, for_statement; 17, 18; 17, 19; 17, 20; 17, 47; 18, identifier:line; 19, identifier:fh; 20, block; 20, 21; 20, 34; 21, if_statement; 21, 22; 21, 28; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:line; 25, identifier:startswith; 26, argument_list; 26, 27; 27, string:"'"; 28, block; 28, 29; 28, 33; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:quote; 32, string:"'"; 33, break_statement; 34, if_statement; 34, 35; 34, 41; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:line; 38, identifier:startswith; 39, argument_list; 39, 40; 40, string:'"'; 41, block; 41, 42; 41, 46; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:quote; 45, string:'"'; 46, break_statement; 47, else_clause; 47, 48; 48, block; 48, 49; 49, return_statement; 49, 50; 50, dictionary; 51, if_statement; 51, 52; 51, 57; 51, 64; 52, comparison_operator:==; 52, 53; 52, 56; 53, subscript; 53, 54; 53, 55; 54, identifier:line; 55, integer:1; 56, identifier:quote; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:endquote; 61, binary_operator:*; 61, 62; 61, 63; 62, identifier:quote; 63, integer:3; 64, else_clause; 64, 65; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:endquote; 69, identifier:quote; 70, if_statement; 70, 71; 70, 81; 70, 96; 71, comparison_operator:in; 71, 72; 71, 73; 72, identifier:endquote; 73, subscript; 73, 74; 73, 75; 74, identifier:line; 75, slice; 75, 76; 75, 80; 76, call; 76, 77; 76, 78; 77, identifier:len; 78, argument_list; 78, 79; 79, identifier:endquote; 80, colon; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:docstring_lines; 85, list:[line[:line.index(endquote)]]; 85, 86; 86, subscript; 86, 87; 86, 88; 87, identifier:line; 88, slice; 88, 89; 88, 90; 89, colon; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:line; 93, identifier:index; 94, argument_list; 94, 95; 95, identifier:endquote; 96, else_clause; 96, 97; 97, block; 97, 98; 97, 103; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:docstring_lines; 101, list:[line]; 101, 102; 102, identifier:line; 103, for_statement; 103, 104; 103, 105; 103, 106; 104, identifier:line; 105, identifier:fh; 106, block; 106, 107; 106, 129; 107, if_statement; 107, 108; 107, 111; 108, comparison_operator:in; 108, 109; 108, 110; 109, identifier:endquote; 110, identifier:line; 111, block; 111, 112; 111, 128; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:docstring_lines; 116, identifier:append; 117, argument_list; 117, 118; 118, subscript; 118, 119; 118, 120; 119, identifier:line; 120, slice; 120, 121; 120, 122; 121, colon; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:line; 125, identifier:index; 126, argument_list; 126, 127; 127, identifier:endquote; 128, break_statement; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:docstring_lines; 133, identifier:append; 134, argument_list; 134, 135; 135, identifier:line; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:docstring_lines; 139, call; 139, 140; 139, 141; 140, identifier:iter; 141, argument_list; 141, 142; 142, identifier:docstring_lines; 143, for_statement; 143, 144; 143, 145; 143, 146; 143, 154; 144, identifier:doc_line; 145, identifier:docstring_lines; 146, block; 146, 147; 147, if_statement; 147, 148; 147, 152; 148, call; 148, 149; 148, 150; 149, identifier:find_fades; 150, argument_list; 150, 151; 151, identifier:doc_line; 152, block; 152, 153; 153, break_statement; 154, else_clause; 154, 155; 155, block; 155, 156; 156, return_statement; 156, 157; 157, dictionary; 158, return_statement; 158, 159; 159, call; 159, 160; 159, 161; 160, identifier:_parse_requirement; 161, argument_list; 161, 162; 162, call; 162, 163; 162, 164; 163, identifier:list; 164, argument_list; 164, 165; 165, identifier:docstring_lines | def _parse_docstring(fh):
find_fades = re.compile(r'\b(fades)\b:').search
for line in fh:
if line.startswith("'"):
quote = "'"
break
if line.startswith('"'):
quote = '"'
break
else:
return {}
if line[1] == quote:
endquote = quote * 3
else:
endquote = quote
if endquote in line[len(endquote):]:
docstring_lines = [line[:line.index(endquote)]]
else:
docstring_lines = [line]
for line in fh:
if endquote in line:
docstring_lines.append(line[:line.index(endquote)])
break
docstring_lines.append(line)
docstring_lines = iter(docstring_lines)
for doc_line in docstring_lines:
if find_fades(doc_line):
break
else:
return {}
return _parse_requirement(list(docstring_lines)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_venv_match; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:installed; 6, identifier:requirements; 7, block; 7, 8; 7, 17; 7, 21; 7, 133; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:requirements; 11, block; 11, 12; 12, return_statement; 12, 13; 13, conditional_expression:if; 13, 14; 13, 15; 13, 16; 14, None; 15, identifier:installed; 16, list:[]; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:satisfying_deps; 20, list:[]; 21, for_statement; 21, 22; 21, 25; 21, 30; 22, pattern_list; 22, 23; 22, 24; 23, identifier:repo; 24, identifier:req_deps; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:requirements; 28, identifier:items; 29, argument_list; 30, block; 30, 31; 30, 37; 30, 44; 30, 92; 30, 117; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:useful_inst; 34, call; 34, 35; 34, 36; 35, identifier:set; 36, argument_list; 37, if_statement; 37, 38; 37, 41; 38, comparison_operator:not; 38, 39; 38, 40; 39, identifier:repo; 40, identifier:installed; 41, block; 41, 42; 42, return_statement; 42, 43; 43, None; 44, if_statement; 44, 45; 44, 48; 44, 66; 45, comparison_operator:==; 45, 46; 45, 47; 46, identifier:repo; 47, identifier:REPO_VCS; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:inst_deps; 52, set_comprehension; 52, 53; 52, 57; 53, call; 53, 54; 53, 55; 54, identifier:VCSDependency; 55, argument_list; 55, 56; 56, identifier:url; 57, for_in_clause; 57, 58; 57, 59; 58, identifier:url; 59, call; 59, 60; 59, 65; 60, attribute; 60, 61; 60, 64; 61, subscript; 61, 62; 61, 63; 62, identifier:installed; 63, identifier:repo; 64, identifier:keys; 65, argument_list; 66, else_clause; 66, 67; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:inst_deps; 71, set_comprehension; 71, 72; 71, 81; 72, call; 72, 73; 72, 74; 73, identifier:Distribution; 74, argument_list; 74, 75; 74, 78; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:project_name; 77, identifier:dep; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:version; 80, identifier:ver; 81, for_in_clause; 81, 82; 81, 85; 82, tuple_pattern; 82, 83; 82, 84; 83, identifier:dep; 84, identifier:ver; 85, call; 85, 86; 85, 91; 86, attribute; 86, 87; 86, 90; 87, subscript; 87, 88; 87, 89; 88, identifier:installed; 89, identifier:repo; 90, identifier:items; 91, argument_list; 92, for_statement; 92, 93; 92, 94; 92, 95; 93, identifier:req; 94, identifier:req_deps; 95, block; 95, 96; 96, for_statement; 96, 97; 96, 98; 96, 99; 96, 113; 97, identifier:inst; 98, identifier:inst_deps; 99, block; 99, 100; 100, if_statement; 100, 101; 100, 104; 101, comparison_operator:in; 101, 102; 101, 103; 102, identifier:inst; 103, identifier:req; 104, block; 104, 105; 104, 112; 105, expression_statement; 105, 106; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:useful_inst; 109, identifier:add; 110, argument_list; 110, 111; 111, identifier:inst; 112, break_statement; 113, else_clause; 113, 114; 114, block; 114, 115; 115, return_statement; 115, 116; 116, None; 117, if_statement; 117, 118; 117, 121; 117, 129; 118, comparison_operator:==; 118, 119; 118, 120; 119, identifier:useful_inst; 120, identifier:inst_deps; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:satisfying_deps; 126, identifier:extend; 127, argument_list; 127, 128; 128, identifier:inst_deps; 129, else_clause; 129, 130; 130, block; 130, 131; 131, return_statement; 131, 132; 132, None; 133, return_statement; 133, 134; 134, identifier:satisfying_deps | def _venv_match(self, installed, requirements):
if not requirements:
return None if installed else []
satisfying_deps = []
for repo, req_deps in requirements.items():
useful_inst = set()
if repo not in installed:
return None
if repo == REPO_VCS:
inst_deps = {VCSDependency(url) for url in installed[repo].keys()}
else:
inst_deps = {Distribution(project_name=dep, version=ver)
for (dep, ver) in installed[repo].items()}
for req in req_deps:
for inst in inst_deps:
if inst in req:
useful_inst.add(inst)
break
else:
return None
if useful_inst == inst_deps:
satisfying_deps.extend(inst_deps)
else:
return None
return satisfying_deps |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:encrypt; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:content; 5, default_parameter; 5, 6; 5, 7; 6, identifier:salt; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:key; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:private_key; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:dh; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:auth_secret; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:keyid; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:keylabel; 25, string:"P-256"; 26, default_parameter; 26, 27; 26, 28; 27, identifier:rs; 28, integer:4096; 29, default_parameter; 29, 30; 29, 31; 30, identifier:version; 31, string:"aes128gcm"; 32, block; 32, 33; 32, 129; 32, 195; 32, 205; 32, 219; 32, 252; 32, 260; 32, 287; 32, 297; 32, 303; 32, 307; 32, 311; 32, 350; 32, 406; 33, function_definition; 33, 34; 33, 35; 33, 41; 34, function_name:encrypt_record; 35, parameters; 35, 36; 35, 37; 35, 38; 35, 39; 35, 40; 36, identifier:key; 37, identifier:nonce; 38, identifier:counter; 39, identifier:buf; 40, identifier:last; 41, block; 41, 42; 41, 73; 41, 113; 41, 121; 41, 127; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:encryptor; 45, call; 45, 46; 45, 72; 46, attribute; 46, 47; 46, 71; 47, call; 47, 48; 47, 49; 48, identifier:Cipher; 49, argument_list; 49, 50; 49, 56; 49, 66; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:algorithms; 53, identifier:AES; 54, argument_list; 54, 55; 55, identifier:key; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:modes; 59, identifier:GCM; 60, argument_list; 60, 61; 61, call; 61, 62; 61, 63; 62, identifier:iv; 63, argument_list; 63, 64; 63, 65; 64, identifier:nonce; 65, identifier:counter; 66, keyword_argument; 66, 67; 66, 68; 67, identifier:backend; 68, call; 68, 69; 68, 70; 69, identifier:default_backend; 70, argument_list; 71, identifier:encryptor; 72, argument_list; 73, if_statement; 73, 74; 73, 77; 73, 93; 74, comparison_operator:==; 74, 75; 74, 76; 75, identifier:version; 76, string:'aes128gcm'; 77, block; 77, 78; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:data; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:encryptor; 84, identifier:update; 85, argument_list; 85, 86; 86, binary_operator:+; 86, 87; 86, 88; 87, identifier:buf; 88, parenthesized_expression; 88, 89; 89, conditional_expression:if; 89, 90; 89, 91; 89, 92; 90, string:b'\x02'; 91, identifier:last; 92, string:b'\x01'; 93, else_clause; 93, 94; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:data; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:encryptor; 101, identifier:update; 102, argument_list; 102, 103; 103, binary_operator:+; 103, 104; 103, 112; 104, parenthesized_expression; 104, 105; 105, binary_operator:*; 105, 106; 105, 107; 106, string:b"\x00"; 107, subscript; 107, 108; 107, 111; 108, subscript; 108, 109; 108, 110; 109, identifier:versions; 110, identifier:version; 111, string:'pad'; 112, identifier:buf; 113, expression_statement; 113, 114; 114, augmented_assignment:+=; 114, 115; 114, 116; 115, identifier:data; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:encryptor; 119, identifier:finalize; 120, argument_list; 121, expression_statement; 121, 122; 122, augmented_assignment:+=; 122, 123; 122, 124; 123, identifier:data; 124, attribute; 124, 125; 124, 126; 125, identifier:encryptor; 126, identifier:tag; 127, return_statement; 127, 128; 128, identifier:data; 129, function_definition; 129, 130; 129, 131; 129, 136; 130, function_name:compose_aes128gcm; 131, parameters; 131, 132; 131, 133; 131, 134; 131, 135; 132, identifier:salt; 133, identifier:content; 134, identifier:rs; 135, identifier:keyid; 136, block; 136, 137; 136, 150; 136, 154; 136, 164; 136, 174; 136, 187; 136, 191; 137, if_statement; 137, 138; 137, 144; 138, comparison_operator:>; 138, 139; 138, 143; 139, call; 139, 140; 139, 141; 140, identifier:len; 141, argument_list; 141, 142; 142, identifier:keyid; 143, integer:255; 144, block; 144, 145; 145, raise_statement; 145, 146; 146, call; 146, 147; 146, 148; 147, identifier:ECEException; 148, argument_list; 148, 149; 149, string:"keyid is too long"; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:header; 153, identifier:salt; 154, if_statement; 154, 155; 154, 158; 155, comparison_operator:>; 155, 156; 155, 157; 156, identifier:rs; 157, identifier:MAX_RECORD_SIZE; 158, block; 158, 159; 159, raise_statement; 159, 160; 160, call; 160, 161; 160, 162; 161, identifier:ECEException; 162, argument_list; 162, 163; 163, string:"Too much content"; 164, expression_statement; 164, 165; 165, augmented_assignment:+=; 165, 166; 165, 167; 166, identifier:header; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:struct; 170, identifier:pack; 171, argument_list; 171, 172; 171, 173; 172, string:"!L"; 173, identifier:rs; 174, expression_statement; 174, 175; 175, augmented_assignment:+=; 175, 176; 175, 177; 176, identifier:header; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:struct; 180, identifier:pack; 181, argument_list; 181, 182; 181, 183; 182, string:"!B"; 183, call; 183, 184; 183, 185; 184, identifier:len; 185, argument_list; 185, 186; 186, identifier:keyid; 187, expression_statement; 187, 188; 188, augmented_assignment:+=; 188, 189; 188, 190; 189, identifier:header; 190, identifier:keyid; 191, return_statement; 191, 192; 192, binary_operator:+; 192, 193; 192, 194; 193, identifier:header; 194, identifier:content; 195, if_statement; 195, 196; 195, 199; 196, comparison_operator:not; 196, 197; 196, 198; 197, identifier:version; 198, identifier:versions; 199, block; 199, 200; 200, raise_statement; 200, 201; 201, call; 201, 202; 201, 203; 202, identifier:ECEException; 203, argument_list; 203, 204; 204, string:u"Invalid version"; 205, if_statement; 205, 206; 205, 209; 206, comparison_operator:is; 206, 207; 206, 208; 207, identifier:salt; 208, None; 209, block; 209, 210; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:salt; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:os; 216, identifier:urandom; 217, argument_list; 217, 218; 218, integer:16; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 224; 221, tuple_pattern; 221, 222; 221, 223; 222, identifier:key_; 223, identifier:nonce_; 224, call; 224, 225; 224, 226; 225, identifier:derive_key; 226, argument_list; 226, 227; 226, 228; 226, 231; 226, 234; 226, 237; 226, 240; 226, 243; 226, 246; 226, 249; 227, string:"encrypt"; 228, keyword_argument; 228, 229; 228, 230; 229, identifier:version; 230, identifier:version; 231, keyword_argument; 231, 232; 231, 233; 232, identifier:salt; 233, identifier:salt; 234, keyword_argument; 234, 235; 234, 236; 235, identifier:key; 236, identifier:key; 237, keyword_argument; 237, 238; 237, 239; 238, identifier:private_key; 239, identifier:private_key; 240, keyword_argument; 240, 241; 240, 242; 241, identifier:dh; 242, identifier:dh; 243, keyword_argument; 243, 244; 243, 245; 244, identifier:auth_secret; 245, identifier:auth_secret; 246, keyword_argument; 246, 247; 246, 248; 247, identifier:keyid; 248, identifier:keyid; 249, keyword_argument; 249, 250; 249, 251; 250, identifier:keylabel; 251, identifier:keylabel; 252, expression_statement; 252, 253; 253, assignment; 253, 254; 253, 255; 254, identifier:overhead; 255, subscript; 255, 256; 255, 259; 256, subscript; 256, 257; 256, 258; 257, identifier:versions; 258, identifier:version; 259, string:'pad'; 260, if_statement; 260, 261; 260, 264; 260, 276; 261, comparison_operator:==; 261, 262; 261, 263; 262, identifier:version; 263, string:'aes128gcm'; 264, block; 264, 265; 264, 269; 265, expression_statement; 265, 266; 266, augmented_assignment:+=; 266, 267; 266, 268; 267, identifier:overhead; 268, integer:16; 269, expression_statement; 269, 270; 270, assignment; 270, 271; 270, 272; 271, identifier:end; 272, call; 272, 273; 272, 274; 273, identifier:len; 274, argument_list; 274, 275; 275, identifier:content; 276, else_clause; 276, 277; 277, block; 277, 278; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:end; 281, binary_operator:+; 281, 282; 281, 286; 282, call; 282, 283; 282, 284; 283, identifier:len; 284, argument_list; 284, 285; 285, identifier:content; 286, integer:1; 287, if_statement; 287, 288; 287, 291; 288, comparison_operator:<=; 288, 289; 288, 290; 289, identifier:rs; 290, identifier:overhead; 291, block; 291, 292; 292, raise_statement; 292, 293; 293, call; 293, 294; 293, 295; 294, identifier:ECEException; 295, argument_list; 295, 296; 296, string:u"Record size too small"; 297, expression_statement; 297, 298; 298, assignment; 298, 299; 298, 300; 299, identifier:chunk_size; 300, binary_operator:-; 300, 301; 300, 302; 301, identifier:rs; 302, identifier:overhead; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 306; 305, identifier:result; 306, string:b""; 307, expression_statement; 307, 308; 308, assignment; 308, 309; 308, 310; 309, identifier:counter; 310, integer:0; 311, for_statement; 311, 312; 311, 313; 311, 322; 312, identifier:i; 313, call; 313, 314; 313, 315; 314, identifier:list; 315, argument_list; 315, 316; 316, call; 316, 317; 316, 318; 317, identifier:range; 318, argument_list; 318, 319; 318, 320; 318, 321; 319, integer:0; 320, identifier:end; 321, identifier:chunk_size; 322, block; 322, 323; 322, 346; 323, expression_statement; 323, 324; 324, augmented_assignment:+=; 324, 325; 324, 326; 325, identifier:result; 326, call; 326, 327; 326, 328; 327, identifier:encrypt_record; 328, argument_list; 328, 329; 328, 330; 328, 331; 328, 332; 328, 340; 329, identifier:key_; 330, identifier:nonce_; 331, identifier:counter; 332, subscript; 332, 333; 332, 334; 333, identifier:content; 334, slice; 334, 335; 334, 336; 334, 337; 335, identifier:i; 336, colon; 337, binary_operator:+; 337, 338; 337, 339; 338, identifier:i; 339, identifier:chunk_size; 340, comparison_operator:>=; 340, 341; 340, 345; 341, parenthesized_expression; 341, 342; 342, binary_operator:+; 342, 343; 342, 344; 343, identifier:i; 344, identifier:chunk_size; 345, identifier:end; 346, expression_statement; 346, 347; 347, augmented_assignment:+=; 347, 348; 347, 349; 348, identifier:counter; 349, integer:1; 350, if_statement; 350, 351; 350, 354; 351, comparison_operator:==; 351, 352; 351, 353; 352, identifier:version; 353, string:"aes128gcm"; 354, block; 354, 355; 354, 396; 355, if_statement; 355, 356; 355, 363; 355, 382; 356, boolean_operator:and; 356, 357; 356, 360; 357, comparison_operator:is; 357, 358; 357, 359; 358, identifier:keyid; 359, None; 360, comparison_operator:is; 360, 361; 360, 362; 361, identifier:private_key; 362, None; 363, block; 363, 364; 364, expression_statement; 364, 365; 365, assignment; 365, 366; 365, 367; 366, identifier:kid; 367, call; 367, 368; 367, 375; 368, attribute; 368, 369; 368, 374; 369, call; 369, 370; 369, 373; 370, attribute; 370, 371; 370, 372; 371, identifier:private_key; 372, identifier:public_key; 373, argument_list; 374, identifier:public_bytes; 375, argument_list; 375, 376; 375, 379; 376, attribute; 376, 377; 376, 378; 377, identifier:Encoding; 378, identifier:X962; 379, attribute; 379, 380; 379, 381; 380, identifier:PublicFormat; 381, identifier:UncompressedPoint; 382, else_clause; 382, 383; 383, block; 383, 384; 384, expression_statement; 384, 385; 385, assignment; 385, 386; 385, 387; 386, identifier:kid; 387, call; 387, 388; 387, 394; 388, attribute; 388, 389; 388, 393; 389, parenthesized_expression; 389, 390; 390, boolean_operator:or; 390, 391; 390, 392; 391, identifier:keyid; 392, string:''; 393, identifier:encode; 394, argument_list; 394, 395; 395, string:'utf-8'; 396, return_statement; 396, 397; 397, call; 397, 398; 397, 399; 398, identifier:compose_aes128gcm; 399, argument_list; 399, 400; 399, 401; 399, 402; 399, 403; 400, identifier:salt; 401, identifier:result; 402, identifier:rs; 403, keyword_argument; 403, 404; 403, 405; 404, identifier:keyid; 405, identifier:kid; 406, return_statement; 406, 407; 407, identifier:result | def encrypt(content, salt=None, key=None,
private_key=None, dh=None, auth_secret=None,
keyid=None, keylabel="P-256",
rs=4096, version="aes128gcm"):
def encrypt_record(key, nonce, counter, buf, last):
encryptor = Cipher(
algorithms.AES(key),
modes.GCM(iv(nonce, counter)),
backend=default_backend()
).encryptor()
if version == 'aes128gcm':
data = encryptor.update(buf + (b'\x02' if last else b'\x01'))
else:
data = encryptor.update((b"\x00" * versions[version]['pad']) + buf)
data += encryptor.finalize()
data += encryptor.tag
return data
def compose_aes128gcm(salt, content, rs, keyid):
if len(keyid) > 255:
raise ECEException("keyid is too long")
header = salt
if rs > MAX_RECORD_SIZE:
raise ECEException("Too much content")
header += struct.pack("!L", rs)
header += struct.pack("!B", len(keyid))
header += keyid
return header + content
if version not in versions:
raise ECEException(u"Invalid version")
if salt is None:
salt = os.urandom(16)
(key_, nonce_) = derive_key("encrypt", version=version,
salt=salt, key=key,
private_key=private_key, dh=dh,
auth_secret=auth_secret,
keyid=keyid, keylabel=keylabel)
overhead = versions[version]['pad']
if version == 'aes128gcm':
overhead += 16
end = len(content)
else:
end = len(content) + 1
if rs <= overhead:
raise ECEException(u"Record size too small")
chunk_size = rs - overhead
result = b""
counter = 0
for i in list(range(0, end, chunk_size)):
result += encrypt_record(key_, nonce_, counter,
content[i:i + chunk_size],
(i + chunk_size) >= end)
counter += 1
if version == "aes128gcm":
if keyid is None and private_key is not None:
kid = private_key.public_key().public_bytes(
Encoding.X962,
PublicFormat.UncompressedPoint)
else:
kid = (keyid or '').encode('utf-8')
return compose_aes128gcm(salt, result, rs, keyid=kid)
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_format_ase2clusgeo; 3, parameters; 3, 4; 3, 5; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:all_atomtypes; 7, None; 8, block; 8, 9; 8, 16; 8, 41; 8, 53; 8, 57; 8, 61; 8, 107; 8, 111; 8, 118; 8, 120; 8, 133; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:totalAN; 12, call; 12, 13; 12, 14; 13, identifier:len; 14, argument_list; 14, 15; 15, identifier:obj; 16, if_statement; 16, 17; 16, 20; 16, 28; 17, comparison_operator:is; 17, 18; 17, 19; 18, identifier:all_atomtypes; 19, None; 20, block; 20, 21; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:atomtype_set; 24, call; 24, 25; 24, 26; 25, identifier:set; 26, argument_list; 26, 27; 27, identifier:all_atomtypes; 28, else_clause; 28, 29; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:atomtype_set; 33, call; 33, 34; 33, 35; 34, identifier:set; 35, argument_list; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:obj; 39, identifier:get_atomic_numbers; 40, argument_list; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:atomtype_lst; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:np; 47, identifier:sort; 48, argument_list; 48, 49; 49, call; 49, 50; 49, 51; 50, identifier:list; 51, argument_list; 51, 52; 52, identifier:atomtype_set; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:n_atoms_per_type_lst; 56, list:[]; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:pos_lst; 60, list:[]; 61, for_statement; 61, 62; 61, 63; 61, 64; 62, identifier:atomtype; 63, identifier:atomtype_lst; 64, block; 64, 65; 64, 75; 64, 85; 64, 93; 64, 100; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:condition; 68, comparison_operator:==; 68, 69; 68, 74; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:obj; 72, identifier:get_atomic_numbers; 73, argument_list; 74, identifier:atomtype; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:pos_onetype; 78, subscript; 78, 79; 78, 84; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:obj; 82, identifier:get_positions; 83, argument_list; 84, identifier:condition; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:n_onetype; 88, subscript; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:pos_onetype; 91, identifier:shape; 92, integer:0; 93, expression_statement; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:pos_lst; 97, identifier:append; 98, argument_list; 98, 99; 99, identifier:pos_onetype; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:n_atoms_per_type_lst; 104, identifier:append; 105, argument_list; 105, 106; 106, identifier:n_onetype; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:typeNs; 110, identifier:n_atoms_per_type_lst; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:Ntypes; 114, call; 114, 115; 114, 116; 115, identifier:len; 116, argument_list; 116, 117; 117, identifier:n_atoms_per_type_lst; 118, expression_statement; 118, 119; 119, identifier:atomtype_lst; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:Apos; 123, call; 123, 124; 123, 132; 124, attribute; 124, 125; 124, 131; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:np; 128, identifier:concatenate; 129, argument_list; 129, 130; 130, identifier:pos_lst; 131, identifier:ravel; 132, argument_list; 133, return_statement; 133, 134; 134, expression_list; 134, 135; 134, 136; 134, 137; 134, 138; 134, 139; 135, identifier:Apos; 136, identifier:typeNs; 137, identifier:Ntypes; 138, identifier:atomtype_lst; 139, identifier:totalAN | def _format_ase2clusgeo(obj, all_atomtypes=None):
totalAN = len(obj)
if all_atomtypes is not None:
atomtype_set = set(all_atomtypes)
else:
atomtype_set = set(obj.get_atomic_numbers())
atomtype_lst = np.sort(list(atomtype_set))
n_atoms_per_type_lst = []
pos_lst = []
for atomtype in atomtype_lst:
condition = obj.get_atomic_numbers() == atomtype
pos_onetype = obj.get_positions()[condition]
n_onetype = pos_onetype.shape[0]
pos_lst.append(pos_onetype)
n_atoms_per_type_lst.append(n_onetype)
typeNs = n_atoms_per_type_lst
Ntypes = len(n_atoms_per_type_lst)
atomtype_lst
Apos = np.concatenate(pos_lst).ravel()
return Apos, typeNs, Ntypes, atomtype_lst, totalAN |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:zmax; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 13; 3, 16; 3, 19; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_times; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:func; 10, attribute; 10, 11; 10, 12; 11, identifier:np; 12, identifier:mean; 13, default_parameter; 13, 14; 13, 15; 14, identifier:interp_kwargs; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:minimize_kwargs; 18, None; 19, default_parameter; 19, 20; 19, 21; 20, identifier:approximate; 21, False; 22, block; 22, 23; 22, 39; 22, 61; 22, 85; 22, 89; 22, 93; 22, 147; 23, if_statement; 23, 24; 23, 29; 24, boolean_operator:and; 24, 25; 24, 26; 25, identifier:return_times; 26, comparison_operator:is; 26, 27; 26, 28; 27, identifier:func; 28, None; 29, block; 29, 30; 30, raise_statement; 30, 31; 31, call; 31, 32; 31, 33; 32, identifier:ValueError; 33, argument_list; 33, 34; 34, concatenated_string; 34, 35; 34, 36; 34, 37; 34, 38; 35, string:"Cannot return times if reducing "; 36, string:"using an input function. Pass `func=None` if "; 37, string:"you want to return all individual values "; 38, string:"and times."; 39, if_statement; 39, 40; 39, 43; 39, 55; 40, comparison_operator:is; 40, 41; 40, 42; 41, identifier:func; 42, None; 43, block; 43, 44; 43, 48; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:reduce; 47, False; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:func; 51, lambda; 51, 52; 51, 54; 52, lambda_parameters; 52, 53; 53, identifier:x; 54, identifier:x; 55, else_clause; 55, 56; 56, block; 56, 57; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:reduce; 60, True; 61, if_statement; 61, 62; 61, 74; 62, comparison_operator:<; 62, 63; 62, 69; 63, subscript; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:t; 67, unary_operator:-; 67, 68; 68, integer:1; 69, subscript; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:t; 73, integer:0; 74, block; 74, 75; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:self; 78, subscript; 78, 79; 78, 80; 79, identifier:self; 80, slice; 80, 81; 80, 82; 80, 83; 81, colon; 82, colon; 83, unary_operator:-; 83, 84; 84, integer:1; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:vals; 88, list:[]; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:times; 92, list:[]; 93, for_statement; 93, 94; 93, 95; 93, 100; 94, identifier:orbit; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:self; 98, identifier:orbit_gen; 99, argument_list; 100, block; 100, 101; 100, 130; 100, 140; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 106; 103, pattern_list; 103, 104; 103, 105; 104, identifier:v; 105, identifier:t; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:orbit; 109, identifier:_max_helper; 110, argument_list; 110, 111; 110, 121; 110, 124; 110, 127; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:np; 114, identifier:abs; 115, argument_list; 115, 116; 116, attribute; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:orbit; 119, identifier:cylindrical; 120, identifier:z; 121, keyword_argument; 121, 122; 121, 123; 122, identifier:interp_kwargs; 123, identifier:interp_kwargs; 124, keyword_argument; 124, 125; 124, 126; 125, identifier:minimize_kwargs; 126, identifier:minimize_kwargs; 127, keyword_argument; 127, 128; 127, 129; 128, identifier:approximate; 129, identifier:approximate; 130, expression_statement; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:vals; 134, identifier:append; 135, argument_list; 135, 136; 136, call; 136, 137; 136, 138; 137, identifier:func; 138, argument_list; 138, 139; 139, identifier:v; 140, expression_statement; 140, 141; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:times; 144, identifier:append; 145, argument_list; 145, 146; 146, identifier:t; 147, return_statement; 147, 148; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:_max_return_helper; 152, argument_list; 152, 153; 152, 154; 152, 155; 152, 156; 153, identifier:vals; 154, identifier:times; 155, identifier:return_times; 156, identifier:reduce | def zmax(self, return_times=False, func=np.mean,
interp_kwargs=None, minimize_kwargs=None,
approximate=False):
if return_times and func is not None:
raise ValueError("Cannot return times if reducing "
"using an input function. Pass `func=None` if "
"you want to return all individual values "
"and times.")
if func is None:
reduce = False
func = lambda x: x
else:
reduce = True
if self.t[-1] < self.t[0]:
self = self[::-1]
vals = []
times = []
for orbit in self.orbit_gen():
v, t = orbit._max_helper(np.abs(orbit.cylindrical.z),
interp_kwargs=interp_kwargs,
minimize_kwargs=minimize_kwargs,
approximate=approximate)
vals.append(func(v))
times.append(t)
return self._max_return_helper(vals, times, return_times, reduce) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:align_circulation_with_z; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:circulation; 7, None; 8, block; 8, 9; 8, 22; 8, 32; 8, 38; 8, 44; 8, 80; 8, 105; 8, 137; 8, 145; 8, 153; 8, 294; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifier:circulation; 12, None; 13, block; 13, 14; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:circulation; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:circulation; 21, argument_list; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:circulation; 25, call; 25, 26; 25, 27; 26, identifier:atleast_2d; 27, argument_list; 27, 28; 27, 29; 28, identifier:circulation; 29, keyword_argument; 29, 30; 29, 31; 30, identifier:insert_axis; 31, integer:1; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:cart; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:cartesian; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:pos; 41, attribute; 41, 42; 41, 43; 42, identifier:cart; 43, identifier:xyz; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:vel; 47, binary_operator:*; 47, 48; 47, 75; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:np; 51, identifier:vstack; 52, argument_list; 52, 53; 53, tuple; 53, 54; 53, 61; 53, 68; 54, subscript; 54, 55; 54, 60; 55, attribute; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:cart; 58, identifier:v_x; 59, identifier:value; 60, None; 61, subscript; 61, 62; 61, 67; 62, attribute; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:cart; 65, identifier:v_y; 66, identifier:value; 67, None; 68, subscript; 68, 69; 68, 74; 69, attribute; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:cart; 72, identifier:v_z; 73, identifier:value; 74, None; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:cart; 78, identifier:v_x; 79, identifier:unit; 80, if_statement; 80, 81; 80, 86; 81, comparison_operator:<; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:pos; 84, identifier:ndim; 85, integer:3; 86, block; 86, 87; 86, 96; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:pos; 90, subscript; 90, 91; 90, 92; 90, 93; 91, identifier:pos; 92, ellipsis:...; 93, attribute; 93, 94; 93, 95; 94, identifier:np; 95, identifier:newaxis; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:vel; 99, subscript; 99, 100; 99, 101; 99, 102; 100, identifier:vel; 101, ellipsis:...; 102, attribute; 102, 103; 102, 104; 103, identifier:np; 104, identifier:newaxis; 105, if_statement; 105, 106; 105, 128; 106, parenthesized_expression; 106, 107; 107, boolean_operator:or; 107, 108; 107, 117; 108, comparison_operator:!=; 108, 109; 108, 114; 109, subscript; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:circulation; 112, identifier:shape; 113, integer:0; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:ndim; 117, comparison_operator:!=; 117, 118; 117, 123; 118, subscript; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:circulation; 121, identifier:shape; 122, integer:1; 123, subscript; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:pos; 126, identifier:shape; 127, integer:2; 128, block; 128, 129; 129, raise_statement; 129, 130; 130, call; 130, 131; 130, 132; 131, identifier:ValueError; 132, argument_list; 132, 133; 133, concatenated_string; 133, 134; 133, 135; 133, 136; 134, string:"Shape of 'circulation' array should match the "; 135, string:"shape of the position/velocity (minus the time "; 136, string:"axis)."; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:new_pos; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:pos; 143, identifier:copy; 144, argument_list; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:new_vel; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:vel; 151, identifier:copy; 152, argument_list; 153, for_statement; 153, 154; 153, 155; 153, 163; 154, identifier:n; 155, call; 155, 156; 155, 157; 156, identifier:range; 157, argument_list; 157, 158; 158, subscript; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:pos; 161, identifier:shape; 162, integer:2; 163, block; 163, 164; 163, 186; 163, 207; 163, 238; 163, 252; 163, 266; 163, 280; 164, if_statement; 164, 165; 164, 184; 165, boolean_operator:or; 165, 166; 165, 172; 166, comparison_operator:==; 166, 167; 166, 171; 167, subscript; 167, 168; 167, 169; 167, 170; 168, identifier:circulation; 169, integer:2; 170, identifier:n; 171, integer:1; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:np; 175, identifier:all; 176, argument_list; 176, 177; 177, comparison_operator:==; 177, 178; 177, 183; 178, subscript; 178, 179; 178, 180; 178, 182; 179, identifier:circulation; 180, slice; 180, 181; 181, colon; 182, identifier:n; 183, integer:0; 184, block; 184, 185; 185, continue_statement; 186, if_statement; 186, 187; 186, 197; 187, comparison_operator:>; 187, 188; 187, 196; 188, call; 188, 189; 188, 190; 189, identifier:sum; 190, argument_list; 190, 191; 191, subscript; 191, 192; 191, 193; 191, 195; 192, identifier:circulation; 193, slice; 193, 194; 194, colon; 195, identifier:n; 196, integer:1; 197, block; 197, 198; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:logger; 202, identifier:warning; 203, argument_list; 203, 204; 204, concatenated_string; 204, 205; 204, 206; 205, string:"Circulation about multiple axes - are you sure "; 206, string:"the orbit has been integrated for long enough?"; 207, if_statement; 207, 208; 207, 214; 207, 219; 207, 231; 208, comparison_operator:==; 208, 209; 208, 213; 209, subscript; 209, 210; 209, 211; 209, 212; 210, identifier:circulation; 211, integer:0; 212, identifier:n; 213, integer:1; 214, block; 214, 215; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:circ; 218, integer:0; 219, elif_clause; 219, 220; 219, 226; 220, comparison_operator:==; 220, 221; 220, 225; 221, subscript; 221, 222; 221, 223; 221, 224; 222, identifier:circulation; 223, integer:1; 224, identifier:n; 225, integer:1; 226, block; 226, 227; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:circ; 230, integer:1; 231, else_clause; 231, 232; 232, block; 232, 233; 233, raise_statement; 233, 234; 234, call; 234, 235; 234, 236; 235, identifier:RuntimeError; 236, argument_list; 236, 237; 237, string:"Should never get here..."; 238, expression_statement; 238, 239; 239, assignment; 239, 240; 239, 246; 240, subscript; 240, 241; 240, 242; 240, 243; 240, 245; 241, identifier:new_pos; 242, identifier:circ; 243, slice; 243, 244; 244, colon; 245, identifier:n; 246, subscript; 246, 247; 246, 248; 246, 249; 246, 251; 247, identifier:pos; 248, integer:2; 249, slice; 249, 250; 250, colon; 251, identifier:n; 252, expression_statement; 252, 253; 253, assignment; 253, 254; 253, 260; 254, subscript; 254, 255; 254, 256; 254, 257; 254, 259; 255, identifier:new_pos; 256, integer:2; 257, slice; 257, 258; 258, colon; 259, identifier:n; 260, subscript; 260, 261; 260, 262; 260, 263; 260, 265; 261, identifier:pos; 262, identifier:circ; 263, slice; 263, 264; 264, colon; 265, identifier:n; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 274; 268, subscript; 268, 269; 268, 270; 268, 271; 268, 273; 269, identifier:new_vel; 270, identifier:circ; 271, slice; 271, 272; 272, colon; 273, identifier:n; 274, subscript; 274, 275; 274, 276; 274, 277; 274, 279; 275, identifier:vel; 276, integer:2; 277, slice; 277, 278; 278, colon; 279, identifier:n; 280, expression_statement; 280, 281; 281, assignment; 281, 282; 281, 288; 282, subscript; 282, 283; 282, 284; 282, 285; 282, 287; 283, identifier:new_vel; 284, integer:2; 285, slice; 285, 286; 286, colon; 287, identifier:n; 288, subscript; 288, 289; 288, 290; 288, 291; 288, 293; 289, identifier:vel; 290, identifier:circ; 291, slice; 291, 292; 292, colon; 293, identifier:n; 294, return_statement; 294, 295; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:self; 298, identifier:__class__; 299, argument_list; 299, 300; 299, 312; 299, 324; 299, 329; 300, keyword_argument; 300, 301; 300, 302; 301, identifier:pos; 302, call; 302, 303; 302, 306; 303, attribute; 303, 304; 303, 305; 304, identifier:new_pos; 305, identifier:reshape; 306, argument_list; 306, 307; 307, attribute; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:cart; 310, identifier:xyz; 311, identifier:shape; 312, keyword_argument; 312, 313; 312, 314; 313, identifier:vel; 314, call; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:new_vel; 317, identifier:reshape; 318, argument_list; 318, 319; 319, attribute; 319, 320; 319, 323; 320, attribute; 320, 321; 320, 322; 321, identifier:cart; 322, identifier:xyz; 323, identifier:shape; 324, keyword_argument; 324, 325; 324, 326; 325, identifier:t; 326, attribute; 326, 327; 326, 328; 327, identifier:self; 328, identifier:t; 329, keyword_argument; 329, 330; 329, 331; 330, identifier:hamiltonian; 331, attribute; 331, 332; 331, 333; 332, identifier:self; 333, identifier:hamiltonian | def align_circulation_with_z(self, circulation=None):
if circulation is None:
circulation = self.circulation()
circulation = atleast_2d(circulation, insert_axis=1)
cart = self.cartesian
pos = cart.xyz
vel = np.vstack((cart.v_x.value[None],
cart.v_y.value[None],
cart.v_z.value[None])) * cart.v_x.unit
if pos.ndim < 3:
pos = pos[...,np.newaxis]
vel = vel[...,np.newaxis]
if (circulation.shape[0] != self.ndim or
circulation.shape[1] != pos.shape[2]):
raise ValueError("Shape of 'circulation' array should match the "
"shape of the position/velocity (minus the time "
"axis).")
new_pos = pos.copy()
new_vel = vel.copy()
for n in range(pos.shape[2]):
if circulation[2,n] == 1 or np.all(circulation[:,n] == 0):
continue
if sum(circulation[:,n]) > 1:
logger.warning("Circulation about multiple axes - are you sure "
"the orbit has been integrated for long enough?")
if circulation[0,n] == 1:
circ = 0
elif circulation[1,n] == 1:
circ = 1
else:
raise RuntimeError("Should never get here...")
new_pos[circ,:,n] = pos[2,:,n]
new_pos[2,:,n] = pos[circ,:,n]
new_vel[circ,:,n] = vel[2,:,n]
new_vel[2,:,n] = vel[circ,:,n]
return self.__class__(pos=new_pos.reshape(cart.xyz.shape),
vel=new_vel.reshape(cart.xyz.shape),
t=self.t,
hamiltonian=self.hamiltonian) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:fast_lyapunov_max; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:w0; 5, identifier:hamiltonian; 6, identifier:dt; 7, identifier:n_steps; 8, default_parameter; 8, 9; 8, 10; 9, identifier:d0; 10, float:1e-5; 11, default_parameter; 11, 12; 11, 13; 12, identifier:n_steps_per_pullback; 13, integer:10; 14, default_parameter; 14, 15; 14, 16; 15, identifier:noffset_orbits; 16, integer:2; 17, default_parameter; 17, 18; 17, 19; 18, identifier:t1; 19, float:0.; 20, default_parameter; 20, 21; 20, 22; 21, identifier:atol; 22, float:1E-10; 23, default_parameter; 23, 24; 23, 25; 24, identifier:rtol; 25, float:1E-10; 26, default_parameter; 26, 27; 26, 28; 27, identifier:nmax; 28, integer:0; 29, default_parameter; 29, 30; 29, 31; 30, identifier:return_orbit; 31, True; 32, block; 32, 33; 32, 42; 32, 63; 32, 76; 32, 123; 32, 139; 32, 151; 33, import_from_statement; 33, 34; 33, 38; 33, 40; 34, relative_import; 34, 35; 34, 36; 35, import_prefix; 36, dotted_name; 36, 37; 37, identifier:lyapunov; 38, dotted_name; 38, 39; 39, identifier:dop853_lyapunov_max; 40, dotted_name; 40, 41; 41, identifier:dop853_lyapunov_max_dont_save; 42, if_statement; 42, 43; 42, 48; 43, call; 43, 44; 43, 45; 44, identifier:isinstance; 45, argument_list; 45, 46; 45, 47; 46, identifier:hamiltonian; 47, identifier:PotentialBase; 48, block; 48, 49; 48, 56; 49, import_from_statement; 49, 50; 49, 54; 50, relative_import; 50, 51; 50, 52; 51, import_prefix; 52, dotted_name; 52, 53; 53, identifier:potential; 54, dotted_name; 54, 55; 55, identifier:Hamiltonian; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:hamiltonian; 59, call; 59, 60; 59, 61; 60, identifier:Hamiltonian; 61, argument_list; 61, 62; 62, identifier:hamiltonian; 63, if_statement; 63, 64; 63, 68; 64, not_operator; 64, 65; 65, attribute; 65, 66; 65, 67; 66, identifier:hamiltonian; 67, identifier:c_enabled; 68, block; 68, 69; 69, raise_statement; 69, 70; 70, call; 70, 71; 70, 72; 71, identifier:TypeError; 72, argument_list; 72, 73; 73, concatenated_string; 73, 74; 73, 75; 74, string:"Input Hamiltonian must contain a C-implemented "; 75, string:"potential and frame."; 76, if_statement; 76, 77; 76, 83; 77, not_operator; 77, 78; 78, call; 78, 79; 78, 80; 79, identifier:isinstance; 80, argument_list; 80, 81; 80, 82; 81, identifier:w0; 82, identifier:PhaseSpacePosition; 83, block; 83, 84; 83, 93; 83, 103; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:w0; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:np; 90, identifier:asarray; 91, argument_list; 91, 92; 92, identifier:w0; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:ndim; 96, binary_operator://; 96, 97; 96, 102; 97, subscript; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:w0; 100, identifier:shape; 101, integer:0; 102, integer:2; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:w0; 106, call; 106, 107; 106, 108; 107, identifier:PhaseSpacePosition; 108, argument_list; 108, 109; 108, 116; 109, keyword_argument; 109, 110; 109, 111; 110, identifier:pos; 111, subscript; 111, 112; 111, 113; 112, identifier:w0; 113, slice; 113, 114; 113, 115; 114, colon; 115, identifier:ndim; 116, keyword_argument; 116, 117; 116, 118; 117, identifier:vel; 118, subscript; 118, 119; 118, 120; 119, identifier:w0; 120, slice; 120, 121; 120, 122; 121, identifier:ndim; 122, colon; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:_w0; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:np; 129, identifier:squeeze; 130, argument_list; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:w0; 134, identifier:w; 135, argument_list; 135, 136; 136, attribute; 136, 137; 136, 138; 137, identifier:hamiltonian; 138, identifier:units; 139, if_statement; 139, 140; 139, 145; 140, comparison_operator:>; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:_w0; 143, identifier:ndim; 144, integer:1; 145, block; 145, 146; 146, raise_statement; 146, 147; 147, call; 147, 148; 147, 149; 148, identifier:ValueError; 149, argument_list; 149, 150; 150, string:"Can only compute fast Lyapunov exponent for a single orbit."; 151, if_statement; 151, 152; 151, 153; 151, 238; 152, identifier:return_orbit; 153, block; 153, 154; 153, 176; 153, 187; 153, 208; 153, 232; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 160; 156, pattern_list; 156, 157; 156, 158; 156, 159; 157, identifier:t; 158, identifier:w; 159, identifier:l; 160, call; 160, 161; 160, 162; 161, identifier:dop853_lyapunov_max; 162, argument_list; 162, 163; 162, 164; 162, 165; 162, 166; 162, 169; 162, 170; 162, 171; 162, 172; 162, 173; 162, 174; 162, 175; 163, identifier:hamiltonian; 164, identifier:_w0; 165, identifier:dt; 166, binary_operator:+; 166, 167; 166, 168; 167, identifier:n_steps; 168, integer:1; 169, identifier:t1; 170, identifier:d0; 171, identifier:n_steps_per_pullback; 172, identifier:noffset_orbits; 173, identifier:atol; 174, identifier:rtol; 175, identifier:nmax; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:w; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:np; 182, identifier:rollaxis; 183, argument_list; 183, 184; 183, 185; 184, identifier:w; 185, unary_operator:-; 185, 186; 186, integer:1; 187, try_statement; 187, 188; 187, 197; 188, block; 188, 189; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:tunit; 192, subscript; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:hamiltonian; 195, identifier:units; 196, string:'time'; 197, except_clause; 197, 198; 197, 201; 198, tuple; 198, 199; 198, 200; 199, identifier:TypeError; 200, identifier:AttributeError; 201, block; 201, 202; 202, expression_statement; 202, 203; 203, assignment; 203, 204; 203, 205; 204, identifier:tunit; 205, attribute; 205, 206; 205, 207; 206, identifier:u; 207, identifier:dimensionless_unscaled; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 211; 210, identifier:orbit; 211, call; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:Orbit; 214, identifier:from_w; 215, argument_list; 215, 216; 215, 219; 215, 224; 215, 229; 216, keyword_argument; 216, 217; 216, 218; 217, identifier:w; 218, identifier:w; 219, keyword_argument; 219, 220; 219, 221; 220, identifier:units; 221, attribute; 221, 222; 221, 223; 222, identifier:hamiltonian; 223, identifier:units; 224, keyword_argument; 224, 225; 224, 226; 225, identifier:t; 226, binary_operator:*; 226, 227; 226, 228; 227, identifier:t; 228, identifier:tunit; 229, keyword_argument; 229, 230; 229, 231; 230, identifier:hamiltonian; 231, identifier:hamiltonian; 232, return_statement; 232, 233; 233, expression_list; 233, 234; 233, 237; 234, binary_operator:/; 234, 235; 234, 236; 235, identifier:l; 236, identifier:tunit; 237, identifier:orbit; 238, else_clause; 238, 239; 239, block; 239, 240; 239, 259; 239, 280; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 243; 242, identifier:l; 243, call; 243, 244; 243, 245; 244, identifier:dop853_lyapunov_max_dont_save; 245, argument_list; 245, 246; 245, 247; 245, 248; 245, 249; 245, 252; 245, 253; 245, 254; 245, 255; 245, 256; 245, 257; 245, 258; 246, identifier:hamiltonian; 247, identifier:_w0; 248, identifier:dt; 249, binary_operator:+; 249, 250; 249, 251; 250, identifier:n_steps; 251, integer:1; 252, identifier:t1; 253, identifier:d0; 254, identifier:n_steps_per_pullback; 255, identifier:noffset_orbits; 256, identifier:atol; 257, identifier:rtol; 258, identifier:nmax; 259, try_statement; 259, 260; 259, 269; 260, block; 260, 261; 261, expression_statement; 261, 262; 262, assignment; 262, 263; 262, 264; 263, identifier:tunit; 264, subscript; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:hamiltonian; 267, identifier:units; 268, string:'time'; 269, except_clause; 269, 270; 269, 273; 270, tuple; 270, 271; 270, 272; 271, identifier:TypeError; 272, identifier:AttributeError; 273, block; 273, 274; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:tunit; 277, attribute; 277, 278; 277, 279; 278, identifier:u; 279, identifier:dimensionless_unscaled; 280, return_statement; 280, 281; 281, binary_operator:/; 281, 282; 281, 283; 282, identifier:l; 283, identifier:tunit | def fast_lyapunov_max(w0, hamiltonian, dt, n_steps, d0=1e-5,
n_steps_per_pullback=10, noffset_orbits=2, t1=0.,
atol=1E-10, rtol=1E-10, nmax=0, return_orbit=True):
from .lyapunov import dop853_lyapunov_max, dop853_lyapunov_max_dont_save
if isinstance(hamiltonian, PotentialBase):
from ..potential import Hamiltonian
hamiltonian = Hamiltonian(hamiltonian)
if not hamiltonian.c_enabled:
raise TypeError("Input Hamiltonian must contain a C-implemented "
"potential and frame.")
if not isinstance(w0, PhaseSpacePosition):
w0 = np.asarray(w0)
ndim = w0.shape[0]//2
w0 = PhaseSpacePosition(pos=w0[:ndim],
vel=w0[ndim:])
_w0 = np.squeeze(w0.w(hamiltonian.units))
if _w0.ndim > 1:
raise ValueError("Can only compute fast Lyapunov exponent for a single orbit.")
if return_orbit:
t,w,l = dop853_lyapunov_max(hamiltonian, _w0,
dt, n_steps+1, t1,
d0, n_steps_per_pullback, noffset_orbits,
atol, rtol, nmax)
w = np.rollaxis(w, -1)
try:
tunit = hamiltonian.units['time']
except (TypeError, AttributeError):
tunit = u.dimensionless_unscaled
orbit = Orbit.from_w(w=w, units=hamiltonian.units,
t=t*tunit, hamiltonian=hamiltonian)
return l/tunit, orbit
else:
l = dop853_lyapunov_max_dont_save(hamiltonian, _w0,
dt, n_steps+1, t1,
d0, n_steps_per_pullback, noffset_orbits,
atol, rtol, nmax)
try:
tunit = hamiltonian.units['time']
except (TypeError, AttributeError):
tunit = u.dimensionless_unscaled
return l/tunit |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:estimate_dt_n_steps; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 16; 4, identifier:w0; 5, identifier:hamiltonian; 6, identifier:n_periods; 7, identifier:n_steps_per_period; 8, default_parameter; 8, 9; 8, 10; 9, identifier:dE_threshold; 10, float:1E-9; 11, default_parameter; 11, 12; 11, 13; 12, identifier:func; 13, attribute; 13, 14; 13, 15; 14, identifier:np; 15, identifier:nanmax; 16, dictionary_splat_pattern; 16, 17; 17, identifier:integrate_kwargs; 18, block; 18, 19; 18, 50; 18, 63; 18, 75; 18, 92; 18, 100; 18, 215; 18, 222; 18, 235; 18, 248; 18, 257; 18, 271; 18, 285; 19, if_statement; 19, 20; 19, 26; 20, not_operator; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:isinstance; 23, argument_list; 23, 24; 23, 25; 24, identifier:w0; 25, identifier:PhaseSpacePosition; 26, block; 26, 27; 26, 36; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:w0; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:np; 33, identifier:asarray; 34, argument_list; 34, 35; 35, identifier:w0; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:w0; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:PhaseSpacePosition; 42, identifier:from_w; 43, argument_list; 43, 44; 43, 45; 44, identifier:w0; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:units; 47, attribute; 47, 48; 47, 49; 48, identifier:hamiltonian; 49, identifier:units; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:dt; 53, call; 53, 54; 53, 55; 54, identifier:_autodetermine_initial_dt; 55, argument_list; 55, 56; 55, 57; 55, 58; 55, 61; 56, identifier:w0; 57, identifier:hamiltonian; 58, keyword_argument; 58, 59; 58, 60; 59, identifier:dE_threshold; 60, identifier:dE_threshold; 61, dictionary_splat; 61, 62; 62, identifier:integrate_kwargs; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:n_steps; 66, call; 66, 67; 66, 68; 67, identifier:int; 68, argument_list; 68, 69; 69, call; 69, 70; 69, 71; 70, identifier:round; 71, argument_list; 71, 72; 72, binary_operator:/; 72, 73; 72, 74; 73, integer:10000; 74, identifier:dt; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:orbit; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:hamiltonian; 81, identifier:integrate_orbit; 82, argument_list; 82, 83; 82, 84; 82, 87; 82, 90; 83, identifier:w0; 84, keyword_argument; 84, 85; 84, 86; 85, identifier:dt; 86, identifier:dt; 87, keyword_argument; 87, 88; 87, 89; 88, identifier:n_steps; 89, identifier:n_steps; 90, dictionary_splat; 90, 91; 91, identifier:integrate_kwargs; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:circ; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:orbit; 98, identifier:circulation; 99, argument_list; 100, if_statement; 100, 101; 100, 107; 100, 184; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:np; 104, identifier:any; 105, argument_list; 105, 106; 106, identifier:circ; 107, block; 107, 108; 107, 119; 107, 130; 107, 138; 107, 146; 107, 154; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:orbit; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:orbit; 114, identifier:align_circulation_with_z; 115, argument_list; 115, 116; 116, keyword_argument; 116, 117; 116, 118; 117, identifier:circulation; 118, identifier:circ; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:cyl; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:orbit; 125, identifier:represent_as; 126, argument_list; 126, 127; 127, attribute; 127, 128; 127, 129; 128, identifier:coord; 129, identifier:CylindricalRepresentation; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:R; 133, attribute; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:cyl; 136, identifier:rho; 137, identifier:value; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:phi; 141, attribute; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:cyl; 144, identifier:phi; 145, identifier:value; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:z; 149, attribute; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:cyl; 152, identifier:z; 153, identifier:value; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:T; 157, binary_operator:*; 157, 158; 157, 179; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:np; 161, identifier:array; 162, argument_list; 162, 163; 163, list_comprehension; 163, 164; 163, 173; 164, attribute; 164, 165; 164, 172; 165, call; 165, 166; 165, 167; 166, identifier:peak_to_peak_period; 167, argument_list; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:orbit; 170, identifier:t; 171, identifier:f; 172, identifier:value; 173, for_in_clause; 173, 174; 173, 175; 174, identifier:f; 175, list:[R, phi, z]; 175, 176; 175, 177; 175, 178; 176, identifier:R; 177, identifier:phi; 178, identifier:z; 179, attribute; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:orbit; 182, identifier:t; 183, identifier:unit; 184, else_clause; 184, 185; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:T; 189, binary_operator:*; 189, 190; 189, 210; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:np; 193, identifier:array; 194, argument_list; 194, 195; 195, list_comprehension; 195, 196; 195, 205; 196, attribute; 196, 197; 196, 204; 197, call; 197, 198; 197, 199; 198, identifier:peak_to_peak_period; 199, argument_list; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:orbit; 202, identifier:t; 203, identifier:f; 204, identifier:value; 205, for_in_clause; 205, 206; 205, 207; 206, identifier:f; 207, attribute; 207, 208; 207, 209; 208, identifier:orbit; 209, identifier:pos; 210, attribute; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:orbit; 213, identifier:t; 214, identifier:unit; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:T; 218, call; 218, 219; 218, 220; 219, identifier:func; 220, argument_list; 220, 221; 221, identifier:T; 222, if_statement; 222, 223; 222, 229; 223, call; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:np; 226, identifier:isnan; 227, argument_list; 227, 228; 228, identifier:T; 229, block; 229, 230; 230, raise_statement; 230, 231; 231, call; 231, 232; 231, 233; 232, identifier:RuntimeError; 233, argument_list; 233, 234; 234, string:"Failed to find period."; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:T; 238, attribute; 238, 239; 238, 247; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:T; 242, identifier:decompose; 243, argument_list; 243, 244; 244, attribute; 244, 245; 244, 246; 245, identifier:hamiltonian; 246, identifier:units; 247, identifier:value; 248, expression_statement; 248, 249; 249, assignment; 249, 250; 249, 251; 250, identifier:dt; 251, binary_operator:/; 251, 252; 251, 253; 252, identifier:T; 253, call; 253, 254; 253, 255; 254, identifier:float; 255, argument_list; 255, 256; 256, identifier:n_steps_per_period; 257, expression_statement; 257, 258; 258, assignment; 258, 259; 258, 260; 259, identifier:n_steps; 260, call; 260, 261; 260, 262; 261, identifier:int; 262, argument_list; 262, 263; 263, call; 263, 264; 263, 265; 264, identifier:round; 265, argument_list; 265, 266; 266, binary_operator:/; 266, 267; 266, 270; 267, binary_operator:*; 267, 268; 267, 269; 268, identifier:n_periods; 269, identifier:T; 270, identifier:dt; 271, if_statement; 271, 272; 271, 279; 272, boolean_operator:or; 272, 273; 272, 276; 273, comparison_operator:==; 273, 274; 273, 275; 274, identifier:dt; 275, float:0.; 276, comparison_operator:<; 276, 277; 276, 278; 277, identifier:dt; 278, float:1E-13; 279, block; 279, 280; 280, raise_statement; 280, 281; 281, call; 281, 282; 281, 283; 282, identifier:ValueError; 283, argument_list; 283, 284; 284, string:"Timestep is zero or very small!"; 285, return_statement; 285, 286; 286, expression_list; 286, 287; 286, 288; 287, identifier:dt; 288, identifier:n_steps | def estimate_dt_n_steps(w0, hamiltonian, n_periods, n_steps_per_period,
dE_threshold=1E-9, func=np.nanmax,
**integrate_kwargs):
if not isinstance(w0, PhaseSpacePosition):
w0 = np.asarray(w0)
w0 = PhaseSpacePosition.from_w(w0, units=hamiltonian.units)
dt = _autodetermine_initial_dt(w0, hamiltonian, dE_threshold=dE_threshold,
**integrate_kwargs)
n_steps = int(round(10000 / dt))
orbit = hamiltonian.integrate_orbit(w0, dt=dt, n_steps=n_steps,
**integrate_kwargs)
circ = orbit.circulation()
if np.any(circ):
orbit = orbit.align_circulation_with_z(circulation=circ)
cyl = orbit.represent_as(coord.CylindricalRepresentation)
R = cyl.rho.value
phi = cyl.phi.value
z = cyl.z.value
T = np.array([peak_to_peak_period(orbit.t, f).value
for f in [R, phi, z]])*orbit.t.unit
else:
T = np.array([peak_to_peak_period(orbit.t, f).value
for f in orbit.pos])*orbit.t.unit
T = func(T)
if np.isnan(T):
raise RuntimeError("Failed to find period.")
T = T.decompose(hamiltonian.units).value
dt = T / float(n_steps_per_period)
n_steps = int(round(n_periods * T / dt))
if dt == 0. or dt < 1E-13:
raise ValueError("Timestep is zero or very small!")
return dt, n_steps |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:plot_projections; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 19; 3, 22; 3, 25; 4, identifier:x; 5, default_parameter; 5, 6; 5, 7; 6, identifier:relative_to; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:autolim; 10, True; 11, default_parameter; 11, 12; 11, 13; 12, identifier:axes; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:subplots_kwargs; 16, call; 16, 17; 16, 18; 17, identifier:dict; 18, argument_list; 19, default_parameter; 19, 20; 19, 21; 20, identifier:labels; 21, None; 22, default_parameter; 22, 23; 22, 24; 23, identifier:plot_function; 24, None; 25, dictionary_splat_pattern; 25, 26; 26, identifier:kwargs; 27, block; 27, 28; 27, 40; 27, 48; 27, 65; 27, 74; 27, 80; 27, 148; 27, 152; 27, 250; 27, 260; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:x; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:np; 34, identifier:array; 35, argument_list; 35, 36; 35, 37; 36, identifier:x; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:copy; 39, True; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:ndim; 43, subscript; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:x; 46, identifier:shape; 47, integer:0; 48, if_statement; 48, 49; 48, 52; 49, comparison_operator:is; 49, 50; 49, 51; 50, identifier:axes; 51, None; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:axes; 56, call; 56, 57; 56, 58; 57, identifier:_get_axes; 58, argument_list; 58, 59; 58, 62; 59, keyword_argument; 59, 60; 59, 61; 60, identifier:dim; 61, identifier:ndim; 62, keyword_argument; 62, 63; 62, 64; 63, identifier:subplots_kwargs; 64, identifier:subplots_kwargs; 65, if_statement; 65, 66; 65, 69; 66, comparison_operator:is; 66, 67; 66, 68; 67, identifier:relative_to; 68, None; 69, block; 69, 70; 70, expression_statement; 70, 71; 71, augmented_assignment:-=; 71, 72; 71, 73; 72, identifier:x; 73, identifier:relative_to; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:plot_fn_name; 77, attribute; 77, 78; 77, 79; 78, identifier:plot_function; 79, identifier:__name__; 80, if_statement; 80, 81; 80, 82; 81, identifier:autolim; 82, block; 82, 83; 82, 87; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:lims; 86, list:[]; 87, for_statement; 87, 88; 87, 89; 87, 93; 88, identifier:i; 89, call; 89, 90; 89, 91; 90, identifier:range; 91, argument_list; 91, 92; 92, identifier:ndim; 93, block; 93, 94; 93, 116; 93, 122; 93, 131; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 99; 96, pattern_list; 96, 97; 96, 98; 97, identifier:max_; 98, identifier:min_; 99, expression_list; 99, 100; 99, 108; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:np; 103, identifier:max; 104, argument_list; 104, 105; 105, subscript; 105, 106; 105, 107; 106, identifier:x; 107, identifier:i; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:np; 111, identifier:min; 112, argument_list; 112, 113; 113, subscript; 113, 114; 113, 115; 114, identifier:x; 115, identifier:i; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:delta; 119, binary_operator:-; 119, 120; 119, 121; 120, identifier:max_; 121, identifier:min_; 122, if_statement; 122, 123; 122, 126; 123, comparison_operator:==; 123, 124; 123, 125; 124, identifier:delta; 125, float:0.; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:delta; 130, float:1.; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:lims; 135, identifier:append; 136, argument_list; 136, 137; 137, list:[min_ - delta*0.02, max_ + delta*0.02]; 137, 138; 137, 143; 138, binary_operator:-; 138, 139; 138, 140; 139, identifier:min_; 140, binary_operator:*; 140, 141; 140, 142; 141, identifier:delta; 142, float:0.02; 143, binary_operator:+; 143, 144; 143, 145; 144, identifier:max_; 145, binary_operator:*; 145, 146; 145, 147; 146, identifier:delta; 147, float:0.02; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:k; 151, integer:0; 152, for_statement; 152, 153; 152, 154; 152, 158; 153, identifier:i; 154, call; 154, 155; 154, 156; 155, identifier:range; 156, argument_list; 156, 157; 157, identifier:ndim; 158, block; 158, 159; 159, for_statement; 159, 160; 159, 161; 159, 165; 160, identifier:j; 161, call; 161, 162; 161, 163; 162, identifier:range; 163, argument_list; 163, 164; 164, identifier:ndim; 165, block; 165, 166; 165, 172; 165, 182; 165, 194; 165, 221; 165, 246; 166, if_statement; 166, 167; 166, 170; 167, comparison_operator:>=; 167, 168; 167, 169; 168, identifier:i; 169, identifier:j; 170, block; 170, 171; 171, continue_statement; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:plot_func; 175, call; 175, 176; 175, 177; 176, identifier:getattr; 177, argument_list; 177, 178; 177, 181; 178, subscript; 178, 179; 178, 180; 179, identifier:axes; 180, identifier:k; 181, identifier:plot_fn_name; 182, expression_statement; 182, 183; 183, call; 183, 184; 183, 185; 184, identifier:plot_func; 185, argument_list; 185, 186; 185, 189; 185, 192; 186, subscript; 186, 187; 186, 188; 187, identifier:x; 188, identifier:i; 189, subscript; 189, 190; 189, 191; 190, identifier:x; 191, identifier:j; 192, dictionary_splat; 192, 193; 193, identifier:kwargs; 194, if_statement; 194, 195; 194, 198; 195, comparison_operator:is; 195, 196; 195, 197; 196, identifier:labels; 197, None; 198, block; 198, 199; 198, 210; 199, expression_statement; 199, 200; 200, call; 200, 201; 200, 206; 201, attribute; 201, 202; 201, 205; 202, subscript; 202, 203; 202, 204; 203, identifier:axes; 204, identifier:k; 205, identifier:set_xlabel; 206, argument_list; 206, 207; 207, subscript; 207, 208; 207, 209; 208, identifier:labels; 209, identifier:i; 210, expression_statement; 210, 211; 211, call; 211, 212; 211, 217; 212, attribute; 212, 213; 212, 216; 213, subscript; 213, 214; 213, 215; 214, identifier:axes; 215, identifier:k; 216, identifier:set_ylabel; 217, argument_list; 217, 218; 218, subscript; 218, 219; 218, 220; 219, identifier:labels; 220, identifier:j; 221, if_statement; 221, 222; 221, 223; 222, identifier:autolim; 223, block; 223, 224; 223, 235; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 231; 226, attribute; 226, 227; 226, 230; 227, subscript; 227, 228; 227, 229; 228, identifier:axes; 229, identifier:k; 230, identifier:set_xlim; 231, argument_list; 231, 232; 232, subscript; 232, 233; 232, 234; 233, identifier:lims; 234, identifier:i; 235, expression_statement; 235, 236; 236, call; 236, 237; 236, 242; 237, attribute; 237, 238; 237, 241; 238, subscript; 238, 239; 238, 240; 239, identifier:axes; 240, identifier:k; 241, identifier:set_ylim; 242, argument_list; 242, 243; 243, subscript; 243, 244; 243, 245; 244, identifier:lims; 245, identifier:j; 246, expression_statement; 246, 247; 247, augmented_assignment:+=; 247, 248; 247, 249; 248, identifier:k; 249, integer:1; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 259; 252, attribute; 252, 253; 252, 258; 253, attribute; 253, 254; 253, 257; 254, subscript; 254, 255; 254, 256; 255, identifier:axes; 256, integer:0; 257, identifier:figure; 258, identifier:tight_layout; 259, argument_list; 260, return_statement; 260, 261; 261, attribute; 261, 262; 261, 265; 262, subscript; 262, 263; 262, 264; 263, identifier:axes; 264, integer:0; 265, identifier:figure | def plot_projections(x, relative_to=None, autolim=True, axes=None,
subplots_kwargs=dict(), labels=None, plot_function=None,
**kwargs):
x = np.array(x, copy=True)
ndim = x.shape[0]
if axes is None:
axes = _get_axes(dim=ndim, subplots_kwargs=subplots_kwargs)
if relative_to is not None:
x -= relative_to
plot_fn_name = plot_function.__name__
if autolim:
lims = []
for i in range(ndim):
max_,min_ = np.max(x[i]), np.min(x[i])
delta = max_ - min_
if delta == 0.:
delta = 1.
lims.append([min_ - delta*0.02, max_ + delta*0.02])
k = 0
for i in range(ndim):
for j in range(ndim):
if i >= j:
continue
plot_func = getattr(axes[k], plot_fn_name)
plot_func(x[i], x[j], **kwargs)
if labels is not None:
axes[k].set_xlabel(labels[i])
axes[k].set_ylabel(labels[j])
if autolim:
axes[k].set_xlim(lims[i])
axes[k].set_ylim(lims[j])
k += 1
axes[0].figure.tight_layout()
return axes[0].figure |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:compute_coeffs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:density_func; 5, identifier:nmax; 6, identifier:lmax; 7, identifier:M; 8, identifier:r_s; 9, default_parameter; 9, 10; 9, 11; 10, identifier:args; 11, tuple; 12, default_parameter; 12, 13; 12, 14; 13, identifier:skip_odd; 14, False; 15, default_parameter; 15, 16; 15, 17; 16, identifier:skip_even; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:skip_m; 20, False; 21, default_parameter; 21, 22; 21, 23; 22, identifier:S_only; 23, False; 24, default_parameter; 24, 25; 24, 26; 25, identifier:progress; 26, False; 27, dictionary_splat_pattern; 27, 28; 28, identifier:nquad_opts; 29, block; 29, 30; 29, 36; 29, 49; 29, 53; 29, 57; 29, 66; 29, 73; 29, 91; 29, 109; 29, 127; 29, 145; 29, 153; 29, 161; 29, 180; 29, 184; 29, 231; 29, 272; 29, 356; 30, import_from_statement; 30, 31; 30, 34; 31, dotted_name; 31, 32; 31, 33; 32, identifier:gala; 33, identifier:_cconfig; 34, dotted_name; 34, 35; 35, identifier:GSL_ENABLED; 36, if_statement; 36, 37; 36, 39; 37, not_operator; 37, 38; 38, identifier:GSL_ENABLED; 39, block; 39, 40; 40, raise_statement; 40, 41; 41, call; 41, 42; 41, 43; 42, identifier:ValueError; 43, argument_list; 43, 44; 44, concatenated_string; 44, 45; 44, 46; 44, 47; 44, 48; 45, string:"Gala was compiled without GSL and so this function "; 46, string:"will not work. See the gala documentation for more "; 47, string:"information about installing and using GSL with "; 48, string:"gala: http://gala.adrian.pw/en/latest/install.html"; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:lmin; 52, integer:0; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:lstride; 56, integer:1; 57, if_statement; 57, 58; 57, 61; 58, boolean_operator:or; 58, 59; 58, 60; 59, identifier:skip_odd; 60, identifier:skip_even; 61, block; 61, 62; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:lstride; 65, integer:2; 66, if_statement; 66, 67; 66, 68; 67, identifier:skip_even; 68, block; 68, 69; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:lmin; 72, integer:1; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:Snlm; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:np; 79, identifier:zeros; 80, argument_list; 80, 81; 81, tuple; 81, 82; 81, 85; 81, 88; 82, binary_operator:+; 82, 83; 82, 84; 83, identifier:nmax; 84, integer:1; 85, binary_operator:+; 85, 86; 85, 87; 86, identifier:lmax; 87, integer:1; 88, binary_operator:+; 88, 89; 88, 90; 89, identifier:lmax; 90, integer:1; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:Snlm_e; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:np; 97, identifier:zeros; 98, argument_list; 98, 99; 99, tuple; 99, 100; 99, 103; 99, 106; 100, binary_operator:+; 100, 101; 100, 102; 101, identifier:nmax; 102, integer:1; 103, binary_operator:+; 103, 104; 103, 105; 104, identifier:lmax; 105, integer:1; 106, binary_operator:+; 106, 107; 106, 108; 107, identifier:lmax; 108, integer:1; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:Tnlm; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:np; 115, identifier:zeros; 116, argument_list; 116, 117; 117, tuple; 117, 118; 117, 121; 117, 124; 118, binary_operator:+; 118, 119; 118, 120; 119, identifier:nmax; 120, integer:1; 121, binary_operator:+; 121, 122; 121, 123; 122, identifier:lmax; 123, integer:1; 124, binary_operator:+; 124, 125; 124, 126; 125, identifier:lmax; 126, integer:1; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:Tnlm_e; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:np; 133, identifier:zeros; 134, argument_list; 134, 135; 135, tuple; 135, 136; 135, 139; 135, 142; 136, binary_operator:+; 136, 137; 136, 138; 137, identifier:nmax; 138, integer:1; 139, binary_operator:+; 139, 140; 139, 141; 140, identifier:lmax; 141, integer:1; 142, binary_operator:+; 142, 143; 142, 144; 143, identifier:lmax; 144, integer:1; 145, expression_statement; 145, 146; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:nquad_opts; 149, identifier:setdefault; 150, argument_list; 150, 151; 150, 152; 151, string:'limit'; 152, integer:256; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:nquad_opts; 157, identifier:setdefault; 158, argument_list; 158, 159; 158, 160; 159, string:'epsrel'; 160, float:1E-10; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:limits; 164, list:[[0, 2*np.pi],
[-1, 1.],
[-1, 1.]]; 164, 165; 164, 172; 164, 176; 165, list:[0, 2*np.pi]; 165, 166; 165, 167; 166, integer:0; 167, binary_operator:*; 167, 168; 167, 169; 168, integer:2; 169, attribute; 169, 170; 169, 171; 170, identifier:np; 171, identifier:pi; 172, list:[-1, 1.]; 172, 173; 172, 175; 173, unary_operator:-; 173, 174; 174, integer:1; 175, float:1.; 176, list:[-1, 1.]; 176, 177; 176, 179; 177, unary_operator:-; 177, 178; 178, integer:1; 179, float:1.; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:nlms; 183, list:[]; 184, for_statement; 184, 185; 184, 186; 184, 192; 185, identifier:n; 186, call; 186, 187; 186, 188; 187, identifier:range; 188, argument_list; 188, 189; 189, binary_operator:+; 189, 190; 189, 191; 190, identifier:nmax; 191, integer:1; 192, block; 192, 193; 193, for_statement; 193, 194; 193, 195; 193, 203; 194, identifier:l; 195, call; 195, 196; 195, 197; 196, identifier:range; 197, argument_list; 197, 198; 197, 199; 197, 202; 198, identifier:lmin; 199, binary_operator:+; 199, 200; 199, 201; 200, identifier:lmax; 201, integer:1; 202, identifier:lstride; 203, block; 203, 204; 204, for_statement; 204, 205; 204, 206; 204, 212; 205, identifier:m; 206, call; 206, 207; 206, 208; 207, identifier:range; 208, argument_list; 208, 209; 209, binary_operator:+; 209, 210; 209, 211; 210, identifier:l; 211, integer:1; 212, block; 212, 213; 212, 221; 213, if_statement; 213, 214; 213, 219; 214, boolean_operator:and; 214, 215; 214, 216; 215, identifier:skip_m; 216, comparison_operator:>; 216, 217; 216, 218; 217, identifier:m; 218, integer:0; 219, block; 219, 220; 220, continue_statement; 221, expression_statement; 221, 222; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:nlms; 225, identifier:append; 226, argument_list; 226, 227; 227, tuple; 227, 228; 227, 229; 227, 230; 228, identifier:n; 229, identifier:l; 230, identifier:m; 231, if_statement; 231, 232; 231, 233; 231, 263; 232, identifier:progress; 233, block; 233, 234; 233, 259; 234, try_statement; 234, 235; 234, 241; 235, block; 235, 236; 236, import_from_statement; 236, 237; 236, 239; 237, dotted_name; 237, 238; 238, identifier:tqdm; 239, dotted_name; 239, 240; 240, identifier:tqdm; 241, except_clause; 241, 242; 241, 246; 242, as_pattern; 242, 243; 242, 244; 243, identifier:ImportError; 244, as_pattern_target; 244, 245; 245, identifier:e; 246, block; 246, 247; 247, raise_statement; 247, 248; 248, call; 248, 249; 248, 250; 249, identifier:ImportError; 250, argument_list; 250, 251; 251, binary_operator:+; 251, 252; 251, 255; 252, concatenated_string; 252, 253; 252, 254; 253, string:'tqdm is not installed - you can install it '; 254, string:'with `pip install tqdm`.\n'; 255, call; 255, 256; 255, 257; 256, identifier:str; 257, argument_list; 257, 258; 258, identifier:e; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 262; 261, identifier:iterfunc; 262, identifier:tqdm; 263, else_clause; 263, 264; 264, block; 264, 265; 265, expression_statement; 265, 266; 266, assignment; 266, 267; 266, 268; 267, identifier:iterfunc; 268, lambda; 268, 269; 268, 271; 269, lambda_parameters; 269, 270; 270, identifier:x; 271, identifier:x; 272, for_statement; 272, 273; 272, 277; 272, 281; 273, pattern_list; 273, 274; 273, 275; 273, 276; 274, identifier:n; 275, identifier:l; 276, identifier:m; 277, call; 277, 278; 277, 279; 278, identifier:iterfunc; 279, argument_list; 279, 280; 280, identifier:nlms; 281, block; 281, 282; 281, 317; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 295; 284, pattern_list; 284, 285; 284, 290; 285, subscript; 285, 286; 285, 287; 285, 288; 285, 289; 286, identifier:Snlm; 287, identifier:n; 288, identifier:l; 289, identifier:m; 290, subscript; 290, 291; 290, 292; 290, 293; 290, 294; 291, identifier:Snlm_e; 292, identifier:n; 293, identifier:l; 294, identifier:m; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:si; 298, identifier:nquad; 299, argument_list; 299, 300; 299, 301; 299, 304; 299, 314; 300, identifier:Snlm_integrand; 301, keyword_argument; 301, 302; 301, 303; 302, identifier:ranges; 303, identifier:limits; 304, keyword_argument; 304, 305; 304, 306; 305, identifier:args; 306, tuple; 306, 307; 306, 308; 306, 309; 306, 310; 306, 311; 306, 312; 306, 313; 307, identifier:density_func; 308, identifier:n; 309, identifier:l; 310, identifier:m; 311, identifier:M; 312, identifier:r_s; 313, identifier:args; 314, keyword_argument; 314, 315; 314, 316; 315, identifier:opts; 316, identifier:nquad_opts; 317, if_statement; 317, 318; 317, 320; 318, not_operator; 318, 319; 319, identifier:S_only; 320, block; 320, 321; 321, expression_statement; 321, 322; 322, assignment; 322, 323; 322, 334; 323, pattern_list; 323, 324; 323, 329; 324, subscript; 324, 325; 324, 326; 324, 327; 324, 328; 325, identifier:Tnlm; 326, identifier:n; 327, identifier:l; 328, identifier:m; 329, subscript; 329, 330; 329, 331; 329, 332; 329, 333; 330, identifier:Tnlm_e; 331, identifier:n; 332, identifier:l; 333, identifier:m; 334, call; 334, 335; 334, 338; 335, attribute; 335, 336; 335, 337; 336, identifier:si; 337, identifier:nquad; 338, argument_list; 338, 339; 338, 340; 338, 343; 338, 353; 339, identifier:Tnlm_integrand; 340, keyword_argument; 340, 341; 340, 342; 341, identifier:ranges; 342, identifier:limits; 343, keyword_argument; 343, 344; 343, 345; 344, identifier:args; 345, tuple; 345, 346; 345, 347; 345, 348; 345, 349; 345, 350; 345, 351; 345, 352; 346, identifier:density_func; 347, identifier:n; 348, identifier:l; 349, identifier:m; 350, identifier:M; 351, identifier:r_s; 352, identifier:args; 353, keyword_argument; 353, 354; 353, 355; 354, identifier:opts; 355, identifier:nquad_opts; 356, return_statement; 356, 357; 357, expression_list; 357, 358; 357, 361; 358, tuple; 358, 359; 358, 360; 359, identifier:Snlm; 360, identifier:Snlm_e; 361, tuple; 361, 362; 361, 363; 362, identifier:Tnlm; 363, identifier:Tnlm_e | def compute_coeffs(density_func, nmax, lmax, M, r_s, args=(),
skip_odd=False, skip_even=False, skip_m=False,
S_only=False, progress=False, **nquad_opts):
from gala._cconfig import GSL_ENABLED
if not GSL_ENABLED:
raise ValueError("Gala was compiled without GSL and so this function "
"will not work. See the gala documentation for more "
"information about installing and using GSL with "
"gala: http://gala.adrian.pw/en/latest/install.html")
lmin = 0
lstride = 1
if skip_odd or skip_even:
lstride = 2
if skip_even:
lmin = 1
Snlm = np.zeros((nmax+1, lmax+1, lmax+1))
Snlm_e = np.zeros((nmax+1, lmax+1, lmax+1))
Tnlm = np.zeros((nmax+1, lmax+1, lmax+1))
Tnlm_e = np.zeros((nmax+1, lmax+1, lmax+1))
nquad_opts.setdefault('limit', 256)
nquad_opts.setdefault('epsrel', 1E-10)
limits = [[0, 2*np.pi],
[-1, 1.],
[-1, 1.]]
nlms = []
for n in range(nmax+1):
for l in range(lmin, lmax+1, lstride):
for m in range(l+1):
if skip_m and m > 0:
continue
nlms.append((n, l, m))
if progress:
try:
from tqdm import tqdm
except ImportError as e:
raise ImportError('tqdm is not installed - you can install it '
'with `pip install tqdm`.\n' + str(e))
iterfunc = tqdm
else:
iterfunc = lambda x: x
for n, l, m in iterfunc(nlms):
Snlm[n, l, m], Snlm_e[n, l, m] = si.nquad(
Snlm_integrand, ranges=limits,
args=(density_func, n, l, m, M, r_s, args),
opts=nquad_opts)
if not S_only:
Tnlm[n, l, m], Tnlm_e[n, l, m] = si.nquad(
Tnlm_integrand, ranges=limits,
args=(density_func, n, l, m, M, r_s, args),
opts=nquad_opts)
return (Snlm, Snlm_e), (Tnlm, Tnlm_e) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:compute_coeffs_discrete; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:xyz; 5, identifier:mass; 6, identifier:nmax; 7, identifier:lmax; 8, identifier:r_s; 9, default_parameter; 9, 10; 9, 11; 10, identifier:skip_odd; 11, False; 12, default_parameter; 12, 13; 12, 14; 13, identifier:skip_even; 14, False; 15, default_parameter; 15, 16; 15, 17; 16, identifier:skip_m; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:compute_var; 20, False; 21, block; 21, 22; 21, 26; 21, 30; 21, 39; 21, 46; 21, 64; 21, 82; 21, 121; 21, 135; 21, 149; 21, 169; 21, 175; 21, 193; 21, 203; 21, 289; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:lmin; 25, integer:0; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:lstride; 29, integer:1; 30, if_statement; 30, 31; 30, 34; 31, boolean_operator:or; 31, 32; 31, 33; 32, identifier:skip_odd; 33, identifier:skip_even; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:lstride; 38, integer:2; 39, if_statement; 39, 40; 39, 41; 40, identifier:skip_even; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:lmin; 45, integer:1; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:Snlm; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:np; 52, identifier:zeros; 53, argument_list; 53, 54; 54, tuple; 54, 55; 54, 58; 54, 61; 55, binary_operator:+; 55, 56; 55, 57; 56, identifier:nmax; 57, integer:1; 58, binary_operator:+; 58, 59; 58, 60; 59, identifier:lmax; 60, integer:1; 61, binary_operator:+; 61, 62; 61, 63; 62, identifier:lmax; 63, integer:1; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:Tnlm; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:np; 70, identifier:zeros; 71, argument_list; 71, 72; 72, tuple; 72, 73; 72, 76; 72, 79; 73, binary_operator:+; 73, 74; 73, 75; 74, identifier:nmax; 75, integer:1; 76, binary_operator:+; 76, 77; 76, 78; 77, identifier:lmax; 78, integer:1; 79, binary_operator:+; 79, 80; 79, 81; 80, identifier:lmax; 81, integer:1; 82, if_statement; 82, 83; 82, 84; 83, identifier:compute_var; 84, block; 84, 85; 84, 103; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:Snlm_var; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:np; 91, identifier:zeros; 92, argument_list; 92, 93; 93, tuple; 93, 94; 93, 97; 93, 100; 94, binary_operator:+; 94, 95; 94, 96; 95, identifier:nmax; 96, integer:1; 97, binary_operator:+; 97, 98; 97, 99; 98, identifier:lmax; 99, integer:1; 100, binary_operator:+; 100, 101; 100, 102; 101, identifier:lmax; 102, integer:1; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:Tnlm_var; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:np; 109, identifier:zeros; 110, argument_list; 110, 111; 111, tuple; 111, 112; 111, 115; 111, 118; 112, binary_operator:+; 112, 113; 112, 114; 113, identifier:nmax; 114, integer:1; 115, binary_operator:+; 115, 116; 115, 117; 116, identifier:lmax; 117, integer:1; 118, binary_operator:+; 118, 119; 118, 120; 119, identifier:lmax; 120, integer:1; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:xyz; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:np; 127, identifier:ascontiguousarray; 128, argument_list; 128, 129; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:np; 132, identifier:atleast_2d; 133, argument_list; 133, 134; 134, identifier:xyz; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:mass; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:np; 141, identifier:ascontiguousarray; 142, argument_list; 142, 143; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:np; 146, identifier:atleast_1d; 147, argument_list; 147, 148; 148, identifier:mass; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:r; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:np; 155, identifier:sqrt; 156, argument_list; 156, 157; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:np; 160, identifier:sum; 161, argument_list; 161, 162; 161, 165; 162, binary_operator:**; 162, 163; 162, 164; 163, identifier:xyz; 164, integer:2; 165, keyword_argument; 165, 166; 165, 167; 166, identifier:axis; 167, unary_operator:-; 167, 168; 168, integer:1; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:s; 172, binary_operator:/; 172, 173; 172, 174; 173, identifier:r; 174, identifier:r_s; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:phi; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:np; 181, identifier:arctan2; 182, argument_list; 182, 183; 182, 188; 183, subscript; 183, 184; 183, 185; 183, 187; 184, identifier:xyz; 185, slice; 185, 186; 186, colon; 187, integer:1; 188, subscript; 188, 189; 188, 190; 188, 192; 189, identifier:xyz; 190, slice; 190, 191; 191, colon; 192, integer:0; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 196; 195, identifier:X; 196, binary_operator:/; 196, 197; 196, 202; 197, subscript; 197, 198; 197, 199; 197, 201; 198, identifier:xyz; 199, slice; 199, 200; 200, colon; 201, integer:2; 202, identifier:r; 203, for_statement; 203, 204; 203, 205; 203, 211; 204, identifier:n; 205, call; 205, 206; 205, 207; 206, identifier:range; 207, argument_list; 207, 208; 208, binary_operator:+; 208, 209; 208, 210; 209, identifier:nmax; 210, integer:1; 211, block; 211, 212; 212, for_statement; 212, 213; 212, 214; 212, 222; 213, identifier:l; 214, call; 214, 215; 214, 216; 215, identifier:range; 216, argument_list; 216, 217; 216, 218; 216, 221; 217, identifier:lmin; 218, binary_operator:+; 218, 219; 218, 220; 219, identifier:lmax; 220, integer:1; 221, identifier:lstride; 222, block; 222, 223; 223, for_statement; 223, 224; 223, 225; 223, 231; 224, identifier:m; 225, call; 225, 226; 225, 227; 226, identifier:range; 227, argument_list; 227, 228; 228, binary_operator:+; 228, 229; 228, 230; 229, identifier:l; 230, integer:1; 231, block; 231, 232; 231, 240; 231, 263; 232, if_statement; 232, 233; 232, 238; 233, boolean_operator:and; 233, 234; 233, 235; 234, identifier:skip_m; 235, comparison_operator:>; 235, 236; 235, 237; 236, identifier:m; 237, integer:0; 238, block; 238, 239; 239, continue_statement; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 253; 242, pattern_list; 242, 243; 242, 248; 243, subscript; 243, 244; 243, 245; 243, 246; 243, 247; 244, identifier:Snlm; 245, identifier:n; 246, identifier:l; 247, identifier:m; 248, subscript; 248, 249; 248, 250; 248, 251; 248, 252; 249, identifier:Tnlm; 250, identifier:n; 251, identifier:l; 252, identifier:m; 253, call; 253, 254; 253, 255; 254, identifier:STnlm_discrete; 255, argument_list; 255, 256; 255, 257; 255, 258; 255, 259; 255, 260; 255, 261; 255, 262; 256, identifier:s; 257, identifier:phi; 258, identifier:X; 259, identifier:mass; 260, identifier:n; 261, identifier:l; 262, identifier:m; 263, if_statement; 263, 264; 263, 265; 264, identifier:compute_var; 265, block; 265, 266; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 279; 268, pattern_list; 268, 269; 268, 274; 269, subscript; 269, 270; 269, 271; 269, 272; 269, 273; 270, identifier:Snlm_var; 271, identifier:n; 272, identifier:l; 273, identifier:m; 274, subscript; 274, 275; 274, 276; 274, 277; 274, 278; 275, identifier:Tnlm_var; 276, identifier:n; 277, identifier:l; 278, identifier:m; 279, call; 279, 280; 279, 281; 280, identifier:STnlm_var_discrete; 281, argument_list; 281, 282; 281, 283; 281, 284; 281, 285; 281, 286; 281, 287; 281, 288; 282, identifier:s; 283, identifier:phi; 284, identifier:X; 285, identifier:mass; 286, identifier:n; 287, identifier:l; 288, identifier:m; 289, if_statement; 289, 290; 289, 291; 289, 300; 290, identifier:compute_var; 291, block; 291, 292; 292, return_statement; 292, 293; 293, expression_list; 293, 294; 293, 297; 294, tuple; 294, 295; 294, 296; 295, identifier:Snlm; 296, identifier:Snlm_var; 297, tuple; 297, 298; 297, 299; 298, identifier:Tnlm; 299, identifier:Tnlm_var; 300, else_clause; 300, 301; 301, block; 301, 302; 302, return_statement; 302, 303; 303, expression_list; 303, 304; 303, 305; 304, identifier:Snlm; 305, identifier:Tnlm | def compute_coeffs_discrete(xyz, mass, nmax, lmax, r_s,
skip_odd=False, skip_even=False, skip_m=False,
compute_var=False):
lmin = 0
lstride = 1
if skip_odd or skip_even:
lstride = 2
if skip_even:
lmin = 1
Snlm = np.zeros((nmax+1, lmax+1, lmax+1))
Tnlm = np.zeros((nmax+1, lmax+1, lmax+1))
if compute_var:
Snlm_var = np.zeros((nmax+1, lmax+1, lmax+1))
Tnlm_var = np.zeros((nmax+1, lmax+1, lmax+1))
xyz = np.ascontiguousarray(np.atleast_2d(xyz))
mass = np.ascontiguousarray(np.atleast_1d(mass))
r = np.sqrt(np.sum(xyz**2, axis=-1))
s = r / r_s
phi = np.arctan2(xyz[:,1], xyz[:,0])
X = xyz[:,2] / r
for n in range(nmax+1):
for l in range(lmin, lmax+1, lstride):
for m in range(l+1):
if skip_m and m > 0: continue
Snlm[n,l,m], Tnlm[n,l,m] = STnlm_discrete(s, phi, X, mass, n, l, m)
if compute_var:
Snlm_var[n,l,m], Tnlm_var[n,l,m] = STnlm_var_discrete(s, phi, X, mass, n, l, m)
if compute_var:
return (Snlm,Snlm_var), (Tnlm,Tnlm_var)
else:
return Snlm, Tnlm |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:to_coord_frame; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:frame; 6, default_parameter; 6, 7; 6, 8; 7, identifier:galactocentric_frame; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, 12; 11, 26; 11, 39; 11, 62; 11, 75; 11, 88; 11, 128; 11, 146; 11, 155; 12, if_statement; 12, 13; 12, 18; 13, comparison_operator:!=; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:ndim; 17, integer:3; 18, block; 18, 19; 19, raise_statement; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:ValueError; 22, argument_list; 22, 23; 23, concatenated_string; 23, 24; 23, 25; 24, string:"Can only change representation for "; 25, string:"ndim=3 instances."; 26, if_statement; 26, 27; 26, 30; 27, comparison_operator:is; 27, 28; 27, 29; 28, identifier:galactocentric_frame; 29, None; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:galactocentric_frame; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:coord; 37, identifier:Galactocentric; 38, argument_list; 39, if_statement; 39, 40; 39, 47; 40, boolean_operator:or; 40, 41; 40, 44; 41, comparison_operator:in; 41, 42; 41, 43; 42, string:'vcirc'; 43, identifier:kwargs; 44, comparison_operator:in; 44, 45; 44, 46; 45, string:'vlsr'; 46, identifier:kwargs; 47, block; 47, 48; 47, 51; 48, import_statement; 48, 49; 49, dotted_name; 49, 50; 50, identifier:warnings; 51, expression_statement; 51, 52; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:warnings; 55, identifier:warn; 56, argument_list; 56, 57; 56, 61; 57, concatenated_string; 57, 58; 57, 59; 57, 60; 58, string:"Instead of passing in 'vcirc' and 'vlsr', specify "; 59, string:"these parameters to the input Galactocentric frame "; 60, string:"using the `galcen_v_sun` argument."; 61, identifier:DeprecationWarning; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:pos_keys; 65, call; 65, 66; 65, 67; 66, identifier:list; 67, argument_list; 67, 68; 68, call; 68, 69; 68, 74; 69, attribute; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:pos_components; 73, identifier:keys; 74, argument_list; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:vel_keys; 78, call; 78, 79; 78, 80; 79, identifier:list; 80, argument_list; 80, 81; 81, call; 81, 82; 81, 87; 82, attribute; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:self; 85, identifier:vel_components; 86, identifier:keys; 87, argument_list; 88, if_statement; 88, 89; 88, 117; 89, parenthesized_expression; 89, 90; 90, boolean_operator:or; 90, 91; 90, 104; 91, comparison_operator:==; 91, 92; 91, 101; 92, attribute; 92, 93; 92, 100; 93, call; 93, 94; 93, 95; 94, identifier:getattr; 95, argument_list; 95, 96; 95, 97; 96, identifier:self; 97, subscript; 97, 98; 97, 99; 98, identifier:pos_keys; 99, integer:0; 100, identifier:unit; 101, attribute; 101, 102; 101, 103; 102, identifier:u; 103, identifier:one; 104, comparison_operator:==; 104, 105; 104, 114; 105, attribute; 105, 106; 105, 113; 106, call; 106, 107; 106, 108; 107, identifier:getattr; 108, argument_list; 108, 109; 108, 110; 109, identifier:self; 110, subscript; 110, 111; 110, 112; 111, identifier:vel_keys; 112, integer:0; 113, identifier:unit; 114, attribute; 114, 115; 114, 116; 115, identifier:u; 116, identifier:one; 117, block; 117, 118; 118, raise_statement; 118, 119; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:u; 122, identifier:UnitConversionError; 123, argument_list; 123, 124; 124, concatenated_string; 124, 125; 124, 126; 124, 127; 125, string:"Position and velocity must have "; 126, string:"dimensioned units to convert to a "; 127, string:"coordinate frame."; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:gc_c; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:galactocentric_frame; 134, identifier:realize_frame; 135, argument_list; 135, 136; 136, call; 136, 137; 136, 142; 137, attribute; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:self; 140, identifier:pos; 141, identifier:with_differentials; 142, argument_list; 142, 143; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:vel; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:c; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:gc_c; 152, identifier:transform_to; 153, argument_list; 153, 154; 154, identifier:frame; 155, return_statement; 155, 156; 156, identifier:c | def to_coord_frame(self, frame, galactocentric_frame=None, **kwargs):
if self.ndim != 3:
raise ValueError("Can only change representation for "
"ndim=3 instances.")
if galactocentric_frame is None:
galactocentric_frame = coord.Galactocentric()
if 'vcirc' in kwargs or 'vlsr' in kwargs:
import warnings
warnings.warn("Instead of passing in 'vcirc' and 'vlsr', specify "
"these parameters to the input Galactocentric frame "
"using the `galcen_v_sun` argument.",
DeprecationWarning)
pos_keys = list(self.pos_components.keys())
vel_keys = list(self.vel_components.keys())
if (getattr(self, pos_keys[0]).unit == u.one or
getattr(self, vel_keys[0]).unit == u.one):
raise u.UnitConversionError("Position and velocity must have "
"dimensioned units to convert to a "
"coordinate frame.")
gc_c = galactocentric_frame.realize_frame(
self.pos.with_differentials(self.vel))
c = gc_c.transform_to(frame)
return c |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_plot_prepare; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:components; 6, identifier:units; 7, block; 7, 8; 7, 21; 7, 28; 7, 64; 7, 68; 7, 72; 7, 229; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:components; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:components; 16, attribute; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:pos; 20, identifier:components; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:n_comps; 24, call; 24, 25; 24, 26; 25, identifier:len; 26, argument_list; 26, 27; 27, identifier:components; 28, if_statement; 28, 29; 28, 32; 29, comparison_operator:is; 29, 30; 29, 31; 30, identifier:units; 31, None; 32, block; 32, 33; 33, if_statement; 33, 34; 33, 41; 33, 49; 34, call; 34, 35; 34, 36; 35, identifier:isinstance; 36, argument_list; 36, 37; 36, 38; 37, identifier:units; 38, attribute; 38, 39; 38, 40; 39, identifier:u; 40, identifier:UnitBase; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:units; 45, binary_operator:*; 45, 46; 45, 48; 46, list:[units]; 46, 47; 47, identifier:units; 48, identifier:n_comps; 49, elif_clause; 49, 50; 49, 56; 50, comparison_operator:!=; 50, 51; 50, 55; 51, call; 51, 52; 51, 53; 52, identifier:len; 53, argument_list; 53, 54; 54, identifier:units; 55, identifier:n_comps; 56, block; 56, 57; 57, raise_statement; 57, 58; 58, call; 58, 59; 58, 60; 59, identifier:ValueError; 60, argument_list; 60, 61; 61, concatenated_string; 61, 62; 61, 63; 62, string:'You must specify a unit for each axis, or a '; 63, string:'single unit for all axes.'; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:labels; 67, list:[]; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:x; 71, list:[]; 72, for_statement; 72, 73; 72, 76; 72, 80; 73, pattern_list; 73, 74; 73, 75; 74, identifier:i; 75, identifier:name; 76, call; 76, 77; 76, 78; 77, identifier:enumerate; 78, argument_list; 78, 79; 79, identifier:components; 80, block; 80, 81; 80, 89; 80, 119; 80, 154; 80, 180; 80, 194; 80, 206; 80, 220; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:val; 84, call; 84, 85; 84, 86; 85, identifier:getattr; 86, argument_list; 86, 87; 86, 88; 87, identifier:self; 88, identifier:name; 89, if_statement; 89, 90; 89, 93; 89, 111; 90, comparison_operator:is; 90, 91; 90, 92; 91, identifier:units; 92, None; 93, block; 93, 94; 93, 105; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:val; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:val; 100, identifier:to; 101, argument_list; 101, 102; 102, subscript; 102, 103; 102, 104; 103, identifier:units; 104, identifier:i; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:unit; 108, subscript; 108, 109; 108, 110; 109, identifier:units; 110, identifier:i; 111, else_clause; 111, 112; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:unit; 116, attribute; 116, 117; 116, 118; 117, identifier:val; 118, identifier:unit; 119, if_statement; 119, 120; 119, 127; 119, 148; 120, comparison_operator:!=; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:val; 123, identifier:unit; 124, attribute; 124, 125; 124, 126; 125, identifier:u; 126, identifier:one; 127, block; 127, 128; 127, 139; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:uu; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:unit; 134, identifier:to_string; 135, argument_list; 135, 136; 136, keyword_argument; 136, 137; 136, 138; 137, identifier:format; 138, string:'latex_inline'; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:unit_str; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, string:' [{}]'; 145, identifier:format; 146, argument_list; 146, 147; 147, identifier:uu; 148, else_clause; 148, 149; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:unit_str; 153, string:''; 154, if_statement; 154, 155; 154, 161; 154, 174; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:name; 158, identifier:startswith; 159, argument_list; 159, 160; 160, string:'d_'; 161, block; 161, 162; 161, 166; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 165; 164, identifier:dot; 165, True; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 169; 168, identifier:name; 169, subscript; 169, 170; 169, 171; 170, identifier:name; 171, slice; 171, 172; 171, 173; 172, integer:2; 173, colon; 174, else_clause; 174, 175; 175, block; 175, 176; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:dot; 179, False; 180, if_statement; 180, 181; 180, 184; 181, comparison_operator:in; 181, 182; 181, 183; 182, identifier:name; 183, identifier:_greek_letters; 184, block; 184, 185; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:name; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, string:r"\{}"; 191, identifier:format; 192, argument_list; 192, 193; 193, identifier:name; 194, if_statement; 194, 195; 194, 196; 195, identifier:dot; 196, block; 196, 197; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:name; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, string:"\dot{{{}}}"; 203, identifier:format; 204, argument_list; 204, 205; 205, identifier:name; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:labels; 210, identifier:append; 211, argument_list; 211, 212; 212, binary_operator:+; 212, 213; 212, 219; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, string:'${}$'; 216, identifier:format; 217, argument_list; 217, 218; 218, identifier:name; 219, identifier:unit_str; 220, expression_statement; 220, 221; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:x; 224, identifier:append; 225, argument_list; 225, 226; 226, attribute; 226, 227; 226, 228; 227, identifier:val; 228, identifier:value; 229, return_statement; 229, 230; 230, expression_list; 230, 231; 230, 232; 231, identifier:x; 232, identifier:labels | def _plot_prepare(self, components, units):
if components is None:
components = self.pos.components
n_comps = len(components)
if units is not None:
if isinstance(units, u.UnitBase):
units = [units]*n_comps
elif len(units) != n_comps:
raise ValueError('You must specify a unit for each axis, or a '
'single unit for all axes.')
labels = []
x = []
for i,name in enumerate(components):
val = getattr(self, name)
if units is not None:
val = val.to(units[i])
unit = units[i]
else:
unit = val.unit
if val.unit != u.one:
uu = unit.to_string(format='latex_inline')
unit_str = ' [{}]'.format(uu)
else:
unit_str = ''
if name.startswith('d_'):
dot = True
name = name[2:]
else:
dot = False
if name in _greek_letters:
name = r"\{}".format(name)
if dot:
name = "\dot{{{}}}".format(name)
labels.append('${}$'.format(name) + unit_str)
x.append(val.value)
return x, labels |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:recommend; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:client_data; 6, identifier:limit; 7, default_parameter; 7, 8; 7, 9; 8, identifier:extra_data; 9, dictionary; 10, block; 10, 11; 10, 21; 10, 30; 10, 43; 10, 56; 10, 62; 10, 166; 10, 194; 10, 215; 10, 232; 10, 243; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:preinstalled_addon_ids; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:client_data; 17, identifier:get; 18, argument_list; 18, 19; 18, 20; 19, string:"installed_addons"; 20, list:[]; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:extended_limit; 24, binary_operator:+; 24, 25; 24, 26; 25, identifier:limit; 26, call; 26, 27; 26, 28; 27, identifier:len; 28, argument_list; 28, 29; 29, identifier:preinstalled_addon_ids; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:ensemble_suggestions; 33, call; 33, 34; 33, 39; 34, attribute; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:_ensemble_recommender; 38, identifier:recommend; 39, argument_list; 39, 40; 39, 41; 39, 42; 40, identifier:client_data; 41, identifier:extended_limit; 42, identifier:extra_data; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:curated_suggestions; 46, call; 46, 47; 46, 52; 47, attribute; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:_curated_recommender; 51, identifier:recommend; 52, argument_list; 52, 53; 52, 54; 52, 55; 53, identifier:client_data; 54, identifier:extended_limit; 55, identifier:extra_data; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:merged_results; 59, call; 59, 60; 59, 61; 60, identifier:set; 61, argument_list; 62, while_statement; 62, 63; 62, 84; 63, parenthesized_expression; 63, 64; 64, boolean_operator:and; 64, 65; 64, 78; 65, boolean_operator:and; 65, 66; 65, 72; 66, comparison_operator:<; 66, 67; 66, 71; 67, call; 67, 68; 67, 69; 68, identifier:len; 69, argument_list; 69, 70; 70, identifier:merged_results; 71, identifier:limit; 72, comparison_operator:>; 72, 73; 72, 77; 73, call; 73, 74; 73, 75; 74, identifier:len; 75, argument_list; 75, 76; 76, identifier:ensemble_suggestions; 77, integer:0; 78, comparison_operator:>; 78, 79; 78, 83; 79, call; 79, 80; 79, 81; 80, identifier:len; 81, argument_list; 81, 82; 82, identifier:curated_suggestions; 83, integer:0; 84, block; 84, 85; 84, 93; 84, 113; 84, 138; 84, 146; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:r1; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:ensemble_suggestions; 91, identifier:pop; 92, argument_list; 93, if_statement; 93, 94; 93, 105; 94, comparison_operator:not; 94, 95; 94, 98; 95, subscript; 95, 96; 95, 97; 96, identifier:r1; 97, integer:0; 98, list_comprehension; 98, 99; 98, 102; 99, subscript; 99, 100; 99, 101; 100, identifier:temp; 101, integer:0; 102, for_in_clause; 102, 103; 102, 104; 103, identifier:temp; 104, identifier:merged_results; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:merged_results; 110, identifier:add; 111, argument_list; 111, 112; 112, identifier:r1; 113, if_statement; 113, 114; 113, 136; 114, not_operator; 114, 115; 115, parenthesized_expression; 115, 116; 116, boolean_operator:and; 116, 117; 116, 130; 117, boolean_operator:and; 117, 118; 117, 124; 118, comparison_operator:<; 118, 119; 118, 123; 119, call; 119, 120; 119, 121; 120, identifier:len; 121, argument_list; 121, 122; 122, identifier:merged_results; 123, identifier:limit; 124, comparison_operator:>; 124, 125; 124, 129; 125, call; 125, 126; 125, 127; 126, identifier:len; 127, argument_list; 127, 128; 128, identifier:ensemble_suggestions; 129, integer:0; 130, comparison_operator:>; 130, 131; 130, 135; 131, call; 131, 132; 131, 133; 132, identifier:len; 133, argument_list; 133, 134; 134, identifier:curated_suggestions; 135, integer:0; 136, block; 136, 137; 137, break_statement; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:r2; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:curated_suggestions; 144, identifier:pop; 145, argument_list; 146, if_statement; 146, 147; 146, 158; 147, comparison_operator:not; 147, 148; 147, 151; 148, subscript; 148, 149; 148, 150; 149, identifier:r2; 150, integer:0; 151, list_comprehension; 151, 152; 151, 155; 152, subscript; 152, 153; 152, 154; 153, identifier:temp; 154, integer:0; 155, for_in_clause; 155, 156; 155, 157; 156, identifier:temp; 157, identifier:merged_results; 158, block; 158, 159; 159, expression_statement; 159, 160; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:merged_results; 163, identifier:add; 164, argument_list; 164, 165; 165, identifier:r2; 166, if_statement; 166, 167; 166, 173; 167, comparison_operator:<; 167, 168; 167, 172; 168, call; 168, 169; 168, 170; 169, identifier:len; 170, argument_list; 170, 171; 171, identifier:merged_results; 172, identifier:limit; 173, block; 173, 174; 173, 183; 173, 192; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:msg; 177, parenthesized_expression; 177, 178; 178, binary_operator:%; 178, 179; 178, 180; 179, string:"Defaulting to empty results. Insufficient recommendations found for client: %s"; 180, subscript; 180, 181; 180, 182; 181, identifier:client_data; 182, string:"client_id"; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 190; 185, attribute; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:logger; 189, identifier:info; 190, argument_list; 190, 191; 191, identifier:msg; 192, return_statement; 192, 193; 193, list:[]; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:sorted_results; 197, call; 197, 198; 197, 199; 198, identifier:sorted; 199, argument_list; 199, 200; 199, 204; 199, 212; 200, call; 200, 201; 200, 202; 201, identifier:list; 202, argument_list; 202, 203; 203, identifier:merged_results; 204, keyword_argument; 204, 205; 204, 206; 205, identifier:key; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:op; 209, identifier:itemgetter; 210, argument_list; 210, 211; 211, integer:1; 212, keyword_argument; 212, 213; 212, 214; 213, identifier:reverse; 214, True; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:log_data; 218, tuple; 218, 219; 218, 222; 219, subscript; 219, 220; 219, 221; 220, identifier:client_data; 221, string:"client_id"; 222, call; 222, 223; 222, 224; 223, identifier:str; 224, argument_list; 224, 225; 225, list_comprehension; 225, 226; 225, 229; 226, subscript; 226, 227; 226, 228; 227, identifier:r; 228, integer:0; 229, for_in_clause; 229, 230; 229, 231; 230, identifier:r; 231, identifier:sorted_results; 232, expression_statement; 232, 233; 233, call; 233, 234; 233, 239; 234, attribute; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:self; 237, identifier:logger; 238, identifier:info; 239, argument_list; 239, 240; 240, binary_operator:%; 240, 241; 240, 242; 241, string:"Hybrid recommendations client_id: [%s], guids: [%s]"; 242, identifier:log_data; 243, return_statement; 243, 244; 244, identifier:sorted_results | def recommend(self, client_data, limit, extra_data={}):
preinstalled_addon_ids = client_data.get("installed_addons", [])
extended_limit = limit + len(preinstalled_addon_ids)
ensemble_suggestions = self._ensemble_recommender.recommend(
client_data, extended_limit, extra_data
)
curated_suggestions = self._curated_recommender.recommend(
client_data, extended_limit, extra_data
)
merged_results = set()
while (
len(merged_results) < limit
and len(ensemble_suggestions) > 0
and len(curated_suggestions) > 0
):
r1 = ensemble_suggestions.pop()
if r1[0] not in [temp[0] for temp in merged_results]:
merged_results.add(r1)
if not (
len(merged_results) < limit
and len(ensemble_suggestions) > 0
and len(curated_suggestions) > 0
):
break
r2 = curated_suggestions.pop()
if r2[0] not in [temp[0] for temp in merged_results]:
merged_results.add(r2)
if len(merged_results) < limit:
msg = (
"Defaulting to empty results. Insufficient recommendations found for client: %s"
% client_data["client_id"]
)
self.logger.info(msg)
return []
sorted_results = sorted(
list(merged_results), key=op.itemgetter(1), reverse=True
)
log_data = (client_data["client_id"], str([r[0] for r in sorted_results]))
self.logger.info(
"Hybrid recommendations client_id: [%s], guids: [%s]" % log_data
)
return sorted_results |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_recommend; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:client_data; 6, identifier:limit; 7, default_parameter; 7, 8; 7, 9; 8, identifier:extra_data; 9, dictionary; 10, block; 10, 11; 10, 20; 10, 30; 10, 39; 10, 43; 10, 53; 10, 120; 10, 134; 10, 149; 10, 153; 10, 185; 10, 200; 10, 216; 10, 224; 10, 245; 10, 256; 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:self; 16, identifier:logger; 17, identifier:info; 18, argument_list; 18, 19; 19, string:"Ensemble recommend invoked"; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:preinstalled_addon_ids; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:client_data; 26, identifier:get; 27, argument_list; 27, 28; 27, 29; 28, string:"installed_addons"; 29, list:[]; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:extended_limit; 33, binary_operator:+; 33, 34; 33, 35; 34, identifier:limit; 35, call; 35, 36; 35, 37; 36, identifier:len; 37, argument_list; 37, 38; 38, identifier:preinstalled_addon_ids; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:flattened_results; 42, list:[]; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:ensemble_weights; 46, call; 46, 47; 46, 52; 47, attribute; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:_weight_cache; 51, identifier:getWeights; 52, argument_list; 53, for_statement; 53, 54; 53, 55; 53, 58; 54, identifier:rkey; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:RECOMMENDER_KEYS; 58, block; 58, 59; 58, 67; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:recommender; 62, subscript; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:_recommender_map; 66, identifier:rkey; 67, if_statement; 67, 68; 67, 74; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:recommender; 71, identifier:can_recommend; 72, argument_list; 72, 73; 73, identifier:client_data; 74, block; 74, 75; 74, 86; 74, 90; 74, 113; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:raw_results; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:recommender; 81, identifier:recommend; 82, argument_list; 82, 83; 82, 84; 82, 85; 83, identifier:client_data; 84, identifier:extended_limit; 85, identifier:extra_data; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:reweighted_results; 89, list:[]; 90, for_statement; 90, 91; 90, 94; 90, 95; 91, pattern_list; 91, 92; 91, 93; 92, identifier:guid; 93, identifier:weight; 94, identifier:raw_results; 95, block; 95, 96; 95, 106; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:item; 99, tuple; 99, 100; 99, 101; 100, identifier:guid; 101, binary_operator:*; 101, 102; 101, 103; 102, identifier:weight; 103, subscript; 103, 104; 103, 105; 104, identifier:ensemble_weights; 105, identifier:rkey; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:reweighted_results; 110, identifier:append; 111, argument_list; 111, 112; 112, identifier:item; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:flattened_results; 117, identifier:extend; 118, argument_list; 118, 119; 119, identifier:reweighted_results; 120, expression_statement; 120, 121; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:flattened_results; 124, identifier:sort; 125, argument_list; 125, 126; 126, keyword_argument; 126, 127; 126, 128; 127, identifier:key; 128, lambda; 128, 129; 128, 131; 129, lambda_parameters; 129, 130; 130, identifier:item; 131, subscript; 131, 132; 131, 133; 132, identifier:item; 133, integer:0; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:guid_grouper; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:itertools; 140, identifier:groupby; 141, argument_list; 141, 142; 141, 143; 142, identifier:flattened_results; 143, lambda; 143, 144; 143, 146; 144, lambda_parameters; 144, 145; 145, identifier:item; 146, subscript; 146, 147; 146, 148; 147, identifier:item; 148, integer:0; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:ensemble_suggestions; 152, list:[]; 153, for_statement; 153, 154; 153, 157; 153, 158; 154, tuple_pattern; 154, 155; 154, 156; 155, identifier:guid; 156, identifier:guid_group; 157, identifier:guid_grouper; 158, block; 158, 159; 158, 172; 158, 178; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:weight_sum; 162, call; 162, 163; 162, 164; 163, identifier:sum; 164, argument_list; 164, 165; 165, list_comprehension; 165, 166; 165, 167; 166, identifier:v; 167, for_in_clause; 167, 168; 167, 171; 168, tuple_pattern; 168, 169; 168, 170; 169, identifier:g; 170, identifier:v; 171, identifier:guid_group; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:item; 175, tuple; 175, 176; 175, 177; 176, identifier:guid; 177, identifier:weight_sum; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:ensemble_suggestions; 182, identifier:append; 183, argument_list; 183, 184; 184, identifier:item; 185, expression_statement; 185, 186; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:ensemble_suggestions; 189, identifier:sort; 190, argument_list; 190, 191; 191, keyword_argument; 191, 192; 191, 193; 192, identifier:key; 193, lambda; 193, 194; 193, 196; 194, lambda_parameters; 194, 195; 195, identifier:x; 196, unary_operator:-; 196, 197; 197, subscript; 197, 198; 197, 199; 198, identifier:x; 199, integer:1; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:filtered_ensemble_suggestions; 203, list_comprehension; 203, 204; 203, 207; 203, 212; 204, tuple; 204, 205; 204, 206; 205, identifier:guid; 206, identifier:weight; 207, for_in_clause; 207, 208; 207, 211; 208, tuple_pattern; 208, 209; 208, 210; 209, identifier:guid; 210, identifier:weight; 211, identifier:ensemble_suggestions; 212, if_clause; 212, 213; 213, comparison_operator:not; 213, 214; 213, 215; 214, identifier:guid; 215, identifier:preinstalled_addon_ids; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:results; 219, subscript; 219, 220; 219, 221; 220, identifier:filtered_ensemble_suggestions; 221, slice; 221, 222; 221, 223; 222, colon; 223, identifier:limit; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 227; 226, identifier:log_data; 227, tuple; 227, 228; 227, 231; 227, 235; 228, subscript; 228, 229; 228, 230; 229, identifier:client_data; 230, string:"client_id"; 231, call; 231, 232; 231, 233; 232, identifier:str; 233, argument_list; 233, 234; 234, identifier:ensemble_weights; 235, call; 235, 236; 235, 237; 236, identifier:str; 237, argument_list; 237, 238; 238, list_comprehension; 238, 239; 238, 242; 239, subscript; 239, 240; 239, 241; 240, identifier:r; 241, integer:0; 242, for_in_clause; 242, 243; 242, 244; 243, identifier:r; 244, identifier:results; 245, expression_statement; 245, 246; 246, call; 246, 247; 246, 252; 247, attribute; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:self; 250, identifier:logger; 251, identifier:info; 252, argument_list; 252, 253; 253, binary_operator:%; 253, 254; 253, 255; 254, string:"client_id: [%s], ensemble_weight: [%s], guids: [%s]"; 255, identifier:log_data; 256, return_statement; 256, 257; 257, identifier:results | def _recommend(self, client_data, limit, extra_data={}):
self.logger.info("Ensemble recommend invoked")
preinstalled_addon_ids = client_data.get("installed_addons", [])
extended_limit = limit + len(preinstalled_addon_ids)
flattened_results = []
ensemble_weights = self._weight_cache.getWeights()
for rkey in self.RECOMMENDER_KEYS:
recommender = self._recommender_map[rkey]
if recommender.can_recommend(client_data):
raw_results = recommender.recommend(
client_data, extended_limit, extra_data
)
reweighted_results = []
for guid, weight in raw_results:
item = (guid, weight * ensemble_weights[rkey])
reweighted_results.append(item)
flattened_results.extend(reweighted_results)
flattened_results.sort(key=lambda item: item[0])
guid_grouper = itertools.groupby(flattened_results, lambda item: item[0])
ensemble_suggestions = []
for (guid, guid_group) in guid_grouper:
weight_sum = sum([v for (g, v) in guid_group])
item = (guid, weight_sum)
ensemble_suggestions.append(item)
ensemble_suggestions.sort(key=lambda x: -x[1])
filtered_ensemble_suggestions = [
(guid, weight)
for (guid, weight) in ensemble_suggestions
if guid not in preinstalled_addon_ids
]
results = filtered_ensemble_suggestions[:limit]
log_data = (
client_data["client_id"],
str(ensemble_weights),
str([r[0] for r in results]),
)
self.logger.info(
"client_id: [%s], ensemble_weight: [%s], guids: [%s]" % log_data
)
return results |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_build_features_caches; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 18; 5, 30; 5, 41; 5, 50; 5, 68; 5, 98; 5, 119; 5, 158; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:_donors_pool; 9, subscript; 9, 10; 9, 17; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:_donors_pool; 15, identifier:get; 16, argument_list; 17, integer:0; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:_lr_curves; 21, subscript; 21, 22; 21, 29; 22, call; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:_lr_curves; 27, identifier:get; 28, argument_list; 29, integer:0; 30, if_statement; 30, 31; 30, 38; 31, boolean_operator:or; 31, 32; 31, 35; 32, comparison_operator:is; 32, 33; 32, 34; 33, identifier:_donors_pool; 34, None; 35, comparison_operator:is; 35, 36; 35, 37; 36, identifier:_lr_curves; 37, None; 38, block; 38, 39; 39, return_statement; 39, 40; 40, None; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:num_donors; 46, call; 46, 47; 46, 48; 47, identifier:len; 48, argument_list; 48, 49; 49, identifier:_donors_pool; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:continuous_features; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:np; 58, identifier:zeros; 59, argument_list; 59, 60; 60, tuple; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:num_donors; 64, call; 64, 65; 64, 66; 65, identifier:len; 66, argument_list; 66, 67; 67, identifier:CONTINUOUS_FEATURES; 68, for_statement; 68, 69; 68, 72; 68, 76; 69, pattern_list; 69, 70; 69, 71; 70, identifier:idx; 71, identifier:d; 72, call; 72, 73; 72, 74; 73, identifier:enumerate; 74, argument_list; 74, 75; 75, identifier:_donors_pool; 76, block; 76, 77; 76, 90; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:features; 80, list_comprehension; 80, 81; 80, 87; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:d; 84, identifier:get; 85, argument_list; 85, 86; 86, identifier:specified_key; 87, for_in_clause; 87, 88; 87, 89; 88, identifier:specified_key; 89, identifier:CONTINUOUS_FEATURES; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 97; 92, subscript; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:self; 95, identifier:continuous_features; 96, identifier:idx; 97, identifier:features; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:categorical_features; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:np; 106, identifier:zeros; 107, argument_list; 107, 108; 107, 116; 108, tuple; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:num_donors; 112, call; 112, 113; 112, 114; 113, identifier:len; 114, argument_list; 114, 115; 115, identifier:CATEGORICAL_FEATURES; 116, keyword_argument; 116, 117; 116, 118; 117, identifier:dtype; 118, string:"object"; 119, for_statement; 119, 120; 119, 123; 119, 127; 120, pattern_list; 120, 121; 120, 122; 121, identifier:idx; 122, identifier:d; 123, call; 123, 124; 123, 125; 124, identifier:enumerate; 125, argument_list; 125, 126; 126, identifier:_donors_pool; 127, block; 127, 128; 127, 141; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:features; 131, list_comprehension; 131, 132; 131, 138; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:d; 135, identifier:get; 136, argument_list; 136, 137; 137, identifier:specified_key; 138, for_in_clause; 138, 139; 138, 140; 139, identifier:specified_key; 140, identifier:CATEGORICAL_FEATURES; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 148; 143, subscript; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:self; 146, identifier:categorical_features; 147, identifier:idx; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:np; 151, identifier:array; 152, argument_list; 152, 153; 152, 155; 153, list:[features]; 153, 154; 154, identifier:features; 155, keyword_argument; 155, 156; 155, 157; 156, identifier:dtype; 157, string:"object"; 158, expression_statement; 158, 159; 159, call; 159, 160; 159, 165; 160, attribute; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:logger; 164, identifier:info; 165, argument_list; 165, 166; 166, string:"Reconstructed matrices for similarity recommender" | def _build_features_caches(self):
_donors_pool = self._donors_pool.get()[0]
_lr_curves = self._lr_curves.get()[0]
if _donors_pool is None or _lr_curves is None:
return None
self.num_donors = len(_donors_pool)
self.continuous_features = np.zeros((self.num_donors, len(CONTINUOUS_FEATURES)))
for idx, d in enumerate(_donors_pool):
features = [d.get(specified_key) for specified_key in CONTINUOUS_FEATURES]
self.continuous_features[idx] = features
self.categorical_features = np.zeros(
(self.num_donors, len(CATEGORICAL_FEATURES)), dtype="object"
)
for idx, d in enumerate(_donors_pool):
features = [d.get(specified_key) for specified_key in CATEGORICAL_FEATURES]
self.categorical_features[idx] = np.array([features], dtype="object")
self.logger.info("Reconstructed matrices for similarity recommender") |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:pdos_select; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:atoms; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:spin; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:l; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:m; 16, None; 17, block; 17, 18; 17, 49; 17, 71; 17, 85; 17, 139; 17, 151; 17, 304; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:valid_m_values; 21, dictionary; 21, 22; 21, 25; 21, 31; 21, 39; 22, pair; 22, 23; 22, 24; 23, string:'s'; 24, list:[]; 25, pair; 25, 26; 25, 27; 26, string:'p'; 27, list:[ 'x', 'y', 'z' ]; 27, 28; 27, 29; 27, 30; 28, string:'x'; 29, string:'y'; 30, string:'z'; 31, pair; 31, 32; 31, 33; 32, string:'d'; 33, list:[ 'xy', 'yz', 'z2-r2', 'xz', 'x2-y2' ]; 33, 34; 33, 35; 33, 36; 33, 37; 33, 38; 34, string:'xy'; 35, string:'yz'; 36, string:'z2-r2'; 37, string:'xz'; 38, string:'x2-y2'; 39, pair; 39, 40; 39, 41; 40, string:'f'; 41, list:[ 'y(3x2-y2)', 'xyz', 'yz2', 'z3', 'xz2', 'z(x2-y2)', 'x(x2-3y2)' ]; 41, 42; 41, 43; 41, 44; 41, 45; 41, 46; 41, 47; 41, 48; 42, string:'y(3x2-y2)'; 43, string:'xyz'; 44, string:'yz2'; 45, string:'z3'; 46, string:'xz2'; 47, string:'z(x2-y2)'; 48, string:'x(x2-3y2)'; 49, if_statement; 49, 50; 49, 52; 49, 65; 50, not_operator; 50, 51; 51, identifier:atoms; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:atom_idx; 56, call; 56, 57; 56, 58; 57, identifier:list; 58, argument_list; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:range; 61, argument_list; 61, 62; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:number_of_atoms; 65, else_clause; 65, 66; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:atom_idx; 70, identifier:atoms; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:to_return; 74, subscript; 74, 75; 74, 78; 74, 79; 74, 81; 74, 83; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:pdos; 78, identifier:atom_idx; 79, slice; 79, 80; 80, colon; 81, slice; 81, 82; 82, colon; 83, slice; 83, 84; 84, colon; 85, if_statement; 85, 86; 85, 88; 85, 101; 85, 111; 85, 121; 85, 132; 86, not_operator; 86, 87; 87, identifier:spin; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:spin_idx; 92, call; 92, 93; 92, 94; 93, identifier:list; 94, argument_list; 94, 95; 95, call; 95, 96; 95, 97; 96, identifier:range; 97, argument_list; 97, 98; 98, attribute; 98, 99; 98, 100; 99, identifier:self; 100, identifier:ispin; 101, elif_clause; 101, 102; 101, 105; 102, comparison_operator:is; 102, 103; 102, 104; 103, identifier:spin; 104, string:'up'; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:spin_idx; 109, list:[0]; 109, 110; 110, integer:0; 111, elif_clause; 111, 112; 111, 115; 112, comparison_operator:is; 112, 113; 112, 114; 113, identifier:spin; 114, string:'down'; 115, block; 115, 116; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:spin_idx; 119, list:[1]; 119, 120; 120, integer:1; 121, elif_clause; 121, 122; 121, 125; 122, comparison_operator:is; 122, 123; 122, 124; 123, identifier:spin; 124, string:'both'; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:spin_idx; 129, list:[0,1]; 129, 130; 129, 131; 130, integer:0; 131, integer:1; 132, else_clause; 132, 133; 133, block; 133, 134; 134, raise_statement; 134, 135; 135, call; 135, 136; 135, 137; 136, identifier:ValueError; 137, argument_list; 137, 138; 138, string:"valid spin values are 'up', 'down', and 'both'. The default is 'both'"; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:to_return; 142, subscript; 142, 143; 142, 144; 142, 146; 142, 148; 142, 150; 143, identifier:to_return; 144, slice; 144, 145; 145, colon; 146, slice; 146, 147; 147, colon; 148, slice; 148, 149; 149, colon; 150, identifier:spin_idx; 151, if_statement; 151, 152; 151, 154; 151, 167; 151, 177; 151, 216; 151, 257; 151, 300; 152, not_operator; 152, 153; 153, identifier:l; 154, block; 154, 155; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:channel_idx; 158, call; 158, 159; 158, 160; 159, identifier:list; 160, argument_list; 160, 161; 161, call; 161, 162; 161, 163; 162, identifier:range; 163, argument_list; 163, 164; 164, attribute; 164, 165; 164, 166; 165, identifier:self; 166, identifier:number_of_channels; 167, elif_clause; 167, 168; 167, 171; 168, comparison_operator:==; 168, 169; 168, 170; 169, identifier:l; 170, string:'s'; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:channel_idx; 175, list:[ 0 ]; 175, 176; 176, integer:0; 177, elif_clause; 177, 178; 177, 181; 178, comparison_operator:==; 178, 179; 178, 180; 179, identifier:l; 180, string:'p'; 181, block; 181, 182; 182, if_statement; 182, 183; 182, 185; 182, 193; 183, not_operator; 183, 184; 184, identifier:m; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:channel_idx; 189, list:[ 1, 2, 3 ]; 189, 190; 189, 191; 189, 192; 190, integer:1; 191, integer:2; 192, integer:3; 193, else_clause; 193, 194; 194, block; 194, 195; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 198; 197, identifier:channel_idx; 198, list_comprehension; 198, 199; 198, 202; 198, 212; 199, binary_operator:+; 199, 200; 199, 201; 200, identifier:i; 201, integer:1; 202, for_in_clause; 202, 203; 202, 206; 203, pattern_list; 203, 204; 203, 205; 204, identifier:i; 205, identifier:v; 206, call; 206, 207; 206, 208; 207, identifier:enumerate; 208, argument_list; 208, 209; 209, subscript; 209, 210; 209, 211; 210, identifier:valid_m_values; 211, string:'p'; 212, if_clause; 212, 213; 213, comparison_operator:in; 213, 214; 213, 215; 214, identifier:v; 215, identifier:m; 216, elif_clause; 216, 217; 216, 220; 217, comparison_operator:==; 217, 218; 217, 219; 218, identifier:l; 219, string:'d'; 220, block; 220, 221; 221, if_statement; 221, 222; 221, 224; 221, 234; 222, not_operator; 222, 223; 223, identifier:m; 224, block; 224, 225; 225, expression_statement; 225, 226; 226, assignment; 226, 227; 226, 228; 227, identifier:channel_idx; 228, list:[ 4, 5, 6, 7, 8 ]; 228, 229; 228, 230; 228, 231; 228, 232; 228, 233; 229, integer:4; 230, integer:5; 231, integer:6; 232, integer:7; 233, integer:8; 234, else_clause; 234, 235; 235, block; 235, 236; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:channel_idx; 239, list_comprehension; 239, 240; 239, 243; 239, 253; 240, binary_operator:+; 240, 241; 240, 242; 241, identifier:i; 242, integer:4; 243, for_in_clause; 243, 244; 243, 247; 244, pattern_list; 244, 245; 244, 246; 245, identifier:i; 246, identifier:v; 247, call; 247, 248; 247, 249; 248, identifier:enumerate; 249, argument_list; 249, 250; 250, subscript; 250, 251; 250, 252; 251, identifier:valid_m_values; 252, string:'d'; 253, if_clause; 253, 254; 254, comparison_operator:in; 254, 255; 254, 256; 255, identifier:v; 256, identifier:m; 257, elif_clause; 257, 258; 257, 261; 258, comparison_operator:==; 258, 259; 258, 260; 259, identifier:l; 260, string:'f'; 261, block; 261, 262; 262, if_statement; 262, 263; 262, 265; 262, 277; 263, not_operator; 263, 264; 264, identifier:m; 265, block; 265, 266; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 269; 268, identifier:channel_idx; 269, list:[ 9, 10, 11, 12, 13, 14, 15 ]; 269, 270; 269, 271; 269, 272; 269, 273; 269, 274; 269, 275; 269, 276; 270, integer:9; 271, integer:10; 272, integer:11; 273, integer:12; 274, integer:13; 275, integer:14; 276, integer:15; 277, else_clause; 277, 278; 278, block; 278, 279; 279, expression_statement; 279, 280; 280, assignment; 280, 281; 280, 282; 281, identifier:channel_idx; 282, list_comprehension; 282, 283; 282, 286; 282, 296; 283, binary_operator:+; 283, 284; 283, 285; 284, identifier:i; 285, integer:9; 286, for_in_clause; 286, 287; 286, 290; 287, pattern_list; 287, 288; 287, 289; 288, identifier:i; 289, identifier:v; 290, call; 290, 291; 290, 292; 291, identifier:enumerate; 292, argument_list; 292, 293; 293, subscript; 293, 294; 293, 295; 294, identifier:valid_m_values; 295, string:'f'; 296, if_clause; 296, 297; 297, comparison_operator:in; 297, 298; 297, 299; 298, identifier:v; 299, identifier:m; 300, else_clause; 300, 301; 301, block; 301, 302; 302, raise_statement; 302, 303; 303, identifier:ValueError; 304, return_statement; 304, 305; 305, subscript; 305, 306; 305, 307; 305, 309; 305, 311; 305, 312; 306, identifier:to_return; 307, slice; 307, 308; 308, colon; 309, slice; 309, 310; 310, colon; 311, identifier:channel_idx; 312, slice; 312, 313; 313, colon | def pdos_select( self, atoms=None, spin=None, l=None, m=None ):
valid_m_values = { 's': [],
'p': [ 'x', 'y', 'z' ],
'd': [ 'xy', 'yz', 'z2-r2', 'xz', 'x2-y2' ],
'f': [ 'y(3x2-y2)', 'xyz', 'yz2', 'z3', 'xz2', 'z(x2-y2)', 'x(x2-3y2)' ] }
if not atoms:
atom_idx = list(range( self.number_of_atoms ))
else:
atom_idx = atoms
to_return = self.pdos[ atom_idx, :, :, : ]
if not spin:
spin_idx = list(range( self.ispin ))
elif spin is 'up':
spin_idx = [0]
elif spin is 'down':
spin_idx = [1]
elif spin is 'both':
spin_idx = [0,1]
else:
raise ValueError( "valid spin values are 'up', 'down', and 'both'. The default is 'both'" )
to_return = to_return[ :, :, :, spin_idx ]
if not l:
channel_idx = list(range( self.number_of_channels ))
elif l == 's':
channel_idx = [ 0 ]
elif l == 'p':
if not m:
channel_idx = [ 1, 2, 3 ]
else:
channel_idx = [ i+1 for i, v in enumerate( valid_m_values['p'] ) if v in m ]
elif l == 'd':
if not m:
channel_idx = [ 4, 5, 6, 7, 8 ]
else:
channel_idx = [ i+4 for i, v in enumerate( valid_m_values['d'] ) if v in m ]
elif l == 'f':
if not m:
channel_idx = [ 9, 10, 11, 12, 13, 14, 15 ]
else:
channel_idx = [ i+9 for i, v in enumerate( valid_m_values['f'] ) if v in m ]
else:
raise ValueError
return to_return[ :, :, channel_idx, : ] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_describe; 3, parameters; 3, 4; 3, 5; 4, identifier:node; 5, identifier:parent; 6, block; 6, 7; 6, 14; 6, 24; 6, 210; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 13; 9, pattern_list; 9, 10; 9, 11; 9, 12; 10, identifier:name; 11, identifier:logger; 12, identifier:children; 13, identifier:node; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:is_placeholder; 17, call; 17, 18; 17, 19; 18, identifier:isinstance; 19, argument_list; 19, 20; 19, 21; 20, identifier:logger; 21, attribute; 21, 22; 21, 23; 22, identifier:logging; 23, identifier:PlaceHolder; 24, if_statement; 24, 25; 24, 26; 24, 32; 25, identifier:is_placeholder; 26, block; 26, 27; 27, expression_statement; 27, 28; 28, yield; 28, 29; 29, binary_operator:%; 29, 30; 29, 31; 30, string:'<--[%s]'; 31, identifier:name; 32, else_clause; 32, 33; 33, block; 33, 34; 33, 48; 33, 71; 33, 78; 33, 106; 33, 143; 33, 152; 33, 160; 33, 177; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:parent_is_correct; 37, boolean_operator:or; 37, 38; 37, 42; 38, parenthesized_expression; 38, 39; 39, comparison_operator:is; 39, 40; 39, 41; 40, identifier:parent; 41, None; 42, parenthesized_expression; 42, 43; 43, comparison_operator:is; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:logger; 46, identifier:parent; 47, identifier:parent; 48, if_statement; 48, 49; 48, 53; 48, 58; 48, 65; 49, not_operator; 49, 50; 50, attribute; 50, 51; 50, 52; 51, identifier:logger; 52, identifier:propagate; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:arrow; 57, string:' '; 58, elif_clause; 58, 59; 58, 60; 59, identifier:parent_is_correct; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:arrow; 64, string:'<--'; 65, else_clause; 65, 66; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:arrow; 70, string:' !-'; 71, expression_statement; 71, 72; 72, yield; 72, 73; 73, binary_operator:%; 73, 74; 73, 75; 74, string:'%s"%s"'; 75, tuple; 75, 76; 75, 77; 76, identifier:arrow; 77, identifier:name; 78, if_statement; 78, 79; 78, 81; 79, not_operator; 79, 80; 80, identifier:parent_is_correct; 81, block; 81, 82; 82, if_statement; 82, 83; 82, 88; 82, 93; 83, comparison_operator:is; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:logger; 86, identifier:parent; 87, None; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, yield; 90, 91; 91, parenthesized_expression; 91, 92; 92, string:' Broken .parent is None, so messages stop here'; 93, else_clause; 93, 94; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, yield; 96, 97; 97, parenthesized_expression; 97, 98; 98, binary_operator:%; 98, 99; 98, 100; 99, string:' Broken .parent redirects messages to %r instead'; 100, tuple; 100, 101; 101, attribute; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:logger; 104, identifier:parent; 105, identifier:name; 106, if_statement; 106, 107; 106, 114; 106, 129; 107, comparison_operator:==; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:logger; 110, identifier:level; 111, attribute; 111, 112; 111, 113; 112, identifier:logging; 113, identifier:NOTSET; 114, block; 114, 115; 115, expression_statement; 115, 116; 116, yield; 116, 117; 117, binary_operator:+; 117, 118; 117, 119; 118, string:' Level NOTSET so inherits level '; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:logging; 122, identifier:getLevelName; 123, argument_list; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:logger; 127, identifier:getEffectiveLevel; 128, argument_list; 129, else_clause; 129, 130; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, yield; 132, 133; 133, binary_operator:+; 133, 134; 133, 135; 134, string:' Level '; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:logging; 138, identifier:getLevelName; 139, argument_list; 139, 140; 140, attribute; 140, 141; 140, 142; 141, identifier:logger; 142, identifier:level; 143, if_statement; 143, 144; 143, 148; 144, not_operator; 144, 145; 145, attribute; 145, 146; 145, 147; 146, identifier:logger; 147, identifier:propagate; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, yield; 150, 151; 151, string:' Propagate OFF'; 152, if_statement; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:logger; 155, identifier:disabled; 156, block; 156, 157; 157, expression_statement; 157, 158; 158, yield; 158, 159; 159, string:' Disabled'; 160, for_statement; 160, 161; 160, 162; 160, 168; 161, identifier:f; 162, call; 162, 163; 162, 164; 163, identifier:getattr; 164, argument_list; 164, 165; 164, 166; 164, 167; 165, identifier:logger; 166, string:'filters'; 167, tuple; 168, block; 168, 169; 169, expression_statement; 169, 170; 170, yield; 170, 171; 171, binary_operator:%; 171, 172; 171, 173; 172, string:' Filter %s'; 173, call; 173, 174; 173, 175; 174, identifier:describe_filter; 175, argument_list; 175, 176; 176, identifier:f; 177, for_statement; 177, 178; 177, 179; 177, 185; 178, identifier:h; 179, call; 179, 180; 179, 181; 180, identifier:getattr; 181, argument_list; 181, 182; 181, 183; 181, 184; 182, identifier:logger; 183, string:'handlers'; 184, tuple; 185, block; 185, 186; 185, 193; 185, 201; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:g; 189, call; 189, 190; 189, 191; 190, identifier:describe_handler; 191, argument_list; 191, 192; 192, identifier:h; 193, expression_statement; 193, 194; 194, yield; 194, 195; 195, binary_operator:%; 195, 196; 195, 197; 196, string:' Handler %s'; 197, call; 197, 198; 197, 199; 198, identifier:next; 199, argument_list; 199, 200; 200, identifier:g; 201, for_statement; 201, 202; 201, 203; 201, 204; 202, identifier:line; 203, identifier:g; 204, block; 204, 205; 205, expression_statement; 205, 206; 206, yield; 206, 207; 207, binary_operator:+; 207, 208; 207, 209; 208, string:' '; 209, identifier:line; 210, if_statement; 210, 211; 210, 212; 211, identifier:children; 212, block; 212, 213; 212, 221; 212, 228; 213, if_statement; 213, 214; 213, 216; 214, not_operator; 214, 215; 215, identifier:is_placeholder; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:parent; 220, identifier:logger; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:last_child; 224, subscript; 224, 225; 224, 226; 225, identifier:children; 226, unary_operator:-; 226, 227; 227, integer:1; 228, for_statement; 228, 229; 228, 230; 228, 231; 229, identifier:child; 230, identifier:children; 231, block; 231, 232; 231, 240; 231, 243; 231, 251; 231, 266; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:g; 235, call; 235, 236; 235, 237; 236, identifier:_describe; 237, argument_list; 237, 238; 237, 239; 238, identifier:child; 239, identifier:parent; 240, expression_statement; 240, 241; 241, yield; 241, 242; 242, string:' |'; 243, expression_statement; 243, 244; 244, yield; 244, 245; 245, binary_operator:+; 245, 246; 245, 247; 246, string:' o'; 247, call; 247, 248; 247, 249; 248, identifier:next; 249, argument_list; 249, 250; 250, identifier:g; 251, if_statement; 251, 252; 251, 255; 251, 260; 252, comparison_operator:is; 252, 253; 252, 254; 253, identifier:child; 254, identifier:last_child; 255, block; 255, 256; 256, expression_statement; 256, 257; 257, assignment; 257, 258; 257, 259; 258, identifier:prefix; 259, string:' '; 260, else_clause; 260, 261; 261, block; 261, 262; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 265; 264, identifier:prefix; 265, string:' |'; 266, for_statement; 266, 267; 266, 268; 266, 269; 267, identifier:line; 268, identifier:g; 269, block; 269, 270; 270, expression_statement; 270, 271; 271, yield; 271, 272; 272, binary_operator:+; 272, 273; 272, 274; 273, identifier:prefix; 274, identifier:line | def _describe(node, parent):
name, logger, children = node
is_placeholder = isinstance(logger, logging.PlaceHolder)
if is_placeholder:
yield '<--[%s]' % name
else:
parent_is_correct = (parent is None) or (logger.parent is parent)
if not logger.propagate:
arrow = ' '
elif parent_is_correct:
arrow = '<--'
else:
arrow = ' !-'
yield '%s"%s"' % (arrow, name)
if not parent_is_correct:
if logger.parent is None:
yield (' Broken .parent is None, so messages stop here')
else:
yield (' Broken .parent redirects messages to %r instead'
% (logger.parent.name,))
if logger.level == logging.NOTSET:
yield ' Level NOTSET so inherits level ' + logging.getLevelName(
logger.getEffectiveLevel())
else:
yield ' Level ' + logging.getLevelName(logger.level)
if not logger.propagate:
yield ' Propagate OFF'
if logger.disabled:
yield ' Disabled'
for f in getattr(logger, 'filters', ()):
yield ' Filter %s' % describe_filter(f)
for h in getattr(logger, 'handlers', ()):
g = describe_handler(h)
yield ' Handler %s' % next(g)
for line in g:
yield ' ' + line
if children:
if not is_placeholder:
parent = logger
last_child = children[-1]
for child in children:
g = _describe(child, parent)
yield ' |'
yield ' o' + next(g)
if child is last_child:
prefix = ' '
else:
prefix = ' |'
for line in g:
yield prefix + line |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:resample; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 21; 5, 27; 5, 33; 5, 60; 5, 81; 5, 93; 5, 101; 5, 109; 5, 134; 5, 162; 5, 184; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:just_resampled; 10, block; 10, 11; 11, expression_statement; 11, 12; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:warnings; 15, identifier:warn; 16, argument_list; 16, 17; 16, 20; 17, concatenated_string; 17, 18; 17, 19; 18, string:"Resampling without additional data; this may not perform as "; 19, string:"desired."; 20, identifier:ResamplerWarning; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:_just_resampled; 26, True; 27, expression_statement; 27, 28; 28, augmented_assignment:+=; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:_resample_count; 32, integer:1; 33, if_statement; 33, 34; 33, 39; 34, comparison_operator:is; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:_resampling_divergences; 38, None; 39, block; 39, 40; 39, 50; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:old_locs; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:particle_locations; 48, identifier:copy; 49, argument_list; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:old_weights; 53, call; 53, 54; 53, 59; 54, attribute; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:particle_weights; 58, identifier:copy; 59, argument_list; 60, if_statement; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:_debug_resampling; 64, block; 64, 65; 64, 73; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:old_mean; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:est_mean; 72, argument_list; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:old_cov; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:est_covariance_mtx; 80, argument_list; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:new_distribution; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:resampler; 88, argument_list; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:model; 92, identifier:self; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:particle_weights; 98, attribute; 98, 99; 98, 100; 99, identifier:new_distribution; 100, identifier:particle_weights; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:self; 105, identifier:particle_locations; 106, attribute; 106, 107; 106, 108; 107, identifier:new_distribution; 108, identifier:particle_locations; 109, if_statement; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:self; 112, identifier:_canonicalize; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 124; 116, subscript; 116, 117; 116, 120; 116, 122; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:particle_locations; 120, slice; 120, 121; 121, colon; 122, slice; 122, 123; 123, colon; 124, call; 124, 125; 124, 130; 125, attribute; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:model; 129, identifier:canonicalize; 130, argument_list; 130, 131; 131, attribute; 131, 132; 131, 133; 132, identifier:self; 133, identifier:particle_locations; 134, try_statement; 134, 135; 134, 144; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, call; 137, 138; 137, 143; 138, attribute; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:model; 142, identifier:clear_cache; 143, argument_list; 144, except_clause; 144, 145; 144, 149; 145, as_pattern; 145, 146; 145, 147; 146, identifier:Exception; 147, as_pattern_target; 147, 148; 148, identifier:e; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:warnings; 154, identifier:warn; 155, argument_list; 155, 156; 156, call; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, string:"Exception raised when clearing model cache: {}. Ignoring."; 159, identifier:format; 160, argument_list; 160, 161; 161, identifier:e; 162, if_statement; 162, 163; 162, 168; 163, comparison_operator:is; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:self; 166, identifier:_resampling_divergences; 167, None; 168, block; 168, 169; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 176; 171, attribute; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:self; 174, identifier:_resampling_divergences; 175, identifier:append; 176, argument_list; 176, 177; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:self; 180, identifier:_kl_divergence; 181, argument_list; 181, 182; 181, 183; 182, identifier:old_locs; 183, identifier:old_weights; 184, if_statement; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:self; 187, identifier:_debug_resampling; 188, block; 188, 189; 188, 197; 188, 205; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:new_mean; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:self; 195, identifier:est_mean; 196, argument_list; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:new_cov; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:self; 203, identifier:est_covariance_mtx; 204, argument_list; 205, expression_statement; 205, 206; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:logger; 209, identifier:debug; 210, argument_list; 210, 211; 211, call; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, string:"Resampling changed mean by {}. Norm change in cov: {}."; 214, identifier:format; 215, argument_list; 215, 216; 215, 219; 216, binary_operator:-; 216, 217; 216, 218; 217, identifier:old_mean; 218, identifier:new_mean; 219, call; 219, 220; 219, 225; 220, attribute; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:np; 223, identifier:linalg; 224, identifier:norm; 225, argument_list; 225, 226; 226, binary_operator:-; 226, 227; 226, 228; 227, identifier:new_cov; 228, identifier:old_cov | def resample(self):
if self.just_resampled:
warnings.warn(
"Resampling without additional data; this may not perform as "
"desired.",
ResamplerWarning
)
self._just_resampled = True
self._resample_count += 1
if self._resampling_divergences is not None:
old_locs = self.particle_locations.copy()
old_weights = self.particle_weights.copy()
if self._debug_resampling:
old_mean = self.est_mean()
old_cov = self.est_covariance_mtx()
new_distribution = self.resampler(self.model, self)
self.particle_weights = new_distribution.particle_weights
self.particle_locations = new_distribution.particle_locations
if self._canonicalize:
self.particle_locations[:, :] = self.model.canonicalize(self.particle_locations)
try:
self.model.clear_cache()
except Exception as e:
warnings.warn("Exception raised when clearing model cache: {}. Ignoring.".format(e))
if self._resampling_divergences is not None:
self._resampling_divergences.append(
self._kl_divergence(old_locs, old_weights)
)
if self._debug_resampling:
new_mean = self.est_mean()
new_cov = self.est_covariance_mtx()
logger.debug("Resampling changed mean by {}. Norm change in cov: {}.".format(
old_mean - new_mean,
np.linalg.norm(new_cov - old_cov)
)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:expected_information_gain; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:expparams; 6, block; 6, 7; 6, 9; 6, 15; 6, 61; 6, 81; 6, 105; 6, 129; 6, 165; 6, 179; 6, 201; 6, 224; 7, expression_statement; 7, 8; 8, identifier:r; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:n_eps; 12, attribute; 12, 13; 12, 14; 13, identifier:expparams; 14, identifier:size; 15, if_statement; 15, 16; 15, 26; 16, boolean_operator:and; 16, 17; 16, 20; 17, comparison_operator:>; 17, 18; 17, 19; 18, identifier:n_eps; 19, integer:1; 20, not_operator; 20, 21; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:model; 25, identifier:is_n_outcomes_constant; 26, block; 26, 27; 26, 36; 26, 59; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:risk; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:np; 33, identifier:empty; 34, argument_list; 34, 35; 35, identifier:n_eps; 36, for_statement; 36, 37; 36, 38; 36, 42; 37, identifier:idx; 38, call; 38, 39; 38, 40; 39, identifier:range; 40, argument_list; 40, 41; 41, identifier:n_eps; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 48; 45, subscript; 45, 46; 45, 47; 46, identifier:risk; 47, identifier:idx; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:expected_information_gain; 52, argument_list; 52, 53; 53, subscript; 53, 54; 53, 55; 53, 56; 54, identifier:expparams; 55, identifier:idx; 56, attribute; 56, 57; 56, 58; 57, identifier:np; 58, identifier:newaxis; 59, return_statement; 59, 60; 60, identifier:risk; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:os; 64, attribute; 64, 65; 64, 80; 65, subscript; 65, 66; 65, 79; 66, call; 66, 67; 66, 72; 67, attribute; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:model; 71, identifier:domain; 72, argument_list; 72, 73; 73, subscript; 73, 74; 73, 75; 73, 76; 74, identifier:expparams; 75, integer:0; 76, attribute; 76, 77; 76, 78; 77, identifier:np; 78, identifier:newaxis; 79, integer:0; 80, identifier:values; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 87; 83, pattern_list; 83, 84; 83, 85; 83, 86; 84, identifier:w_hyp; 85, identifier:L; 86, identifier:N; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:hypothetical_update; 91, argument_list; 91, 92; 91, 98; 91, 99; 91, 102; 92, subscript; 92, 93; 92, 94; 93, identifier:os; 94, slice; 94, 95; 94, 96; 95, colon; 96, unary_operator:-; 96, 97; 97, integer:1; 98, identifier:expparams; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:return_normalization; 101, True; 102, keyword_argument; 102, 103; 102, 104; 103, identifier:return_likelihood; 104, True; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:w_hyp_last_outcome; 108, binary_operator:*; 108, 109; 108, 120; 109, parenthesized_expression; 109, 110; 110, binary_operator:-; 110, 111; 110, 112; 111, integer:1; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:L; 115, identifier:sum; 116, argument_list; 116, 117; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:axis; 119, integer:0; 120, subscript; 120, 121; 120, 124; 120, 127; 121, attribute; 121, 122; 121, 123; 122, identifier:self; 123, identifier:particle_weights; 124, attribute; 124, 125; 124, 126; 125, identifier:np; 126, identifier:newaxis; 127, slice; 127, 128; 128, colon; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:N; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:np; 135, identifier:concatenate; 136, argument_list; 136, 137; 136, 162; 137, list:[N[:,:,0], np.sum(w_hyp_last_outcome[np.newaxis,:,:], axis=2)]; 137, 138; 137, 145; 138, subscript; 138, 139; 138, 140; 138, 142; 138, 144; 139, identifier:N; 140, slice; 140, 141; 141, colon; 142, slice; 142, 143; 143, colon; 144, integer:0; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:np; 148, identifier:sum; 149, argument_list; 149, 150; 149, 159; 150, subscript; 150, 151; 150, 152; 150, 155; 150, 157; 151, identifier:w_hyp_last_outcome; 152, attribute; 152, 153; 152, 154; 153, identifier:np; 154, identifier:newaxis; 155, slice; 155, 156; 156, colon; 157, slice; 157, 158; 158, colon; 159, keyword_argument; 159, 160; 159, 161; 160, identifier:axis; 161, integer:2; 162, keyword_argument; 162, 163; 162, 164; 163, identifier:axis; 164, integer:0; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:w_hyp_last_outcome; 168, binary_operator:/; 168, 169; 168, 170; 169, identifier:w_hyp_last_outcome; 170, subscript; 170, 171; 170, 172; 170, 174; 170, 176; 171, identifier:N; 172, unary_operator:-; 172, 173; 173, integer:1; 174, slice; 174, 175; 175, colon; 176, attribute; 176, 177; 176, 178; 177, identifier:np; 178, identifier:newaxis; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:w_hyp; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:np; 185, identifier:concatenate; 186, argument_list; 186, 187; 186, 198; 187, list:[w_hyp, w_hyp_last_outcome[np.newaxis,:,:]]; 187, 188; 187, 189; 188, identifier:w_hyp; 189, subscript; 189, 190; 189, 191; 189, 194; 189, 196; 190, identifier:w_hyp_last_outcome; 191, attribute; 191, 192; 191, 193; 192, identifier:np; 193, identifier:newaxis; 194, slice; 194, 195; 195, colon; 196, slice; 196, 197; 197, colon; 198, keyword_argument; 198, 199; 198, 200; 199, identifier:axis; 200, integer:0; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:KLD; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:np; 207, identifier:sum; 208, argument_list; 208, 209; 208, 221; 209, binary_operator:*; 209, 210; 209, 211; 210, identifier:w_hyp; 211, call; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:np; 214, identifier:log; 215, argument_list; 215, 216; 216, binary_operator:/; 216, 217; 216, 218; 217, identifier:w_hyp; 218, attribute; 218, 219; 218, 220; 219, identifier:self; 220, identifier:particle_weights; 221, keyword_argument; 221, 222; 221, 223; 222, identifier:axis; 223, integer:2; 224, return_statement; 224, 225; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:np; 228, identifier:sum; 229, argument_list; 229, 230; 229, 233; 230, binary_operator:*; 230, 231; 230, 232; 231, identifier:N; 232, identifier:KLD; 233, keyword_argument; 233, 234; 233, 235; 234, identifier:axis; 235, integer:0 | def expected_information_gain(self, expparams):
r
n_eps = expparams.size
if n_eps > 1 and not self.model.is_n_outcomes_constant:
risk = np.empty(n_eps)
for idx in range(n_eps):
risk[idx] = self.expected_information_gain(expparams[idx, np.newaxis])
return risk
os = self.model.domain(expparams[0,np.newaxis])[0].values
w_hyp, L, N = self.hypothetical_update(
os[:-1],
expparams,
return_normalization=True,
return_likelihood=True
)
w_hyp_last_outcome = (1 - L.sum(axis=0)) * self.particle_weights[np.newaxis, :]
N = np.concatenate([N[:,:,0], np.sum(w_hyp_last_outcome[np.newaxis,:,:], axis=2)], axis=0)
w_hyp_last_outcome = w_hyp_last_outcome / N[-1,:,np.newaxis]
w_hyp = np.concatenate([w_hyp, w_hyp_last_outcome[np.newaxis,:,:]], axis=0)
KLD = np.sum(w_hyp * np.log(w_hyp / self.particle_weights), axis=2)
return np.sum(N * KLD, axis=0) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:iter_actions; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 27; 5, 36; 5, 40; 5, 54; 5, 200; 5, 214; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ns; 9, string:'{urn:schemas-upnp-org:service-1-0}'; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:scpd_body; 13, attribute; 13, 14; 13, 26; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:requests; 17, identifier:get; 18, argument_list; 18, 19; 19, binary_operator:+; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:base_url; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:scpd_url; 26, identifier:content; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:tree; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:XML; 33, identifier:fromstring; 34, argument_list; 34, 35; 35, identifier:scpd_body; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:vartypes; 39, dictionary; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:srvStateTables; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:tree; 46, identifier:findall; 47, argument_list; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, string:'{}serviceStateTable'; 51, identifier:format; 52, argument_list; 52, 53; 53, identifier:ns; 54, for_statement; 54, 55; 54, 56; 54, 57; 55, identifier:srvStateTable; 56, identifier:srvStateTables; 57, block; 57, 58; 57, 72; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:statevars; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:srvStateTable; 64, identifier:findall; 65, argument_list; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, string:'{}stateVariable'; 69, identifier:format; 70, argument_list; 70, 71; 71, identifier:ns; 72, for_statement; 72, 73; 72, 74; 72, 75; 73, identifier:state; 74, identifier:statevars; 75, block; 75, 76; 75, 90; 75, 104; 75, 118; 75, 132; 75, 141; 75, 153; 75, 167; 75, 176; 75, 188; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:name; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:state; 82, identifier:findtext; 83, argument_list; 83, 84; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, string:'{}name'; 87, identifier:format; 88, argument_list; 88, 89; 89, identifier:ns; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:datatype; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:state; 96, identifier:findtext; 97, argument_list; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, string:'{}dataType'; 101, identifier:format; 102, argument_list; 102, 103; 103, identifier:ns; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:default; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:state; 110, identifier:findtext; 111, argument_list; 111, 112; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, string:'{}defaultValue'; 115, identifier:format; 116, argument_list; 116, 117; 117, identifier:ns; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 121; 120, identifier:value_list_elt; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:state; 124, identifier:find; 125, argument_list; 125, 126; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, string:'{}allowedValueList'; 129, identifier:format; 130, argument_list; 130, 131; 131, identifier:ns; 132, if_statement; 132, 133; 132, 136; 133, comparison_operator:is; 133, 134; 133, 135; 134, identifier:value_list_elt; 135, None; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:value_list_elt; 140, tuple; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:value_list; 144, boolean_operator:or; 144, 145; 144, 152; 145, list_comprehension; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:item; 148, identifier:text; 149, for_in_clause; 149, 150; 149, 151; 150, identifier:item; 151, identifier:value_list_elt; 152, None; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:value_range_elt; 156, call; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:state; 159, identifier:find; 160, argument_list; 160, 161; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, string:'{}allowedValueRange'; 164, identifier:format; 165, argument_list; 165, 166; 166, identifier:ns; 167, if_statement; 167, 168; 167, 171; 168, comparison_operator:is; 168, 169; 168, 170; 169, identifier:value_range_elt; 170, None; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:value_range_elt; 175, tuple; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:value_range; 179, boolean_operator:or; 179, 180; 179, 187; 180, list_comprehension; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:item; 183, identifier:text; 184, for_in_clause; 184, 185; 184, 186; 185, identifier:item; 186, identifier:value_range_elt; 187, None; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 193; 190, subscript; 190, 191; 190, 192; 191, identifier:vartypes; 192, identifier:name; 193, call; 193, 194; 193, 195; 194, identifier:Vartype; 195, argument_list; 195, 196; 195, 197; 195, 198; 195, 199; 196, identifier:datatype; 197, identifier:default; 198, identifier:value_list; 199, identifier:value_range; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:actionLists; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:tree; 206, identifier:findall; 207, argument_list; 207, 208; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, string:'{}actionList'; 211, identifier:format; 212, argument_list; 212, 213; 213, identifier:ns; 214, for_statement; 214, 215; 214, 216; 214, 217; 215, identifier:actionList; 216, identifier:actionLists; 217, block; 217, 218; 217, 232; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 221; 220, identifier:actions; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:actionList; 224, identifier:findall; 225, argument_list; 225, 226; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, string:'{}action'; 229, identifier:format; 230, argument_list; 230, 231; 231, identifier:ns; 232, for_statement; 232, 233; 232, 234; 232, 235; 233, identifier:i; 234, identifier:actions; 235, block; 235, 236; 235, 250; 235, 264; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:action_name; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:i; 242, identifier:findtext; 243, argument_list; 243, 244; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, string:'{}name'; 247, identifier:format; 248, argument_list; 248, 249; 249, identifier:ns; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:argLists; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:i; 256, identifier:findall; 257, argument_list; 257, 258; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, string:'{}argumentList'; 261, identifier:format; 262, argument_list; 262, 263; 263, identifier:ns; 264, for_statement; 264, 265; 264, 266; 264, 267; 265, identifier:argList; 266, identifier:argLists; 267, block; 267, 268; 267, 282; 267, 286; 267, 290; 267, 371; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 271; 270, identifier:args_iter; 271, call; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:argList; 274, identifier:findall; 275, argument_list; 275, 276; 276, call; 276, 277; 276, 280; 277, attribute; 277, 278; 277, 279; 278, string:'{}argument'; 279, identifier:format; 280, argument_list; 280, 281; 281, identifier:ns; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:in_args; 285, list:[]; 286, expression_statement; 286, 287; 287, assignment; 287, 288; 287, 289; 288, identifier:out_args; 289, list:[]; 290, for_statement; 290, 291; 290, 292; 290, 293; 291, identifier:arg; 292, identifier:args_iter; 293, block; 293, 294; 293, 308; 293, 322; 293, 336; 293, 342; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 297; 296, identifier:arg_name; 297, call; 297, 298; 297, 301; 298, attribute; 298, 299; 298, 300; 299, identifier:arg; 300, identifier:findtext; 301, argument_list; 301, 302; 302, call; 302, 303; 302, 306; 303, attribute; 303, 304; 303, 305; 304, string:'{}name'; 305, identifier:format; 306, argument_list; 306, 307; 307, identifier:ns; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:direction; 311, call; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:arg; 314, identifier:findtext; 315, argument_list; 315, 316; 316, call; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, string:'{}direction'; 319, identifier:format; 320, argument_list; 320, 321; 321, identifier:ns; 322, expression_statement; 322, 323; 323, assignment; 323, 324; 323, 325; 324, identifier:related_variable; 325, call; 325, 326; 325, 329; 326, attribute; 326, 327; 326, 328; 327, identifier:arg; 328, identifier:findtext; 329, argument_list; 329, 330; 330, call; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, string:'{}relatedStateVariable'; 333, identifier:format; 334, argument_list; 334, 335; 335, identifier:ns; 336, expression_statement; 336, 337; 337, assignment; 337, 338; 337, 339; 338, identifier:vartype; 339, subscript; 339, 340; 339, 341; 340, identifier:vartypes; 341, identifier:related_variable; 342, if_statement; 342, 343; 342, 346; 342, 358; 343, comparison_operator:==; 343, 344; 343, 345; 344, identifier:direction; 345, string:"in"; 346, block; 346, 347; 347, expression_statement; 347, 348; 348, call; 348, 349; 348, 352; 349, attribute; 349, 350; 349, 351; 350, identifier:in_args; 351, identifier:append; 352, argument_list; 352, 353; 353, call; 353, 354; 353, 355; 354, identifier:Argument; 355, argument_list; 355, 356; 355, 357; 356, identifier:arg_name; 357, identifier:vartype; 358, else_clause; 358, 359; 359, block; 359, 360; 360, expression_statement; 360, 361; 361, call; 361, 362; 361, 365; 362, attribute; 362, 363; 362, 364; 363, identifier:out_args; 364, identifier:append; 365, argument_list; 365, 366; 366, call; 366, 367; 366, 368; 367, identifier:Argument; 368, argument_list; 368, 369; 368, 370; 369, identifier:arg_name; 370, identifier:vartype; 371, expression_statement; 371, 372; 372, yield; 372, 373; 373, call; 373, 374; 373, 375; 374, identifier:Action; 375, argument_list; 375, 376; 375, 377; 375, 378; 376, identifier:action_name; 377, identifier:in_args; 378, identifier:out_args | def iter_actions(self):
ns = '{urn:schemas-upnp-org:service-1-0}'
scpd_body = requests.get(self.base_url + self.scpd_url).content
tree = XML.fromstring(scpd_body)
vartypes = {}
srvStateTables = tree.findall('{}serviceStateTable'.format(ns))
for srvStateTable in srvStateTables:
statevars = srvStateTable.findall('{}stateVariable'.format(ns))
for state in statevars:
name = state.findtext('{}name'.format(ns))
datatype = state.findtext('{}dataType'.format(ns))
default = state.findtext('{}defaultValue'.format(ns))
value_list_elt = state.find('{}allowedValueList'.format(ns))
if value_list_elt is None:
value_list_elt = ()
value_list = [item.text for item in value_list_elt] or None
value_range_elt = state.find('{}allowedValueRange'.format(ns))
if value_range_elt is None:
value_range_elt = ()
value_range = [item.text for item in value_range_elt] or None
vartypes[name] = Vartype(datatype, default, value_list,
value_range)
actionLists = tree.findall('{}actionList'.format(ns))
for actionList in actionLists:
actions = actionList.findall('{}action'.format(ns))
for i in actions:
action_name = i.findtext('{}name'.format(ns))
argLists = i.findall('{}argumentList'.format(ns))
for argList in argLists:
args_iter = argList.findall('{}argument'.format(ns))
in_args = []
out_args = []
for arg in args_iter:
arg_name = arg.findtext('{}name'.format(ns))
direction = arg.findtext('{}direction'.format(ns))
related_variable = arg.findtext(
'{}relatedStateVariable'.format(ns))
vartype = vartypes[related_variable]
if direction == "in":
in_args.append(Argument(arg_name, vartype))
else:
out_args.append(Argument(arg_name, vartype))
yield Action(action_name, in_args, out_args) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_event_xml; 3, parameters; 3, 4; 4, identifier:xml_event; 5, block; 5, 6; 5, 10; 5, 19; 5, 28; 5, 280; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, dictionary; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:tree; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:XML; 16, identifier:fromstring; 17, argument_list; 17, 18; 18, identifier:xml_event; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:properties; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:tree; 25, identifier:findall; 26, argument_list; 26, 27; 27, string:'{urn:schemas-upnp-org:event-1-0}property'; 28, for_statement; 28, 29; 28, 30; 28, 31; 29, identifier:prop; 30, identifier:properties; 31, block; 31, 32; 32, for_statement; 32, 33; 32, 34; 32, 35; 33, identifier:variable; 34, identifier:prop; 35, block; 35, 36; 36, if_statement; 36, 37; 36, 42; 36, 265; 37, comparison_operator:==; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:variable; 40, identifier:tag; 41, string:"LastChange"; 42, block; 42, 43; 42, 59; 42, 68; 42, 82; 42, 96; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:last_change_tree; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:XML; 49, identifier:fromstring; 50, argument_list; 50, 51; 51, call; 51, 52; 51, 57; 52, attribute; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:variable; 55, identifier:text; 56, identifier:encode; 57, argument_list; 57, 58; 58, string:'utf-8'; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:instance; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:last_change_tree; 65, identifier:find; 66, argument_list; 66, 67; 67, string:"{urn:schemas-upnp-org:metadata-1-0/AVT/}InstanceID"; 68, if_statement; 68, 69; 68, 72; 69, comparison_operator:is; 69, 70; 69, 71; 70, identifier:instance; 71, None; 72, block; 72, 73; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:instance; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:last_change_tree; 79, identifier:find; 80, argument_list; 80, 81; 81, string:"{urn:schemas-upnp-org:metadata-1-0/RCS/}InstanceID"; 82, if_statement; 82, 83; 82, 86; 83, comparison_operator:is; 83, 84; 83, 85; 84, identifier:instance; 85, None; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:instance; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:last_change_tree; 93, identifier:find; 94, argument_list; 94, 95; 95, string:"{urn:schemas-sonos-com:metadata-1-0/Queue/}QueueID"; 96, for_statement; 96, 97; 96, 98; 96, 99; 97, identifier:last_change_var; 98, identifier:instance; 99, block; 99, 100; 99, 106; 99, 126; 99, 133; 99, 142; 99, 153; 99, 219; 99, 228; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:tag; 103, attribute; 103, 104; 103, 105; 104, identifier:last_change_var; 105, identifier:tag; 106, if_statement; 106, 107; 106, 113; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:tag; 110, identifier:startswith; 111, argument_list; 111, 112; 112, string:'{'; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:tag; 117, subscript; 117, 118; 117, 125; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:tag; 121, identifier:split; 122, argument_list; 122, 123; 122, 124; 123, string:'}'; 124, integer:1; 125, integer:1; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:tag; 129, call; 129, 130; 129, 131; 130, identifier:camel_to_underscore; 131, argument_list; 131, 132; 132, identifier:tag; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:value; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:last_change_var; 139, identifier:get; 140, argument_list; 140, 141; 141, string:'val'; 142, if_statement; 142, 143; 142, 146; 143, comparison_operator:is; 143, 144; 143, 145; 144, identifier:value; 145, None; 146, block; 146, 147; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:value; 150, attribute; 150, 151; 150, 152; 151, identifier:last_change_var; 152, identifier:text; 153, if_statement; 153, 154; 153, 160; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:value; 157, identifier:startswith; 158, argument_list; 158, 159; 159, string:'<DIDL-Lite'; 160, block; 160, 161; 161, try_statement; 161, 162; 161, 181; 162, block; 162, 163; 162, 170; 162, 175; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:didl; 166, call; 166, 167; 166, 168; 167, identifier:from_didl_string; 168, argument_list; 168, 169; 169, identifier:value; 170, if_statement; 170, 171; 170, 173; 171, not_operator; 171, 172; 172, identifier:didl; 173, block; 173, 174; 174, continue_statement; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:value; 178, subscript; 178, 179; 178, 180; 179, identifier:didl; 180, integer:0; 181, except_clause; 181, 182; 181, 186; 182, as_pattern; 182, 183; 182, 184; 183, identifier:SoCoException; 184, as_pattern_target; 184, 185; 185, identifier:original_exception; 186, block; 186, 187; 186, 203; 186, 212; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:log; 191, identifier:debug; 192, argument_list; 192, 193; 192, 198; 192, 199; 193, concatenated_string; 193, 194; 193, 195; 193, 196; 193, 197; 194, string:"Event contains illegal metadata"; 195, string:"for '%s'.\n"; 196, string:"Error message: '%s'\n"; 197, string:"The result will be a SoCoFault."; 198, identifier:tag; 199, call; 199, 200; 199, 201; 200, identifier:str; 201, argument_list; 201, 202; 202, identifier:original_exception; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:event_parse_exception; 206, call; 206, 207; 206, 208; 207, identifier:EventParseException; 208, argument_list; 208, 209; 208, 210; 208, 211; 209, identifier:tag; 210, identifier:value; 211, identifier:original_exception; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:value; 215, call; 215, 216; 215, 217; 216, identifier:SoCoFault; 217, argument_list; 217, 218; 218, identifier:event_parse_exception; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 222; 221, identifier:channel; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:last_change_var; 225, identifier:get; 226, argument_list; 226, 227; 227, string:'channel'; 228, if_statement; 228, 229; 228, 232; 228, 257; 229, comparison_operator:is; 229, 230; 229, 231; 230, identifier:channel; 231, None; 232, block; 232, 233; 232, 249; 233, if_statement; 233, 234; 233, 242; 234, comparison_operator:is; 234, 235; 234, 241; 235, call; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:result; 238, identifier:get; 239, argument_list; 239, 240; 240, identifier:tag; 241, None; 242, block; 242, 243; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 248; 245, subscript; 245, 246; 245, 247; 246, identifier:result; 247, identifier:tag; 248, dictionary; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 256; 251, subscript; 251, 252; 251, 255; 252, subscript; 252, 253; 252, 254; 253, identifier:result; 254, identifier:tag; 255, identifier:channel; 256, identifier:value; 257, else_clause; 257, 258; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 264; 261, subscript; 261, 262; 261, 263; 262, identifier:result; 263, identifier:tag; 264, identifier:value; 265, else_clause; 265, 266; 266, block; 266, 267; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 277; 269, subscript; 269, 270; 269, 271; 270, identifier:result; 271, call; 271, 272; 271, 273; 272, identifier:camel_to_underscore; 273, argument_list; 273, 274; 274, attribute; 274, 275; 274, 276; 275, identifier:variable; 276, identifier:tag; 277, attribute; 277, 278; 277, 279; 278, identifier:variable; 279, identifier:text; 280, return_statement; 280, 281; 281, identifier:result | def parse_event_xml(xml_event):
result = {}
tree = XML.fromstring(xml_event)
properties = tree.findall(
'{urn:schemas-upnp-org:event-1-0}property')
for prop in properties:
for variable in prop:
if variable.tag == "LastChange":
last_change_tree = XML.fromstring(
variable.text.encode('utf-8'))
instance = last_change_tree.find(
"{urn:schemas-upnp-org:metadata-1-0/AVT/}InstanceID")
if instance is None:
instance = last_change_tree.find(
"{urn:schemas-upnp-org:metadata-1-0/RCS/}InstanceID")
if instance is None:
instance = last_change_tree.find(
"{urn:schemas-sonos-com:metadata-1-0/Queue/}QueueID")
for last_change_var in instance:
tag = last_change_var.tag
if tag.startswith('{'):
tag = tag.split('}', 1)[1]
tag = camel_to_underscore(tag)
value = last_change_var.get('val')
if value is None:
value = last_change_var.text
if value.startswith('<DIDL-Lite'):
try:
didl = from_didl_string(value)
if not didl:
continue
value = didl[0]
except SoCoException as original_exception:
log.debug("Event contains illegal metadata"
"for '%s'.\n"
"Error message: '%s'\n"
"The result will be a SoCoFault.",
tag, str(original_exception))
event_parse_exception = EventParseException(
tag, value, original_exception
)
value = SoCoFault(event_parse_exception)
channel = last_change_var.get('channel')
if channel is not None:
if result.get(tag) is None:
result[tag] = {}
result[tag][channel] = value
else:
result[tag] = value
else:
result[camel_to_underscore(variable.tag)] = variable.text
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_restore_coordinator; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 36; 5, 42; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:transport_info; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:device; 14, identifier:get_current_transport_info; 15, argument_list; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:is; 17, 18; 17, 19; 18, identifier:transport_info; 19, None; 20, block; 20, 21; 21, if_statement; 21, 22; 21, 27; 22, comparison_operator:==; 22, 23; 22, 26; 23, subscript; 23, 24; 23, 25; 24, identifier:transport_info; 25, string:'current_transport_state'; 26, string:'PLAYING'; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, call; 29, 30; 29, 35; 30, attribute; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:device; 34, identifier:pause; 35, argument_list; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:_restore_queue; 41, argument_list; 42, if_statement; 42, 43; 42, 52; 42, 123; 42, 129; 43, boolean_operator:and; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:is_playing_queue; 47, comparison_operator:>; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:playlist_position; 51, integer:0; 52, block; 52, 53; 52, 78; 52, 103; 52, 113; 53, if_statement; 53, 54; 53, 59; 54, comparison_operator:is; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:playlist_position; 58, None; 59, block; 59, 60; 59, 66; 60, expression_statement; 60, 61; 61, augmented_assignment:-=; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:playlist_position; 65, integer:1; 66, expression_statement; 66, 67; 67, call; 67, 68; 67, 73; 68, attribute; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:device; 72, identifier:play_from_queue; 73, argument_list; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:self; 76, identifier:playlist_position; 77, False; 78, if_statement; 78, 79; 78, 84; 79, comparison_operator:is; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:track_position; 83, None; 84, block; 84, 85; 85, if_statement; 85, 86; 85, 91; 86, comparison_operator:!=; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:track_position; 90, string:""; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, call; 93, 94; 93, 99; 94, attribute; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:device; 98, identifier:seek; 99, argument_list; 99, 100; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:track_position; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 110; 105, attribute; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:device; 109, identifier:play_mode; 110, attribute; 110, 111; 110, 112; 111, identifier:self; 112, identifier:play_mode; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 120; 115, attribute; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:device; 119, identifier:cross_fade; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:cross_fade; 123, elif_clause; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:is_playing_cloud_queue; 127, block; 127, 128; 128, pass_statement; 129, else_clause; 129, 130; 130, block; 130, 131; 131, if_statement; 131, 132; 131, 137; 132, comparison_operator:!=; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:media_uri; 136, string:""; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, call; 139, 140; 139, 145; 140, attribute; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:device; 144, identifier:play_uri; 145, argument_list; 145, 146; 145, 149; 145, 152; 146, attribute; 146, 147; 146, 148; 147, identifier:self; 148, identifier:media_uri; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:media_metadata; 152, keyword_argument; 152, 153; 152, 154; 153, identifier:start; 154, False | def _restore_coordinator(self):
transport_info = self.device.get_current_transport_info()
if transport_info is not None:
if transport_info['current_transport_state'] == 'PLAYING':
self.device.pause()
self._restore_queue()
if self.is_playing_queue and self.playlist_position > 0:
if self.playlist_position is not None:
self.playlist_position -= 1
self.device.play_from_queue(self.playlist_position, False)
if self.track_position is not None:
if self.track_position != "":
self.device.seek(self.track_position)
self.device.play_mode = self.play_mode
self.device.cross_fade = self.cross_fade
elif self.is_playing_cloud_queue:
pass
else:
if self.media_uri != "":
self.device.play_uri(
self.media_uri, self.media_metadata, start=False) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_loading_order; 3, parameters; 3, 4; 4, identifier:step_files; 5, block; 5, 6; 5, 10; 5, 14; 5, 18; 5, 121; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:tools; 9, list:[]; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:workflows; 13, list:[]; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:workflows_with_subworkflows; 17, list:[]; 18, for_statement; 18, 19; 18, 20; 18, 21; 19, identifier:f; 20, identifier:step_files; 21, block; 21, 22; 22, if_statement; 22, 23; 22, 36; 22, 44; 23, boolean_operator:or; 23, 24; 23, 30; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:f; 27, identifier:startswith; 28, argument_list; 28, 29; 29, string:'http://'; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:f; 33, identifier:startswith; 34, argument_list; 34, 35; 35, string:'https://'; 36, block; 36, 37; 37, expression_statement; 37, 38; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:tools; 41, identifier:append; 42, argument_list; 42, 43; 43, identifier:f; 44, else_clause; 44, 45; 45, block; 45, 46; 45, 53; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:obj; 49, call; 49, 50; 49, 51; 50, identifier:load_yaml; 51, argument_list; 51, 52; 52, identifier:f; 53, if_statement; 53, 54; 53, 63; 53, 112; 54, comparison_operator:==; 54, 55; 54, 62; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:obj; 58, identifier:get; 59, argument_list; 59, 60; 59, 61; 60, string:'class'; 61, string:''; 62, string:'Workflow'; 63, block; 63, 64; 64, if_statement; 64, 65; 64, 72; 64, 103; 65, comparison_operator:in; 65, 66; 65, 67; 66, string:'requirements'; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:obj; 70, identifier:keys; 71, argument_list; 72, block; 72, 73; 72, 80; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:subw; 76, dictionary; 76, 77; 77, pair; 77, 78; 77, 79; 78, string:'class'; 79, string:'SubworkflowFeatureRequirement'; 80, if_statement; 80, 81; 80, 86; 80, 94; 81, comparison_operator:in; 81, 82; 81, 83; 82, identifier:subw; 83, subscript; 83, 84; 83, 85; 84, identifier:obj; 85, string:'requirements'; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:workflows_with_subworkflows; 91, identifier:append; 92, argument_list; 92, 93; 93, identifier:f; 94, else_clause; 94, 95; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:workflows; 100, identifier:append; 101, argument_list; 101, 102; 102, identifier:f; 103, else_clause; 103, 104; 104, block; 104, 105; 105, expression_statement; 105, 106; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:workflows; 109, identifier:append; 110, argument_list; 110, 111; 111, identifier:f; 112, else_clause; 112, 113; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:tools; 118, identifier:append; 119, argument_list; 119, 120; 120, identifier:f; 121, return_statement; 121, 122; 122, binary_operator:+; 122, 123; 122, 126; 123, binary_operator:+; 123, 124; 123, 125; 124, identifier:tools; 125, identifier:workflows; 126, identifier:workflows_with_subworkflows | def sort_loading_order(step_files):
tools = []
workflows = []
workflows_with_subworkflows = []
for f in step_files:
if f.startswith('http://') or f.startswith('https://'):
tools.append(f)
else:
obj = load_yaml(f)
if obj.get('class', '') == 'Workflow':
if 'requirements' in obj.keys():
subw = {'class': 'SubworkflowFeatureRequirement'}
if subw in obj['requirements']:
workflows_with_subworkflows.append(f)
else:
workflows.append(f)
else:
workflows.append(f)
else:
tools.append(f)
return tools + workflows + workflows_with_subworkflows |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:add_input; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 14; 7, 53; 7, 57; 7, 63; 7, 79; 7, 95; 7, 109; 7, 118; 7, 205; 7, 211; 7, 228; 7, 241; 7, 265; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:_closed; 13, argument_list; 14, function_definition; 14, 15; 14, 16; 14, 18; 15, function_name:_get_item; 16, parameters; 16, 17; 17, identifier:args; 18, block; 18, 19; 18, 28; 18, 36; 18, 51; 19, if_statement; 19, 20; 19, 22; 20, not_operator; 20, 21; 21, identifier:args; 22, block; 22, 23; 23, raise_statement; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:ValueError; 26, argument_list; 26, 27; 27, string:"No parameter specified."; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:item; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:args; 34, identifier:popitem; 35, argument_list; 36, if_statement; 36, 37; 36, 38; 37, identifier:args; 38, block; 38, 39; 39, raise_statement; 39, 40; 40, call; 40, 41; 40, 42; 41, identifier:ValueError; 42, argument_list; 42, 43; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, concatenated_string; 45, 46; 45, 47; 46, string:"Too many parameters, not clear what to do "; 47, string:"with {}"; 48, identifier:format; 49, argument_list; 49, 50; 50, identifier:kwargs; 51, return_statement; 51, 52; 52, identifier:item; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:symbols; 56, None; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:input_dict; 60, call; 60, 61; 60, 62; 61, identifier:CommentedMap; 62, argument_list; 63, if_statement; 63, 64; 63, 67; 64, comparison_operator:in; 64, 65; 64, 66; 65, string:'default'; 66, identifier:kwargs; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 73; 70, subscript; 70, 71; 70, 72; 71, identifier:input_dict; 72, string:'default'; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:kwargs; 76, identifier:pop; 77, argument_list; 77, 78; 78, string:'default'; 79, if_statement; 79, 80; 79, 83; 80, comparison_operator:in; 80, 81; 80, 82; 81, string:'label'; 82, identifier:kwargs; 83, block; 83, 84; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 89; 86, subscript; 86, 87; 86, 88; 87, identifier:input_dict; 88, string:'label'; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:kwargs; 92, identifier:pop; 93, argument_list; 93, 94; 94, string:'label'; 95, if_statement; 95, 96; 95, 99; 96, comparison_operator:in; 96, 97; 96, 98; 97, string:'symbols'; 98, identifier:kwargs; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:symbols; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:kwargs; 106, identifier:pop; 107, argument_list; 107, 108; 108, string:'symbols'; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 114; 111, pattern_list; 111, 112; 111, 113; 112, identifier:name; 113, identifier:input_type; 114, call; 114, 115; 114, 116; 115, identifier:_get_item; 116, argument_list; 116, 117; 117, identifier:kwargs; 118, if_statement; 118, 119; 118, 122; 118, 191; 119, comparison_operator:==; 119, 120; 119, 121; 120, identifier:input_type; 121, string:'enum'; 122, block; 122, 123; 122, 129; 122, 135; 122, 145; 122, 155; 122, 168; 122, 179; 122, 185; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:typ; 126, call; 126, 127; 126, 128; 127, identifier:CommentedMap; 128, argument_list; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 134; 131, subscript; 131, 132; 131, 133; 132, identifier:typ; 133, string:'type'; 134, string:'enum'; 135, if_statement; 135, 136; 135, 139; 136, comparison_operator:is; 136, 137; 136, 138; 137, identifier:symbols; 138, None; 139, block; 139, 140; 140, raise_statement; 140, 141; 141, call; 141, 142; 141, 143; 142, identifier:ValueError; 143, argument_list; 143, 144; 144, string:"Please specify the enum's symbols."; 145, if_statement; 145, 146; 145, 149; 146, comparison_operator:==; 146, 147; 146, 148; 147, identifier:symbols; 148, list:[]; 149, block; 149, 150; 150, raise_statement; 150, 151; 151, call; 151, 152; 151, 153; 152, identifier:ValueError; 153, argument_list; 153, 154; 154, string:"The enum's symbols cannot be empty."; 155, if_statement; 155, 156; 155, 162; 156, comparison_operator:!=; 156, 157; 156, 161; 157, call; 157, 158; 157, 159; 158, identifier:type; 159, argument_list; 159, 160; 160, identifier:symbols; 161, identifier:list; 162, block; 162, 163; 163, raise_statement; 163, 164; 164, call; 164, 165; 164, 166; 165, identifier:ValueError; 166, argument_list; 166, 167; 167, string:'Symbols should be a list.'; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:symbols; 171, list_comprehension; 171, 172; 171, 176; 172, call; 172, 173; 172, 174; 173, identifier:str; 174, argument_list; 174, 175; 175, identifier:s; 176, for_in_clause; 176, 177; 176, 178; 177, identifier:s; 178, identifier:symbols; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 184; 181, subscript; 181, 182; 181, 183; 182, identifier:typ; 183, string:'symbols'; 184, identifier:symbols; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 190; 187, subscript; 187, 188; 187, 189; 188, identifier:input_dict; 189, string:'type'; 190, identifier:typ; 191, else_clause; 191, 192; 192, block; 192, 193; 193, if_statement; 193, 194; 193, 198; 194, call; 194, 195; 194, 196; 195, identifier:bool; 196, argument_list; 196, 197; 197, identifier:input_dict; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 204; 201, subscript; 201, 202; 201, 203; 202, identifier:input_dict; 203, string:'type'; 204, identifier:input_type; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:msg; 208, binary_operator:+; 208, 209; 208, 210; 209, string:'"{}" is already used as a workflow input. Please use a '; 210, string:'different name.'; 211, if_statement; 211, 212; 211, 217; 212, comparison_operator:in; 212, 213; 212, 214; 213, identifier:name; 214, attribute; 214, 215; 214, 216; 215, identifier:self; 216, identifier:wf_inputs; 217, block; 217, 218; 218, raise_statement; 218, 219; 219, call; 219, 220; 219, 221; 220, identifier:ValueError; 221, argument_list; 221, 222; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:msg; 225, identifier:format; 226, argument_list; 226, 227; 227, identifier:name; 228, if_statement; 228, 229; 228, 234; 229, call; 229, 230; 229, 231; 230, identifier:isinstance; 231, argument_list; 231, 232; 231, 233; 232, identifier:input_type; 233, identifier:dict; 234, block; 234, 235; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 240; 237, subscript; 237, 238; 237, 239; 238, identifier:input_dict; 239, string:'type'; 240, identifier:input_type; 241, if_statement; 241, 242; 241, 246; 241, 255; 242, call; 242, 243; 242, 244; 243, identifier:bool; 244, argument_list; 244, 245; 245, identifier:input_dict; 246, block; 246, 247; 247, expression_statement; 247, 248; 248, assignment; 248, 249; 248, 254; 249, subscript; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:self; 252, identifier:wf_inputs; 253, identifier:name; 254, identifier:input_dict; 255, else_clause; 255, 256; 256, block; 256, 257; 257, expression_statement; 257, 258; 258, assignment; 258, 259; 258, 264; 259, subscript; 259, 260; 259, 263; 260, attribute; 260, 261; 260, 262; 261, identifier:self; 262, identifier:wf_inputs; 263, identifier:name; 264, identifier:input_type; 265, return_statement; 265, 266; 266, call; 266, 267; 266, 268; 267, identifier:Reference; 268, argument_list; 268, 269; 269, keyword_argument; 269, 270; 269, 271; 270, identifier:input_name; 271, identifier:name | def add_input(self, **kwargs):
self._closed()
def _get_item(args):
if not args:
raise ValueError("No parameter specified.")
item = args.popitem()
if args:
raise ValueError("Too many parameters, not clear what to do "
"with {}".format(kwargs))
return item
symbols = None
input_dict = CommentedMap()
if 'default' in kwargs:
input_dict['default'] = kwargs.pop('default')
if 'label' in kwargs:
input_dict['label'] = kwargs.pop('label')
if 'symbols' in kwargs:
symbols = kwargs.pop('symbols')
name, input_type = _get_item(kwargs)
if input_type == 'enum':
typ = CommentedMap()
typ['type'] = 'enum'
if symbols is None:
raise ValueError("Please specify the enum's symbols.")
if symbols == []:
raise ValueError("The enum's symbols cannot be empty.")
if type(symbols) != list:
raise ValueError('Symbols should be a list.')
symbols = [str(s) for s in symbols]
typ['symbols'] = symbols
input_dict['type'] = typ
else:
if bool(input_dict):
input_dict['type'] = input_type
msg = '"{}" is already used as a workflow input. Please use a ' +\
'different name.'
if name in self.wf_inputs:
raise ValueError(msg.format(name))
if isinstance(input_type, dict):
input_dict['type'] = input_type
if bool(input_dict):
self.wf_inputs[name] = input_dict
else:
self.wf_inputs[name] = input_type
return Reference(input_name=name) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:to_obj; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wd; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:pack; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, identifier:relpath; 13, None; 14, block; 14, 15; 14, 21; 14, 27; 14, 33; 14, 39; 14, 55; 14, 71; 14, 84; 14, 101; 14, 118; 14, 135; 14, 143; 14, 151; 14, 157; 14, 186; 14, 192; 15, expression_statement; 15, 16; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:_closed; 20, argument_list; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:obj; 24, call; 24, 25; 24, 26; 25, identifier:CommentedMap; 26, argument_list; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 32; 29, subscript; 29, 30; 29, 31; 30, identifier:obj; 31, string:'cwlVersion'; 32, string:'v1.0'; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 38; 35, subscript; 35, 36; 35, 37; 36, identifier:obj; 37, string:'class'; 38, string:'Workflow'; 39, try_statement; 39, 40; 39, 49; 40, block; 40, 41; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 46; 43, subscript; 43, 44; 43, 45; 44, identifier:obj; 45, string:'doc'; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:documentation; 49, except_clause; 49, 50; 49, 53; 50, tuple; 50, 51; 50, 52; 51, identifier:AttributeError; 52, identifier:ValueError; 53, block; 53, 54; 54, pass_statement; 55, try_statement; 55, 56; 55, 65; 56, block; 56, 57; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 62; 59, subscript; 59, 60; 59, 61; 60, identifier:obj; 61, string:'label'; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:label; 65, except_clause; 65, 66; 65, 69; 66, tuple; 66, 67; 66, 68; 67, identifier:AttributeError; 68, identifier:ValueError; 69, block; 69, 70; 70, pass_statement; 71, if_statement; 71, 72; 71, 77; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:_has_requirements; 76, argument_list; 77, block; 77, 78; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 83; 80, subscript; 80, 81; 80, 82; 81, identifier:obj; 82, string:'requirements'; 83, list:[]; 84, if_statement; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:has_workflow_step; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, call; 90, 91; 90, 96; 91, attribute; 91, 92; 91, 95; 92, subscript; 92, 93; 92, 94; 93, identifier:obj; 94, string:'requirements'; 95, identifier:append; 96, argument_list; 96, 97; 97, dictionary; 97, 98; 98, pair; 98, 99; 98, 100; 99, string:'class'; 100, string:'SubworkflowFeatureRequirement'; 101, if_statement; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:has_scatter_requirement; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 113; 108, attribute; 108, 109; 108, 112; 109, subscript; 109, 110; 109, 111; 110, identifier:obj; 111, string:'requirements'; 112, identifier:append; 113, argument_list; 113, 114; 114, dictionary; 114, 115; 115, pair; 115, 116; 115, 117; 116, string:'class'; 117, string:'ScatterFeatureRequirement'; 118, if_statement; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:has_multiple_inputs; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 130; 125, attribute; 125, 126; 125, 129; 126, subscript; 126, 127; 126, 128; 127, identifier:obj; 128, string:'requirements'; 129, identifier:append; 130, argument_list; 130, 131; 131, dictionary; 131, 132; 132, pair; 132, 133; 132, 134; 133, string:'class'; 134, string:'MultipleInputFeatureRequirement'; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 140; 137, subscript; 137, 138; 137, 139; 138, identifier:obj; 139, string:'inputs'; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:wf_inputs; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, subscript; 145, 146; 145, 147; 146, identifier:obj; 147, string:'outputs'; 148, attribute; 148, 149; 148, 150; 149, identifier:self; 150, identifier:wf_outputs; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:steps_obj; 154, call; 154, 155; 154, 156; 155, identifier:CommentedMap; 156, argument_list; 157, for_statement; 157, 158; 157, 159; 157, 162; 158, identifier:key; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:wf_steps; 162, block; 162, 163; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 168; 165, subscript; 165, 166; 165, 167; 166, identifier:steps_obj; 167, identifier:key; 168, call; 168, 169; 168, 176; 169, attribute; 169, 170; 169, 175; 170, subscript; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:self; 173, identifier:wf_steps; 174, identifier:key; 175, identifier:to_obj; 176, argument_list; 176, 177; 176, 180; 176, 183; 177, keyword_argument; 177, 178; 177, 179; 178, identifier:relpath; 179, identifier:relpath; 180, keyword_argument; 180, 181; 180, 182; 181, identifier:pack; 182, identifier:pack; 183, keyword_argument; 183, 184; 183, 185; 184, identifier:wd; 185, identifier:wd; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 191; 188, subscript; 188, 189; 188, 190; 189, identifier:obj; 190, string:'steps'; 191, identifier:steps_obj; 192, return_statement; 192, 193; 193, identifier:obj | def to_obj(self, wd=False, pack=False, relpath=None):
self._closed()
obj = CommentedMap()
obj['cwlVersion'] = 'v1.0'
obj['class'] = 'Workflow'
try:
obj['doc'] = self.documentation
except (AttributeError, ValueError):
pass
try:
obj['label'] = self.label
except (AttributeError, ValueError):
pass
if self._has_requirements():
obj['requirements'] = []
if self.has_workflow_step:
obj['requirements'].append(
{'class': 'SubworkflowFeatureRequirement'})
if self.has_scatter_requirement:
obj['requirements'].append({'class': 'ScatterFeatureRequirement'})
if self.has_multiple_inputs:
obj['requirements'].append(
{'class': 'MultipleInputFeatureRequirement'})
obj['inputs'] = self.wf_inputs
obj['outputs'] = self.wf_outputs
steps_obj = CommentedMap()
for key in self.wf_steps:
steps_obj[key] = self.wf_steps[key].to_obj(relpath=relpath,
pack=pack,
wd=wd)
obj['steps'] = steps_obj
return obj |
0, module; 0, 1; 1, ERROR; 1, 2; 1, 21; 1, 22; 1, 26; 1, 30; 1, 62; 1, 86; 1, 90; 1, 174; 1, 178; 1, 208; 1, 226; 2, function_definition; 2, 3; 2, 4; 2, 9; 3, function_name:to_script; 4, parameters; 4, 5; 4, 6; 5, identifier:self; 6, default_parameter; 6, 7; 6, 8; 7, identifier:wf_name; 8, string:'wf'; 9, block; 9, 10; 9, 16; 9, 20; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:_closed; 15, argument_list; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:script; 19, list:[]; 20, comment; 21, ERROR; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:params; 25, list:[]; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:returns; 29, list:[]; 30, for_statement; 30, 31; 30, 34; 30, 41; 31, pattern_list; 31, 32; 31, 33; 32, identifier:name; 33, identifier:typ; 34, call; 34, 35; 34, 40; 35, attribute; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:wf_inputs; 39, identifier:items; 40, argument_list; 41, block; 41, 42; 41, 55; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:params; 46, identifier:append; 47, argument_list; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, string:'{}=\'{}\''; 51, identifier:format; 52, argument_list; 52, 53; 52, 54; 53, identifier:name; 54, identifier:typ; 55, expression_statement; 55, 56; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:returns; 59, identifier:append; 60, argument_list; 60, 61; 61, identifier:name; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:script; 66, identifier:append; 67, argument_list; 67, 68; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, string:'{} = {}.add_inputs({})'; 71, identifier:format; 72, argument_list; 72, 73; 72, 79; 72, 80; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, string:', '; 76, identifier:join; 77, argument_list; 77, 78; 78, identifier:returns; 79, identifier:wf_name; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, string:', '; 83, identifier:join; 84, argument_list; 84, 85; 85, identifier:params; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:returns; 89, list:[]; 90, for_statement; 90, 91; 90, 94; 90, 101; 91, pattern_list; 91, 92; 91, 93; 92, identifier:name; 93, identifier:step; 94, call; 94, 95; 94, 100; 95, attribute; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:self; 98, identifier:wf_steps; 99, identifier:items; 100, argument_list; 101, block; 101, 102; 101, 108; 101, 124; 101, 149; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:pyname; 105, attribute; 105, 106; 105, 107; 106, identifier:step; 107, identifier:python_name; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:returns; 111, list_comprehension; 111, 112; 111, 119; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, string:'{}_{}'; 115, identifier:format; 116, argument_list; 116, 117; 116, 118; 117, identifier:pyname; 118, identifier:o; 119, for_in_clause; 119, 120; 119, 121; 120, identifier:o; 121, subscript; 121, 122; 121, 123; 122, identifier:step; 123, string:'out'; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:params; 127, list_comprehension; 127, 128; 127, 138; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, string:'{}={}'; 131, identifier:format; 132, argument_list; 132, 133; 132, 134; 133, identifier:name; 134, call; 134, 135; 134, 136; 135, identifier:python_name; 136, argument_list; 136, 137; 137, identifier:param; 138, for_in_clause; 138, 139; 138, 142; 139, pattern_list; 139, 140; 139, 141; 140, identifier:name; 141, identifier:param; 142, call; 142, 143; 142, 148; 143, attribute; 143, 144; 143, 147; 144, subscript; 144, 145; 144, 146; 145, identifier:step; 146, string:'in'; 147, identifier:items; 148, argument_list; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:script; 153, identifier:append; 154, argument_list; 154, 155; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, string:'{} = {}.{}({})'; 158, identifier:format; 159, argument_list; 159, 160; 159, 166; 159, 167; 159, 168; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, string:', '; 163, identifier:join; 164, argument_list; 164, 165; 165, identifier:returns; 166, identifier:wf_name; 167, identifier:pyname; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, string:', '; 171, identifier:join; 172, argument_list; 172, 173; 173, identifier:params; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:params; 177, list:[]; 178, for_statement; 178, 179; 178, 182; 178, 189; 179, pattern_list; 179, 180; 179, 181; 180, identifier:name; 181, identifier:details; 182, call; 182, 183; 182, 188; 183, attribute; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:self; 186, identifier:wf_outputs; 187, identifier:items; 188, argument_list; 189, block; 189, 190; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:params; 194, identifier:append; 195, argument_list; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, string:'{}={}'; 199, identifier:format; 200, argument_list; 200, 201; 200, 202; 201, identifier:name; 202, call; 202, 203; 202, 204; 203, identifier:python_name; 204, argument_list; 204, 205; 205, subscript; 205, 206; 205, 207; 206, identifier:details; 207, string:'outputSource'; 208, expression_statement; 208, 209; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:script; 212, identifier:append; 213, argument_list; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, string:'{}.add_outputs({})'; 217, identifier:format; 218, argument_list; 218, 219; 218, 220; 219, identifier:wf_name; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, string:', '; 223, identifier:join; 224, argument_list; 224, 225; 225, identifier:params; 226, return_statement; 226, 227; 227, call; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, string:'\n'; 230, identifier:join; 231, argument_list; 231, 232; 232, identifier:script | def to_script(self, wf_name='wf'):
self._closed()
script = []
# print('doc =
')
params = []
returns = []
for name, typ in self.wf_inputs.items():
params.append('{}=\'{}\''.format(name, typ))
returns.append(name)
script.append('{} = {}.add_inputs({})'.format(
', '.join(returns), wf_name, ', '.join(params)))
returns = []
for name, step in self.wf_steps.items():
pyname = step.python_name
returns = ['{}_{}'.format(pyname, o) for o in step['out']]
params = ['{}={}'.format(name, python_name(param))
for name, param in step['in'].items()]
script.append('{} = {}.{}({})'.format(
', '.join(returns), wf_name, pyname, ', '.join(params)))
params = []
for name, details in self.wf_outputs.items():
params.append('{}={}'.format(
name, python_name(details['outputSource'])))
script.append('{}.add_outputs({})'.format(wf_name, ', '.join(params)))
return '\n'.join(script) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:save; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 4, identifier:self; 5, identifier:fname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:mode; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:validate; 11, True; 12, default_parameter; 12, 13; 12, 14; 13, identifier:encoding; 14, string:'utf-8'; 15, default_parameter; 15, 16; 15, 17; 16, identifier:wd; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:inline; 20, False; 21, default_parameter; 21, 22; 21, 23; 22, identifier:relative; 23, False; 24, default_parameter; 24, 25; 24, 26; 25, identifier:pack; 26, False; 27, block; 27, 28; 27, 34; 27, 85; 27, 94; 27, 120; 27, 129; 27, 147; 27, 165; 27, 189; 27, 217; 27, 241; 27, 254; 28, expression_statement; 28, 29; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:_closed; 33, argument_list; 34, if_statement; 34, 35; 34, 38; 35, comparison_operator:is; 35, 36; 35, 37; 36, identifier:mode; 37, None; 38, block; 38, 39; 38, 43; 38, 64; 38, 77; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:mode; 42, string:'abs'; 43, if_statement; 43, 44; 43, 45; 43, 50; 43, 57; 44, identifier:pack; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:mode; 49, string:'pack'; 50, elif_clause; 50, 51; 50, 52; 51, identifier:wd; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:mode; 56, string:'wd'; 57, elif_clause; 57, 58; 57, 59; 58, identifier:relative; 59, block; 59, 60; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:mode; 63, string:'rel'; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:msg; 67, call; 67, 68; 67, 74; 68, attribute; 68, 69; 68, 73; 69, concatenated_string; 69, 70; 69, 71; 69, 72; 70, string:'Using deprecated save method. Please save the workflow '; 71, string:'with: wf.save(\'{}\', mode=\'{}\'). Redirecting to new '; 72, string:'save method.'; 73, identifier:format; 74, argument_list; 74, 75; 74, 76; 75, identifier:fname; 76, identifier:mode; 77, expression_statement; 77, 78; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:warnings; 81, identifier:warn; 82, argument_list; 82, 83; 82, 84; 83, identifier:msg; 84, identifier:DeprecationWarning; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:modes; 88, tuple; 88, 89; 88, 90; 88, 91; 88, 92; 88, 93; 89, string:'rel'; 90, string:'abs'; 91, string:'wd'; 92, string:'inline'; 93, string:'pack'; 94, if_statement; 94, 95; 94, 98; 95, comparison_operator:not; 95, 96; 95, 97; 96, identifier:mode; 97, identifier:modes; 98, block; 98, 99; 98, 115; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:msg; 102, call; 102, 103; 102, 107; 103, attribute; 103, 104; 103, 105; 103, 106; 104, string:'Illegal mode "{}". Choose one of ({}).'; 105, line_continuation:\; 106, identifier:format; 107, argument_list; 107, 108; 107, 109; 108, identifier:mode; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, string:','; 112, identifier:join; 113, argument_list; 113, 114; 114, identifier:modes; 115, raise_statement; 115, 116; 116, call; 116, 117; 116, 118; 117, identifier:ValueError; 118, argument_list; 118, 119; 119, identifier:msg; 120, if_statement; 120, 121; 120, 122; 121, identifier:validate; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:self; 127, identifier:validate; 128, argument_list; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:dirname; 132, call; 132, 133; 132, 138; 133, attribute; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:os; 136, identifier:path; 137, identifier:dirname; 138, argument_list; 138, 139; 139, call; 139, 140; 139, 145; 140, attribute; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:os; 143, identifier:path; 144, identifier:abspath; 145, argument_list; 145, 146; 146, identifier:fname; 147, if_statement; 147, 148; 147, 157; 148, not_operator; 148, 149; 149, call; 149, 150; 149, 155; 150, attribute; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:os; 153, identifier:path; 154, identifier:exists; 155, argument_list; 155, 156; 156, identifier:dirname; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:os; 162, identifier:makedirs; 163, argument_list; 163, 164; 164, identifier:dirname; 165, if_statement; 165, 166; 165, 169; 166, comparison_operator:==; 166, 167; 166, 168; 167, identifier:mode; 168, string:'inline'; 169, block; 169, 170; 169, 177; 169, 185; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 173; 172, identifier:msg; 173, parenthesized_expression; 173, 174; 174, concatenated_string; 174, 175; 174, 176; 175, string:'Inline saving is deprecated. Please save the workflow '; 176, string:'using mode=\'pack\'. Setting mode to pack.'; 177, expression_statement; 177, 178; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:warnings; 181, identifier:warn; 182, argument_list; 182, 183; 182, 184; 183, identifier:msg; 184, identifier:DeprecationWarning; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:mode; 188, string:'pack'; 189, if_statement; 189, 190; 189, 193; 190, comparison_operator:==; 190, 191; 190, 192; 191, identifier:mode; 192, string:'rel'; 193, block; 193, 194; 193, 198; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:relpath; 197, identifier:dirname; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 201; 200, identifier:save_yaml; 201, argument_list; 201, 202; 201, 205; 201, 208; 201, 211; 201, 214; 202, keyword_argument; 202, 203; 202, 204; 203, identifier:fname; 204, identifier:fname; 205, keyword_argument; 205, 206; 205, 207; 206, identifier:wf; 207, identifier:self; 208, keyword_argument; 208, 209; 208, 210; 209, identifier:pack; 210, False; 211, keyword_argument; 211, 212; 211, 213; 212, identifier:relpath; 213, identifier:relpath; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:wd; 216, False; 217, if_statement; 217, 218; 217, 221; 218, comparison_operator:==; 218, 219; 218, 220; 219, identifier:mode; 220, string:'abs'; 221, block; 221, 222; 222, expression_statement; 222, 223; 223, call; 223, 224; 223, 225; 224, identifier:save_yaml; 225, argument_list; 225, 226; 225, 229; 225, 232; 225, 235; 225, 238; 226, keyword_argument; 226, 227; 226, 228; 227, identifier:fname; 228, identifier:fname; 229, keyword_argument; 229, 230; 229, 231; 230, identifier:wf; 231, identifier:self; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:pack; 234, False; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:relpath; 237, None; 238, keyword_argument; 238, 239; 238, 240; 239, identifier:wd; 240, False; 241, if_statement; 241, 242; 241, 245; 242, comparison_operator:==; 242, 243; 242, 244; 243, identifier:mode; 244, string:'pack'; 245, block; 245, 246; 246, expression_statement; 246, 247; 247, call; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:self; 250, identifier:_pack; 251, argument_list; 251, 252; 251, 253; 252, identifier:fname; 253, identifier:encoding; 254, if_statement; 254, 255; 254, 258; 255, comparison_operator:==; 255, 256; 255, 257; 256, identifier:mode; 257, string:'wd'; 258, block; 258, 259; 259, if_statement; 259, 260; 259, 267; 259, 273; 260, comparison_operator:is; 260, 261; 260, 266; 261, call; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:self; 264, identifier:get_working_dir; 265, argument_list; 266, None; 267, block; 267, 268; 268, raise_statement; 268, 269; 269, call; 269, 270; 269, 271; 270, identifier:ValueError; 271, argument_list; 271, 272; 272, string:'Working directory not set.'; 273, else_clause; 273, 274; 274, block; 274, 275; 274, 286; 274, 300; 274, 319; 275, expression_statement; 275, 276; 276, assignment; 276, 277; 276, 278; 277, identifier:bn; 278, call; 278, 279; 278, 284; 279, attribute; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:os; 282, identifier:path; 283, identifier:basename; 284, argument_list; 284, 285; 285, identifier:fname; 286, expression_statement; 286, 287; 287, assignment; 287, 288; 287, 289; 288, identifier:wd_file; 289, call; 289, 290; 289, 295; 290, attribute; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:os; 293, identifier:path; 294, identifier:join; 295, argument_list; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:self; 298, identifier:working_dir; 299, identifier:bn; 300, expression_statement; 300, 301; 301, call; 301, 302; 301, 303; 302, identifier:save_yaml; 303, argument_list; 303, 304; 303, 307; 303, 310; 303, 313; 303, 316; 304, keyword_argument; 304, 305; 304, 306; 305, identifier:fname; 306, identifier:wd_file; 307, keyword_argument; 307, 308; 307, 309; 308, identifier:wf; 309, identifier:self; 310, keyword_argument; 310, 311; 310, 312; 311, identifier:pack; 312, False; 313, keyword_argument; 313, 314; 313, 315; 314, identifier:relpath; 315, None; 316, keyword_argument; 316, 317; 316, 318; 317, identifier:wd; 318, True; 319, try_statement; 319, 320; 319, 329; 320, block; 320, 321; 321, expression_statement; 321, 322; 322, call; 322, 323; 322, 326; 323, attribute; 323, 324; 323, 325; 324, identifier:shutil; 325, identifier:copy2; 326, argument_list; 326, 327; 326, 328; 327, identifier:wd_file; 328, identifier:fname; 329, except_clause; 329, 330; 329, 333; 330, attribute; 330, 331; 330, 332; 331, identifier:shutil; 332, identifier:Error; 333, block; 333, 334; 334, pass_statement | def save(self, fname, mode=None, validate=True, encoding='utf-8',
wd=False, inline=False, relative=False, pack=False):
self._closed()
if mode is None:
mode = 'abs'
if pack:
mode = 'pack'
elif wd:
mode = 'wd'
elif relative:
mode = 'rel'
msg = 'Using deprecated save method. Please save the workflow ' \
'with: wf.save(\'{}\', mode=\'{}\'). Redirecting to new ' \
'save method.'.format(fname, mode)
warnings.warn(msg, DeprecationWarning)
modes = ('rel', 'abs', 'wd', 'inline', 'pack')
if mode not in modes:
msg = 'Illegal mode "{}". Choose one of ({}).'\
.format(mode, ','.join(modes))
raise ValueError(msg)
if validate:
self.validate()
dirname = os.path.dirname(os.path.abspath(fname))
if not os.path.exists(dirname):
os.makedirs(dirname)
if mode == 'inline':
msg = ('Inline saving is deprecated. Please save the workflow '
'using mode=\'pack\'. Setting mode to pack.')
warnings.warn(msg, DeprecationWarning)
mode = 'pack'
if mode == 'rel':
relpath = dirname
save_yaml(fname=fname, wf=self, pack=False, relpath=relpath,
wd=False)
if mode == 'abs':
save_yaml(fname=fname, wf=self, pack=False, relpath=None,
wd=False)
if mode == 'pack':
self._pack(fname, encoding)
if mode == 'wd':
if self.get_working_dir() is None:
raise ValueError('Working directory not set.')
else:
bn = os.path.basename(fname)
wd_file = os.path.join(self.working_dir, bn)
save_yaml(fname=wd_file, wf=self, pack=False, relpath=None,
wd=True)
try:
shutil.copy2(wd_file, fname)
except shutil.Error:
pass |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_snodas_ds; 3, parameters; 3, 4; 3, 5; 4, identifier:dem_dt; 5, default_parameter; 5, 6; 5, 7; 6, identifier:code; 7, integer:1036; 8, block; 8, 9; 8, 12; 8, 15; 8, 19; 8, 23; 8, 35; 8, 53; 8, 105; 8, 339; 9, import_statement; 9, 10; 10, dotted_name; 10, 11; 11, identifier:tarfile; 12, import_statement; 12, 13; 13, dotted_name; 13, 14; 14, identifier:gzip; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:snodas_ds; 18, None; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:snodas_url_str; 22, None; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:outdir; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:os; 30, identifier:path; 31, identifier:join; 32, argument_list; 32, 33; 32, 34; 33, identifier:datadir; 34, string:'snodas'; 35, if_statement; 35, 36; 35, 45; 36, not_operator; 36, 37; 37, call; 37, 38; 37, 43; 38, attribute; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:os; 41, identifier:path; 42, identifier:exists; 43, argument_list; 43, 44; 44, identifier:outdir; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:os; 50, identifier:makedirs; 51, argument_list; 51, 52; 52, identifier:outdir; 53, if_statement; 53, 54; 53, 71; 53, 80; 53, 98; 54, boolean_operator:and; 54, 55; 54, 63; 55, comparison_operator:>=; 55, 56; 55, 57; 56, identifier:dem_dt; 57, call; 57, 58; 57, 59; 58, identifier:datetime; 59, argument_list; 59, 60; 59, 61; 59, 62; 60, integer:2003; 61, integer:9; 62, integer:30; 63, comparison_operator:<; 63, 64; 63, 65; 64, identifier:dem_dt; 65, call; 65, 66; 65, 67; 66, identifier:datetime; 67, argument_list; 67, 68; 67, 69; 67, 70; 68, integer:2010; 69, integer:1; 70, integer:1; 71, block; 71, 72; 71, 76; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:snodas_url_str; 75, string:'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/%Y/%m_%b/SNODAS_%Y%m%d.tar'; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:tar_subfn_str_fmt; 79, string:'us_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz'; 80, elif_clause; 80, 81; 80, 89; 81, comparison_operator:>=; 81, 82; 81, 83; 82, identifier:dem_dt; 83, call; 83, 84; 83, 85; 84, identifier:datetime; 85, argument_list; 85, 86; 85, 87; 85, 88; 86, integer:2010; 87, integer:1; 88, integer:1; 89, block; 89, 90; 89, 94; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:snodas_url_str; 93, string:'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/unmasked/%Y/%m_%b/SNODAS_unmasked_%Y%m%d.tar'; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:tar_subfn_str_fmt; 97, string:'./zz_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz'; 98, else_clause; 98, 99; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 103; 102, identifier:print; 103, argument_list; 103, 104; 104, string:"No SNODAS data available for input date"; 105, if_statement; 105, 106; 105, 109; 106, comparison_operator:is; 106, 107; 106, 108; 107, identifier:snodas_url_str; 108, None; 109, block; 109, 110; 109, 119; 109, 131; 109, 136; 109, 145; 109, 267; 109, 271; 109, 275; 109, 282; 109, 286; 109, 303; 109, 309; 109, 317; 109, 324; 109, 330; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:snodas_url; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:dem_dt; 116, identifier:strftime; 117, argument_list; 117, 118; 118, identifier:snodas_url_str; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:snodas_tar_fn; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:iolib; 125, identifier:getfile; 126, argument_list; 126, 127; 126, 128; 127, identifier:snodas_url; 128, keyword_argument; 128, 129; 128, 130; 129, identifier:outdir; 130, identifier:outdir; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 134; 133, identifier:print; 134, argument_list; 134, 135; 135, string:"Unpacking"; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:tar; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:tarfile; 142, identifier:open; 143, argument_list; 143, 144; 144, identifier:snodas_tar_fn; 145, for_statement; 145, 146; 145, 147; 145, 150; 146, identifier:ext; 147, tuple; 147, 148; 147, 149; 148, string:'dat'; 149, string:'Hdr'; 150, block; 150, 151; 150, 159; 150, 168; 150, 181; 150, 186; 150, 203; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:tar_subfn_str; 154, binary_operator:%; 154, 155; 154, 156; 155, identifier:tar_subfn_str_fmt; 156, tuple; 156, 157; 156, 158; 157, identifier:code; 158, identifier:ext; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:tar_subfn_gz; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:dem_dt; 165, identifier:strftime; 166, argument_list; 166, 167; 167, identifier:tar_subfn_str; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:tar_subfn; 171, subscript; 171, 172; 171, 180; 172, call; 172, 173; 172, 178; 173, attribute; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:os; 176, identifier:path; 177, identifier:splitext; 178, argument_list; 178, 179; 179, identifier:tar_subfn_gz; 180, integer:0; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 184; 183, identifier:print; 184, argument_list; 184, 185; 185, identifier:tar_subfn; 186, if_statement; 186, 187; 186, 190; 187, comparison_operator:is; 187, 188; 187, 189; 188, identifier:outdir; 189, None; 190, block; 190, 191; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:tar_subfn; 194, call; 194, 195; 194, 200; 195, attribute; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:os; 198, identifier:path; 199, identifier:join; 200, argument_list; 200, 201; 200, 202; 201, identifier:outdir; 202, identifier:tar_subfn; 203, if_statement; 203, 204; 203, 213; 204, not_operator; 204, 205; 205, call; 205, 206; 205, 211; 206, attribute; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:os; 209, identifier:path; 210, identifier:exists; 211, argument_list; 211, 212; 212, identifier:tar_subfn; 213, block; 213, 214; 213, 221; 213, 260; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:tar; 218, identifier:extract; 219, argument_list; 219, 220; 220, identifier:tar_subfn_gz; 221, with_statement; 221, 222; 221, 234; 222, with_clause; 222, 223; 223, with_item; 223, 224; 224, as_pattern; 224, 225; 224, 232; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:gzip; 228, identifier:open; 229, argument_list; 229, 230; 229, 231; 230, identifier:tar_subfn_gz; 231, string:'rb'; 232, as_pattern_target; 232, 233; 233, identifier:f; 234, block; 234, 235; 234, 243; 234, 254; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:outf; 238, call; 238, 239; 238, 240; 239, identifier:open; 240, argument_list; 240, 241; 240, 242; 241, identifier:tar_subfn; 242, string:'wb'; 243, expression_statement; 243, 244; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:outf; 247, identifier:write; 248, argument_list; 248, 249; 249, call; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:f; 252, identifier:read; 253, argument_list; 254, expression_statement; 254, 255; 255, call; 255, 256; 255, 259; 256, attribute; 256, 257; 256, 258; 257, identifier:outf; 258, identifier:close; 259, argument_list; 260, expression_statement; 260, 261; 261, call; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:os; 264, identifier:remove; 265, argument_list; 265, 266; 266, identifier:tar_subfn_gz; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:bad_str; 270, string:'Created by module comment'; 271, expression_statement; 271, 272; 272, assignment; 272, 273; 272, 274; 273, identifier:snodas_fn; 274, identifier:tar_subfn; 275, expression_statement; 275, 276; 276, assignment; 276, 277; 276, 278; 277, identifier:f; 278, call; 278, 279; 278, 280; 279, identifier:open; 280, argument_list; 280, 281; 281, identifier:snodas_fn; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:output; 285, list:[]; 286, for_statement; 286, 287; 286, 288; 286, 289; 287, identifier:line; 288, identifier:f; 289, block; 289, 290; 290, if_statement; 290, 291; 290, 295; 291, not_operator; 291, 292; 292, comparison_operator:in; 292, 293; 292, 294; 293, identifier:bad_str; 294, identifier:line; 295, block; 295, 296; 296, expression_statement; 296, 297; 297, call; 297, 298; 297, 301; 298, attribute; 298, 299; 298, 300; 299, identifier:output; 300, identifier:append; 301, argument_list; 301, 302; 302, identifier:line; 303, expression_statement; 303, 304; 304, call; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:f; 307, identifier:close; 308, argument_list; 309, expression_statement; 309, 310; 310, assignment; 310, 311; 310, 312; 311, identifier:f; 312, call; 312, 313; 312, 314; 313, identifier:open; 314, argument_list; 314, 315; 314, 316; 315, identifier:snodas_fn; 316, string:'w'; 317, expression_statement; 317, 318; 318, call; 318, 319; 318, 322; 319, attribute; 319, 320; 319, 321; 320, identifier:f; 321, identifier:writelines; 322, argument_list; 322, 323; 323, identifier:output; 324, expression_statement; 324, 325; 325, call; 325, 326; 325, 329; 326, attribute; 326, 327; 326, 328; 327, identifier:f; 328, identifier:close; 329, argument_list; 330, expression_statement; 330, 331; 331, assignment; 331, 332; 331, 333; 332, identifier:snodas_ds; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:gdal; 336, identifier:Open; 337, argument_list; 337, 338; 338, identifier:snodas_fn; 339, return_statement; 339, 340; 340, identifier:snodas_ds | def get_snodas_ds(dem_dt, code=1036):
import tarfile
import gzip
snodas_ds = None
snodas_url_str = None
outdir = os.path.join(datadir, 'snodas')
if not os.path.exists(outdir):
os.makedirs(outdir)
if dem_dt >= datetime(2003,9,30) and dem_dt < datetime(2010,1,1):
snodas_url_str = 'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/%Y/%m_%b/SNODAS_%Y%m%d.tar'
tar_subfn_str_fmt = 'us_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz'
elif dem_dt >= datetime(2010,1,1):
snodas_url_str = 'ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/unmasked/%Y/%m_%b/SNODAS_unmasked_%Y%m%d.tar'
tar_subfn_str_fmt = './zz_ssmv1%itS__T0001TTNATS%%Y%%m%%d05HP001.%s.gz'
else:
print("No SNODAS data available for input date")
if snodas_url_str is not None:
snodas_url = dem_dt.strftime(snodas_url_str)
snodas_tar_fn = iolib.getfile(snodas_url, outdir=outdir)
print("Unpacking")
tar = tarfile.open(snodas_tar_fn)
for ext in ('dat', 'Hdr'):
tar_subfn_str = tar_subfn_str_fmt % (code, ext)
tar_subfn_gz = dem_dt.strftime(tar_subfn_str)
tar_subfn = os.path.splitext(tar_subfn_gz)[0]
print(tar_subfn)
if outdir is not None:
tar_subfn = os.path.join(outdir, tar_subfn)
if not os.path.exists(tar_subfn):
tar.extract(tar_subfn_gz)
with gzip.open(tar_subfn_gz, 'rb') as f:
outf = open(tar_subfn, 'wb')
outf.write(f.read())
outf.close()
os.remove(tar_subfn_gz)
bad_str = 'Created by module comment'
snodas_fn = tar_subfn
f = open(snodas_fn)
output = []
for line in f:
if not bad_str in line:
output.append(line)
f.close()
f = open(snodas_fn, 'w')
f.writelines(output)
f.close()
snodas_ds = gdal.Open(snodas_fn)
return snodas_ds |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:get_modscag_fn_list; 3, parameters; 3, 4; 3, 5; 3, 13; 4, identifier:dem_dt; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tile_list; 7, tuple; 7, 8; 7, 9; 7, 10; 7, 11; 7, 12; 8, string:'h08v04'; 9, string:'h09v04'; 10, string:'h10v04'; 11, string:'h08v05'; 12, string:'h09v05'; 13, default_parameter; 13, 14; 13, 15; 14, identifier:pad_days; 15, integer:7; 16, block; 16, 17; 16, 20; 16, 23; 16, 28; 16, 36; 16, 45; 16, 68; 16, 80; 16, 98; 16, 102; 16, 483; 17, import_statement; 17, 18; 18, dotted_name; 18, 19; 19, identifier:re; 20, import_statement; 20, 21; 21, dotted_name; 21, 22; 22, identifier:requests; 23, import_from_statement; 23, 24; 23, 26; 24, dotted_name; 24, 25; 25, identifier:bs4; 26, dotted_name; 26, 27; 27, identifier:BeautifulSoup; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:auth; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:iolib; 34, identifier:get_auth; 35, argument_list; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:pad_days; 39, call; 39, 40; 39, 41; 40, identifier:timedelta; 41, argument_list; 41, 42; 42, keyword_argument; 42, 43; 42, 44; 43, identifier:days; 44, identifier:pad_days; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:dt_list; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:timelib; 51, identifier:dt_range; 52, argument_list; 52, 53; 52, 56; 52, 64; 53, binary_operator:-; 53, 54; 53, 55; 54, identifier:dem_dt; 55, identifier:pad_days; 56, binary_operator:+; 56, 57; 56, 60; 57, binary_operator:+; 57, 58; 57, 59; 58, identifier:dem_dt; 59, identifier:pad_days; 60, call; 60, 61; 60, 62; 61, identifier:timedelta; 62, argument_list; 62, 63; 63, integer:1; 64, call; 64, 65; 64, 66; 65, identifier:timedelta; 66, argument_list; 66, 67; 67, integer:1; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:outdir; 71, call; 71, 72; 71, 77; 72, attribute; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:os; 75, identifier:path; 76, identifier:join; 77, argument_list; 77, 78; 77, 79; 78, identifier:datadir; 79, string:'modscag'; 80, if_statement; 80, 81; 80, 90; 81, not_operator; 81, 82; 82, call; 82, 83; 82, 88; 83, attribute; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:os; 86, identifier:path; 87, identifier:exists; 88, argument_list; 88, 89; 89, identifier:outdir; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:os; 95, identifier:makedirs; 96, argument_list; 96, 97; 97, identifier:outdir; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:out_vrt_fn_list; 101, list:[]; 102, for_statement; 102, 103; 102, 104; 102, 105; 103, identifier:dt; 104, identifier:dt_list; 105, block; 105, 106; 105, 123; 105, 177; 105, 181; 105, 443; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:out_vrt_fn; 109, call; 109, 110; 109, 115; 110, attribute; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:os; 113, identifier:path; 114, identifier:join; 115, argument_list; 115, 116; 115, 117; 116, identifier:outdir; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:dt; 120, identifier:strftime; 121, argument_list; 121, 122; 122, string:'%Y%m%d_snow_fraction.vrt'; 123, if_statement; 123, 124; 123, 132; 124, call; 124, 125; 124, 130; 125, attribute; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:os; 128, identifier:path; 129, identifier:exists; 130, argument_list; 130, 131; 131, identifier:out_vrt_fn; 132, block; 132, 133; 132, 142; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:vrt_ds; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:gdal; 139, identifier:Open; 140, argument_list; 140, 141; 141, identifier:out_vrt_fn; 142, if_statement; 142, 143; 142, 168; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:np; 146, identifier:all; 147, argument_list; 147, 148; 148, list_comprehension; 148, 149; 148, 165; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:np; 152, identifier:any; 153, argument_list; 153, 154; 154, list_comprehension; 154, 155; 154, 158; 155, comparison_operator:in; 155, 156; 155, 157; 156, identifier:tile; 157, identifier:sub_fn; 158, for_in_clause; 158, 159; 158, 160; 159, identifier:sub_fn; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:vrt_ds; 163, identifier:GetFileList; 164, argument_list; 165, for_in_clause; 165, 166; 165, 167; 166, identifier:tile; 167, identifier:tile_list; 168, block; 168, 169; 168, 176; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:out_vrt_fn_list; 173, identifier:append; 174, argument_list; 174, 175; 175, identifier:out_vrt_fn; 176, continue_statement; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:modscag_fn_list; 180, list:[]; 181, for_statement; 181, 182; 181, 183; 181, 184; 182, identifier:tile; 183, identifier:tile_list; 184, block; 184, 185; 184, 189; 184, 198; 184, 205; 184, 217; 184, 221; 184, 254; 184, 290; 184, 323; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:modscag_url_str; 188, string:'https://snow-data.jpl.nasa.gov/modscag-historic/%Y/%j/'; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:modscag_url_base; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:dt; 195, identifier:strftime; 196, argument_list; 196, 197; 197, identifier:modscag_url_str; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 201; 200, identifier:print; 201, argument_list; 201, 202; 202, binary_operator:%; 202, 203; 202, 204; 203, string:"Trying: %s"; 204, identifier:modscag_url_base; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:r; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:requests; 211, identifier:get; 212, argument_list; 212, 213; 212, 214; 213, identifier:modscag_url_base; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:auth; 216, identifier:auth; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:modscag_url_fn; 220, list:[]; 221, if_statement; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:r; 224, identifier:ok; 225, block; 225, 226; 225, 236; 226, expression_statement; 226, 227; 227, assignment; 227, 228; 227, 229; 228, identifier:parsed_html; 229, call; 229, 230; 229, 231; 230, identifier:BeautifulSoup; 231, argument_list; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:r; 234, identifier:content; 235, string:"html.parser"; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:modscag_url_fn; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:parsed_html; 242, identifier:findAll; 243, argument_list; 243, 244; 244, keyword_argument; 244, 245; 244, 246; 245, identifier:text; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:re; 249, identifier:compile; 250, argument_list; 250, 251; 251, binary_operator:%; 251, 252; 251, 253; 252, string:'%s.*snow_fraction.tif'; 253, identifier:tile; 254, if_statement; 254, 255; 254, 257; 255, not_operator; 255, 256; 256, identifier:modscag_url_fn; 257, block; 257, 258; 257, 262; 257, 271; 257, 278; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:modscag_url_str; 261, string:'https://snow-data.jpl.nasa.gov/modscag/%Y/%j/'; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 265; 264, identifier:modscag_url_base; 265, call; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:dt; 268, identifier:strftime; 269, argument_list; 269, 270; 270, identifier:modscag_url_str; 271, expression_statement; 271, 272; 272, call; 272, 273; 272, 274; 273, identifier:print; 274, argument_list; 274, 275; 275, binary_operator:%; 275, 276; 275, 277; 276, string:"Trying: %s"; 277, identifier:modscag_url_base; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:r; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:requests; 284, identifier:get; 285, argument_list; 285, 286; 285, 287; 286, identifier:modscag_url_base; 287, keyword_argument; 287, 288; 287, 289; 288, identifier:auth; 289, identifier:auth; 290, if_statement; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:r; 293, identifier:ok; 294, block; 294, 295; 294, 305; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:parsed_html; 298, call; 298, 299; 298, 300; 299, identifier:BeautifulSoup; 300, argument_list; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:r; 303, identifier:content; 304, string:"html.parser"; 305, expression_statement; 305, 306; 306, assignment; 306, 307; 306, 308; 307, identifier:modscag_url_fn; 308, call; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:parsed_html; 311, identifier:findAll; 312, argument_list; 312, 313; 313, keyword_argument; 313, 314; 313, 315; 314, identifier:text; 315, call; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:re; 318, identifier:compile; 319, argument_list; 319, 320; 320, binary_operator:%; 320, 321; 320, 322; 321, string:'%s.*snow_fraction.tif'; 322, identifier:tile; 323, if_statement; 323, 324; 323, 326; 323, 334; 324, not_operator; 324, 325; 325, identifier:modscag_url_fn; 326, block; 326, 327; 327, expression_statement; 327, 328; 328, call; 328, 329; 328, 330; 329, identifier:print; 330, argument_list; 330, 331; 331, binary_operator:%; 331, 332; 331, 333; 332, string:"Unable to fetch MODSCAG for %s"; 333, identifier:dt; 334, else_clause; 334, 335; 335, block; 335, 336; 335, 346; 335, 364; 336, expression_statement; 336, 337; 337, assignment; 337, 338; 337, 339; 338, identifier:parsed_html; 339, call; 339, 340; 339, 341; 340, identifier:BeautifulSoup; 341, argument_list; 341, 342; 341, 345; 342, attribute; 342, 343; 342, 344; 343, identifier:r; 344, identifier:content; 345, string:"html.parser"; 346, expression_statement; 346, 347; 347, assignment; 347, 348; 347, 349; 348, identifier:modscag_url_fn; 349, call; 349, 350; 349, 353; 350, attribute; 350, 351; 350, 352; 351, identifier:parsed_html; 352, identifier:findAll; 353, argument_list; 353, 354; 354, keyword_argument; 354, 355; 354, 356; 355, identifier:text; 356, call; 356, 357; 356, 360; 357, attribute; 357, 358; 357, 359; 358, identifier:re; 359, identifier:compile; 360, argument_list; 360, 361; 361, binary_operator:%; 361, 362; 361, 363; 362, string:'%s.*snow_fraction.tif'; 363, identifier:tile; 364, if_statement; 364, 365; 364, 366; 365, identifier:modscag_url_fn; 366, block; 366, 367; 366, 373; 366, 385; 366, 390; 366, 412; 366, 436; 367, expression_statement; 367, 368; 368, assignment; 368, 369; 368, 370; 369, identifier:modscag_url_fn; 370, subscript; 370, 371; 370, 372; 371, identifier:modscag_url_fn; 372, integer:0; 373, expression_statement; 373, 374; 374, assignment; 374, 375; 374, 376; 375, identifier:modscag_url; 376, call; 376, 377; 376, 382; 377, attribute; 377, 378; 377, 381; 378, attribute; 378, 379; 378, 380; 379, identifier:os; 380, identifier:path; 381, identifier:join; 382, argument_list; 382, 383; 382, 384; 383, identifier:modscag_url_base; 384, identifier:modscag_url_fn; 385, expression_statement; 385, 386; 386, call; 386, 387; 386, 388; 387, identifier:print; 388, argument_list; 388, 389; 389, identifier:modscag_url; 390, expression_statement; 390, 391; 391, assignment; 391, 392; 391, 393; 392, identifier:modscag_fn; 393, call; 393, 394; 393, 399; 394, attribute; 394, 395; 394, 398; 395, attribute; 395, 396; 395, 397; 396, identifier:os; 397, identifier:path; 398, identifier:join; 399, argument_list; 399, 400; 399, 401; 400, identifier:outdir; 401, subscript; 401, 402; 401, 410; 402, call; 402, 403; 402, 408; 403, attribute; 403, 404; 403, 407; 404, attribute; 404, 405; 404, 406; 405, identifier:os; 406, identifier:path; 407, identifier:split; 408, argument_list; 408, 409; 409, identifier:modscag_url_fn; 410, unary_operator:-; 410, 411; 411, integer:1; 412, if_statement; 412, 413; 412, 422; 413, not_operator; 413, 414; 414, call; 414, 415; 414, 420; 415, attribute; 415, 416; 415, 419; 416, attribute; 416, 417; 416, 418; 417, identifier:os; 418, identifier:path; 419, identifier:exists; 420, argument_list; 420, 421; 421, identifier:modscag_fn; 422, block; 422, 423; 423, expression_statement; 423, 424; 424, call; 424, 425; 424, 428; 425, attribute; 425, 426; 425, 427; 426, identifier:iolib; 427, identifier:getfile2; 428, argument_list; 428, 429; 428, 430; 428, 433; 429, identifier:modscag_url; 430, keyword_argument; 430, 431; 430, 432; 431, identifier:auth; 432, identifier:auth; 433, keyword_argument; 433, 434; 433, 435; 434, identifier:outdir; 435, identifier:outdir; 436, expression_statement; 436, 437; 437, call; 437, 438; 437, 441; 438, attribute; 438, 439; 438, 440; 439, identifier:modscag_fn_list; 440, identifier:append; 441, argument_list; 441, 442; 442, identifier:modscag_fn; 443, if_statement; 443, 444; 443, 445; 444, identifier:modscag_fn_list; 445, block; 445, 446; 445, 454; 445, 461; 445, 466; 445, 476; 446, expression_statement; 446, 447; 447, assignment; 447, 448; 447, 449; 448, identifier:cmd; 449, list:['gdalbuildvrt', '-vrtnodata', '255', out_vrt_fn]; 449, 450; 449, 451; 449, 452; 449, 453; 450, string:'gdalbuildvrt'; 451, string:'-vrtnodata'; 452, string:'255'; 453, identifier:out_vrt_fn; 454, expression_statement; 454, 455; 455, call; 455, 456; 455, 459; 456, attribute; 456, 457; 456, 458; 457, identifier:cmd; 458, identifier:extend; 459, argument_list; 459, 460; 460, identifier:modscag_fn_list; 461, expression_statement; 461, 462; 462, call; 462, 463; 462, 464; 463, identifier:print; 464, argument_list; 464, 465; 465, identifier:cmd; 466, expression_statement; 466, 467; 467, call; 467, 468; 467, 471; 468, attribute; 468, 469; 468, 470; 469, identifier:subprocess; 470, identifier:call; 471, argument_list; 471, 472; 471, 473; 472, identifier:cmd; 473, keyword_argument; 473, 474; 473, 475; 474, identifier:shell; 475, False; 476, expression_statement; 476, 477; 477, call; 477, 478; 477, 481; 478, attribute; 478, 479; 478, 480; 479, identifier:out_vrt_fn_list; 480, identifier:append; 481, argument_list; 481, 482; 482, identifier:out_vrt_fn; 483, return_statement; 483, 484; 484, identifier:out_vrt_fn_list | def get_modscag_fn_list(dem_dt, tile_list=('h08v04', 'h09v04', 'h10v04', 'h08v05', 'h09v05'), pad_days=7):
import re
import requests
from bs4 import BeautifulSoup
auth = iolib.get_auth()
pad_days = timedelta(days=pad_days)
dt_list = timelib.dt_range(dem_dt-pad_days, dem_dt+pad_days+timedelta(1), timedelta(1))
outdir = os.path.join(datadir, 'modscag')
if not os.path.exists(outdir):
os.makedirs(outdir)
out_vrt_fn_list = []
for dt in dt_list:
out_vrt_fn = os.path.join(outdir, dt.strftime('%Y%m%d_snow_fraction.vrt'))
if os.path.exists(out_vrt_fn):
vrt_ds = gdal.Open(out_vrt_fn)
if np.all([np.any([tile in sub_fn for sub_fn in vrt_ds.GetFileList()]) for tile in tile_list]):
out_vrt_fn_list.append(out_vrt_fn)
continue
modscag_fn_list = []
for tile in tile_list:
modscag_url_str = 'https://snow-data.jpl.nasa.gov/modscag-historic/%Y/%j/'
modscag_url_base = dt.strftime(modscag_url_str)
print("Trying: %s" % modscag_url_base)
r = requests.get(modscag_url_base, auth=auth)
modscag_url_fn = []
if r.ok:
parsed_html = BeautifulSoup(r.content, "html.parser")
modscag_url_fn = parsed_html.findAll(text=re.compile('%s.*snow_fraction.tif' % tile))
if not modscag_url_fn:
modscag_url_str = 'https://snow-data.jpl.nasa.gov/modscag/%Y/%j/'
modscag_url_base = dt.strftime(modscag_url_str)
print("Trying: %s" % modscag_url_base)
r = requests.get(modscag_url_base, auth=auth)
if r.ok:
parsed_html = BeautifulSoup(r.content, "html.parser")
modscag_url_fn = parsed_html.findAll(text=re.compile('%s.*snow_fraction.tif' % tile))
if not modscag_url_fn:
print("Unable to fetch MODSCAG for %s" % dt)
else:
parsed_html = BeautifulSoup(r.content, "html.parser")
modscag_url_fn = parsed_html.findAll(text=re.compile('%s.*snow_fraction.tif' % tile))
if modscag_url_fn:
modscag_url_fn = modscag_url_fn[0]
modscag_url = os.path.join(modscag_url_base, modscag_url_fn)
print(modscag_url)
modscag_fn = os.path.join(outdir, os.path.split(modscag_url_fn)[-1])
if not os.path.exists(modscag_fn):
iolib.getfile2(modscag_url, auth=auth, outdir=outdir)
modscag_fn_list.append(modscag_fn)
if modscag_fn_list:
cmd = ['gdalbuildvrt', '-vrtnodata', '255', out_vrt_fn]
cmd.extend(modscag_fn_list)
print(cmd)
subprocess.call(cmd, shell=False)
out_vrt_fn_list.append(out_vrt_fn)
return out_vrt_fn_list |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_decode_record; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:s; 6, default_parameter; 6, 7; 6, 8; 7, identifier:line; 8, integer:0; 9, block; 9, 10; 9, 12; 9, 21; 9, 26; 9, 93; 9, 99; 9, 114; 9, 126; 9, 132; 9, 147; 9, 154; 9, 158; 9, 170; 10, expression_statement; 10, 11; 11, string:'''Decode one record of HEX file.
@param s line with HEX record.
@param line line number (for error messages).
@raise EndOfFile if EOF record encountered.
'''; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:s; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:s; 18, identifier:rstrip; 19, argument_list; 19, 20; 20, string:'\r\n'; 21, if_statement; 21, 22; 21, 24; 22, not_operator; 22, 23; 23, identifier:s; 24, block; 24, 25; 25, return_statement; 26, if_statement; 26, 27; 26, 32; 26, 84; 27, comparison_operator:==; 27, 28; 27, 31; 28, subscript; 28, 29; 28, 30; 29, identifier:s; 30, integer:0; 31, string:':'; 32, block; 32, 33; 32, 65; 32, 72; 33, try_statement; 33, 34; 33, 53; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:bin; 38, call; 38, 39; 38, 40; 39, identifier:array; 40, argument_list; 40, 41; 40, 42; 41, string:'B'; 42, call; 42, 43; 42, 44; 43, identifier:unhexlify; 44, argument_list; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:asbytes; 47, argument_list; 47, 48; 48, subscript; 48, 49; 48, 50; 49, identifier:s; 50, slice; 50, 51; 50, 52; 51, integer:1; 52, colon; 53, except_clause; 53, 54; 53, 57; 54, tuple; 54, 55; 54, 56; 55, identifier:TypeError; 56, identifier:ValueError; 57, block; 57, 58; 58, raise_statement; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:HexRecordError; 61, argument_list; 61, 62; 62, keyword_argument; 62, 63; 62, 64; 63, identifier:line; 64, identifier:line; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:length; 68, call; 68, 69; 68, 70; 69, identifier:len; 70, argument_list; 70, 71; 71, identifier:bin; 72, if_statement; 72, 73; 72, 76; 73, comparison_operator:<; 73, 74; 73, 75; 74, identifier:length; 75, integer:5; 76, block; 76, 77; 77, raise_statement; 77, 78; 78, call; 78, 79; 78, 80; 79, identifier:HexRecordError; 80, argument_list; 80, 81; 81, keyword_argument; 81, 82; 81, 83; 82, identifier:line; 83, identifier:line; 84, else_clause; 84, 85; 85, block; 85, 86; 86, raise_statement; 86, 87; 87, call; 87, 88; 87, 89; 88, identifier:HexRecordError; 89, argument_list; 89, 90; 90, keyword_argument; 90, 91; 90, 92; 91, identifier:line; 92, identifier:line; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:record_length; 96, subscript; 96, 97; 96, 98; 97, identifier:bin; 98, integer:0; 99, if_statement; 99, 100; 99, 106; 100, comparison_operator:!=; 100, 101; 100, 102; 101, identifier:length; 102, parenthesized_expression; 102, 103; 103, binary_operator:+; 103, 104; 103, 105; 104, integer:5; 105, identifier:record_length; 106, block; 106, 107; 107, raise_statement; 107, 108; 108, call; 108, 109; 108, 110; 109, identifier:RecordLengthError; 110, argument_list; 110, 111; 111, keyword_argument; 111, 112; 111, 113; 112, identifier:line; 113, identifier:line; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:addr; 117, binary_operator:+; 117, 118; 117, 123; 118, binary_operator:*; 118, 119; 118, 122; 119, subscript; 119, 120; 119, 121; 120, identifier:bin; 121, integer:1; 122, integer:256; 123, subscript; 123, 124; 123, 125; 124, identifier:bin; 125, integer:2; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:record_type; 129, subscript; 129, 130; 129, 131; 130, identifier:bin; 131, integer:3; 132, if_statement; 132, 133; 132, 139; 133, not_operator; 133, 134; 134, parenthesized_expression; 134, 135; 135, comparison_operator:<=; 135, 136; 135, 137; 135, 138; 136, integer:0; 137, identifier:record_type; 138, integer:5; 139, block; 139, 140; 140, raise_statement; 140, 141; 141, call; 141, 142; 141, 143; 142, identifier:RecordTypeError; 143, argument_list; 143, 144; 144, keyword_argument; 144, 145; 144, 146; 145, identifier:line; 146, identifier:line; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:crc; 150, call; 150, 151; 150, 152; 151, identifier:sum; 152, argument_list; 152, 153; 153, identifier:bin; 154, expression_statement; 154, 155; 155, augmented_assignment:&=; 155, 156; 155, 157; 156, identifier:crc; 157, integer:0x0FF; 158, if_statement; 158, 159; 158, 162; 159, comparison_operator:!=; 159, 160; 159, 161; 160, identifier:crc; 161, integer:0; 162, block; 162, 163; 163, raise_statement; 163, 164; 164, call; 164, 165; 164, 166; 165, identifier:RecordChecksumError; 166, argument_list; 166, 167; 167, keyword_argument; 167, 168; 167, 169; 168, identifier:line; 169, identifier:line; 170, if_statement; 170, 171; 170, 174; 170, 229; 170, 248; 170, 286; 170, 324; 170, 385; 171, comparison_operator:==; 171, 172; 171, 173; 172, identifier:record_type; 173, integer:0; 174, block; 174, 175; 174, 181; 175, expression_statement; 175, 176; 176, augmented_assignment:+=; 176, 177; 176, 178; 177, identifier:addr; 178, attribute; 178, 179; 178, 180; 179, identifier:self; 180, identifier:_offset; 181, for_statement; 181, 182; 181, 183; 181, 190; 182, identifier:i; 183, call; 183, 184; 183, 185; 184, identifier:range_g; 185, argument_list; 185, 186; 185, 187; 186, integer:4; 187, binary_operator:+; 187, 188; 187, 189; 188, integer:4; 189, identifier:record_length; 190, block; 190, 191; 190, 215; 190, 225; 191, if_statement; 191, 192; 191, 204; 192, not_operator; 192, 193; 193, comparison_operator:is; 193, 194; 193, 203; 194, call; 194, 195; 194, 200; 195, attribute; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:self; 198, identifier:_buf; 199, identifier:get; 200, argument_list; 200, 201; 200, 202; 201, identifier:addr; 202, None; 203, None; 204, block; 204, 205; 205, raise_statement; 205, 206; 206, call; 206, 207; 206, 208; 207, identifier:AddressOverlapError; 208, argument_list; 208, 209; 208, 212; 209, keyword_argument; 209, 210; 209, 211; 210, identifier:address; 211, identifier:addr; 212, keyword_argument; 212, 213; 212, 214; 213, identifier:line; 214, identifier:line; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 222; 217, subscript; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:self; 220, identifier:_buf; 221, identifier:addr; 222, subscript; 222, 223; 222, 224; 223, identifier:bin; 224, identifier:i; 225, expression_statement; 225, 226; 226, augmented_assignment:+=; 226, 227; 226, 228; 227, identifier:addr; 228, integer:1; 229, elif_clause; 229, 230; 229, 233; 230, comparison_operator:==; 230, 231; 230, 232; 231, identifier:record_type; 232, integer:1; 233, block; 233, 234; 233, 246; 234, if_statement; 234, 235; 234, 238; 235, comparison_operator:!=; 235, 236; 235, 237; 236, identifier:record_length; 237, integer:0; 238, block; 238, 239; 239, raise_statement; 239, 240; 240, call; 240, 241; 240, 242; 241, identifier:EOFRecordError; 242, argument_list; 242, 243; 243, keyword_argument; 243, 244; 243, 245; 244, identifier:line; 245, identifier:line; 246, raise_statement; 246, 247; 247, identifier:_EndOfFile; 248, elif_clause; 248, 249; 248, 252; 249, comparison_operator:==; 249, 250; 249, 251; 250, identifier:record_type; 251, integer:2; 252, block; 252, 253; 252, 269; 253, if_statement; 253, 254; 253, 261; 254, boolean_operator:or; 254, 255; 254, 258; 255, comparison_operator:!=; 255, 256; 255, 257; 256, identifier:record_length; 257, integer:2; 258, comparison_operator:!=; 258, 259; 258, 260; 259, identifier:addr; 260, integer:0; 261, block; 261, 262; 262, raise_statement; 262, 263; 263, call; 263, 264; 263, 265; 264, identifier:ExtendedSegmentAddressRecordError; 265, argument_list; 265, 266; 266, keyword_argument; 266, 267; 266, 268; 267, identifier:line; 268, identifier:line; 269, expression_statement; 269, 270; 270, assignment; 270, 271; 270, 274; 271, attribute; 271, 272; 271, 273; 272, identifier:self; 273, identifier:_offset; 274, binary_operator:*; 274, 275; 274, 285; 275, parenthesized_expression; 275, 276; 276, binary_operator:+; 276, 277; 276, 282; 277, binary_operator:*; 277, 278; 277, 281; 278, subscript; 278, 279; 278, 280; 279, identifier:bin; 280, integer:4; 281, integer:256; 282, subscript; 282, 283; 282, 284; 283, identifier:bin; 284, integer:5; 285, integer:16; 286, elif_clause; 286, 287; 286, 290; 287, comparison_operator:==; 287, 288; 287, 289; 288, identifier:record_type; 289, integer:4; 290, block; 290, 291; 290, 307; 291, if_statement; 291, 292; 291, 299; 292, boolean_operator:or; 292, 293; 292, 296; 293, comparison_operator:!=; 293, 294; 293, 295; 294, identifier:record_length; 295, integer:2; 296, comparison_operator:!=; 296, 297; 296, 298; 297, identifier:addr; 298, integer:0; 299, block; 299, 300; 300, raise_statement; 300, 301; 301, call; 301, 302; 301, 303; 302, identifier:ExtendedLinearAddressRecordError; 303, argument_list; 303, 304; 304, keyword_argument; 304, 305; 304, 306; 305, identifier:line; 306, identifier:line; 307, expression_statement; 307, 308; 308, assignment; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:self; 311, identifier:_offset; 312, binary_operator:*; 312, 313; 312, 323; 313, parenthesized_expression; 313, 314; 314, binary_operator:+; 314, 315; 314, 320; 315, binary_operator:*; 315, 316; 315, 319; 316, subscript; 316, 317; 316, 318; 317, identifier:bin; 318, integer:4; 319, integer:256; 320, subscript; 320, 321; 320, 322; 321, identifier:bin; 322, integer:5; 323, integer:65536; 324, elif_clause; 324, 325; 324, 328; 325, comparison_operator:==; 325, 326; 325, 327; 326, identifier:record_type; 327, integer:3; 328, block; 328, 329; 328, 345; 328, 357; 329, if_statement; 329, 330; 329, 337; 330, boolean_operator:or; 330, 331; 330, 334; 331, comparison_operator:!=; 331, 332; 331, 333; 332, identifier:record_length; 333, integer:4; 334, comparison_operator:!=; 334, 335; 334, 336; 335, identifier:addr; 336, integer:0; 337, block; 337, 338; 338, raise_statement; 338, 339; 339, call; 339, 340; 339, 341; 340, identifier:StartSegmentAddressRecordError; 341, argument_list; 341, 342; 342, keyword_argument; 342, 343; 342, 344; 343, identifier:line; 344, identifier:line; 345, if_statement; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:self; 348, identifier:start_addr; 349, block; 349, 350; 350, raise_statement; 350, 351; 351, call; 351, 352; 351, 353; 352, identifier:DuplicateStartAddressRecordError; 353, argument_list; 353, 354; 354, keyword_argument; 354, 355; 354, 356; 355, identifier:line; 356, identifier:line; 357, expression_statement; 357, 358; 358, assignment; 358, 359; 358, 362; 359, attribute; 359, 360; 359, 361; 360, identifier:self; 361, identifier:start_addr; 362, dictionary; 362, 363; 362, 374; 363, pair; 363, 364; 363, 365; 364, string:'CS'; 365, binary_operator:+; 365, 366; 365, 371; 366, binary_operator:*; 366, 367; 366, 370; 367, subscript; 367, 368; 367, 369; 368, identifier:bin; 369, integer:4; 370, integer:256; 371, subscript; 371, 372; 371, 373; 372, identifier:bin; 373, integer:5; 374, pair; 374, 375; 374, 376; 375, string:'IP'; 376, binary_operator:+; 376, 377; 376, 382; 377, binary_operator:*; 377, 378; 377, 381; 378, subscript; 378, 379; 378, 380; 379, identifier:bin; 380, integer:6; 381, integer:256; 382, subscript; 382, 383; 382, 384; 383, identifier:bin; 384, integer:7; 385, elif_clause; 385, 386; 385, 389; 386, comparison_operator:==; 386, 387; 386, 388; 387, identifier:record_type; 388, integer:5; 389, block; 389, 390; 389, 406; 389, 418; 390, if_statement; 390, 391; 390, 398; 391, boolean_operator:or; 391, 392; 391, 395; 392, comparison_operator:!=; 392, 393; 392, 394; 393, identifier:record_length; 394, integer:4; 395, comparison_operator:!=; 395, 396; 395, 397; 396, identifier:addr; 397, integer:0; 398, block; 398, 399; 399, raise_statement; 399, 400; 400, call; 400, 401; 400, 402; 401, identifier:StartLinearAddressRecordError; 402, argument_list; 402, 403; 403, keyword_argument; 403, 404; 403, 405; 404, identifier:line; 405, identifier:line; 406, if_statement; 406, 407; 406, 410; 407, attribute; 407, 408; 407, 409; 408, identifier:self; 409, identifier:start_addr; 410, block; 410, 411; 411, raise_statement; 411, 412; 412, call; 412, 413; 412, 414; 413, identifier:DuplicateStartAddressRecordError; 414, argument_list; 414, 415; 415, keyword_argument; 415, 416; 415, 417; 416, identifier:line; 417, identifier:line; 418, expression_statement; 418, 419; 419, assignment; 419, 420; 419, 423; 420, attribute; 420, 421; 420, 422; 421, identifier:self; 422, identifier:start_addr; 423, dictionary; 423, 424; 424, pair; 424, 425; 424, 426; 425, string:'EIP'; 426, parenthesized_expression; 426, 427; 427, binary_operator:+; 427, 428; 427, 445; 428, binary_operator:+; 428, 429; 428, 440; 429, binary_operator:+; 429, 430; 429, 435; 430, binary_operator:*; 430, 431; 430, 434; 431, subscript; 431, 432; 431, 433; 432, identifier:bin; 433, integer:4; 434, integer:16777216; 435, binary_operator:*; 435, 436; 435, 439; 436, subscript; 436, 437; 436, 438; 437, identifier:bin; 438, integer:5; 439, integer:65536; 440, binary_operator:*; 440, 441; 440, 444; 441, subscript; 441, 442; 441, 443; 442, identifier:bin; 443, integer:6; 444, integer:256; 445, subscript; 445, 446; 445, 447; 446, identifier:bin; 447, integer:7 | def _decode_record(self, s, line=0):
'''Decode one record of HEX file.
@param s line with HEX record.
@param line line number (for error messages).
@raise EndOfFile if EOF record encountered.
'''
s = s.rstrip('\r\n')
if not s:
return
if s[0] == ':':
try:
bin = array('B', unhexlify(asbytes(s[1:])))
except (TypeError, ValueError):
raise HexRecordError(line=line)
length = len(bin)
if length < 5:
raise HexRecordError(line=line)
else:
raise HexRecordError(line=line)
record_length = bin[0]
if length != (5 + record_length):
raise RecordLengthError(line=line)
addr = bin[1]*256 + bin[2]
record_type = bin[3]
if not (0 <= record_type <= 5):
raise RecordTypeError(line=line)
crc = sum(bin)
crc &= 0x0FF
if crc != 0:
raise RecordChecksumError(line=line)
if record_type == 0:
addr += self._offset
for i in range_g(4, 4+record_length):
if not self._buf.get(addr, None) is None:
raise AddressOverlapError(address=addr, line=line)
self._buf[addr] = bin[i]
addr += 1
elif record_type == 1:
if record_length != 0:
raise EOFRecordError(line=line)
raise _EndOfFile
elif record_type == 2:
if record_length != 2 or addr != 0:
raise ExtendedSegmentAddressRecordError(line=line)
self._offset = (bin[4]*256 + bin[5]) * 16
elif record_type == 4:
if record_length != 2 or addr != 0:
raise ExtendedLinearAddressRecordError(line=line)
self._offset = (bin[4]*256 + bin[5]) * 65536
elif record_type == 3:
if record_length != 4 or addr != 0:
raise StartSegmentAddressRecordError(line=line)
if self.start_addr:
raise DuplicateStartAddressRecordError(line=line)
self.start_addr = {'CS': bin[4]*256 + bin[5],
'IP': bin[6]*256 + bin[7],
}
elif record_type == 5:
if record_length != 4 or addr != 0:
raise StartLinearAddressRecordError(line=line)
if self.start_addr:
raise DuplicateStartAddressRecordError(line=line)
self.start_addr = {'EIP': (bin[4]*16777216 +
bin[5]*65536 +
bin[6]*256 +
bin[7]),
} |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_get_start_end; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:end; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:size; 13, None; 14, block; 14, 15; 14, 32; 14, 148; 15, if_statement; 15, 16; 15, 29; 16, boolean_operator:and; 16, 17; 16, 24; 17, comparison_operator:==; 17, 18; 17, 21; 18, tuple; 18, 19; 18, 20; 19, identifier:start; 20, identifier:end; 21, tuple; 21, 22; 21, 23; 22, None; 23, None; 24, comparison_operator:==; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:_buf; 28, dictionary; 29, block; 29, 30; 30, raise_statement; 30, 31; 31, identifier:EmptyIntelHexError; 32, if_statement; 32, 33; 32, 36; 32, 107; 33, comparison_operator:is; 33, 34; 33, 35; 34, identifier:size; 35, None; 36, block; 36, 37; 36, 51; 36, 68; 37, if_statement; 37, 38; 37, 43; 38, comparison_operator:not; 38, 39; 38, 40; 39, None; 40, tuple; 40, 41; 40, 42; 41, identifier:start; 42, identifier:end; 43, block; 43, 44; 44, raise_statement; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:ValueError; 47, argument_list; 47, 48; 48, concatenated_string; 48, 49; 48, 50; 49, string:"tobinarray: you can't use start,end and size"; 50, string:" arguments in the same time"; 51, if_statement; 51, 52; 51, 59; 52, comparison_operator:==; 52, 53; 52, 56; 53, tuple; 53, 54; 53, 55; 54, identifier:start; 55, identifier:end; 56, tuple; 56, 57; 56, 58; 57, None; 58, None; 59, block; 59, 60; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:start; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:minaddr; 67, argument_list; 68, if_statement; 68, 69; 68, 72; 68, 81; 69, comparison_operator:is; 69, 70; 69, 71; 70, identifier:start; 71, None; 72, block; 72, 73; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:end; 76, binary_operator:-; 76, 77; 76, 80; 77, binary_operator:+; 77, 78; 77, 79; 78, identifier:start; 79, identifier:size; 80, integer:1; 81, else_clause; 81, 82; 82, block; 82, 83; 82, 91; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:start; 86, binary_operator:+; 86, 87; 86, 90; 87, binary_operator:-; 87, 88; 87, 89; 88, identifier:end; 89, identifier:size; 90, integer:1; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:<; 92, 93; 92, 94; 93, identifier:start; 94, integer:0; 95, block; 95, 96; 96, raise_statement; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:ValueError; 99, argument_list; 99, 100; 100, binary_operator:%; 100, 101; 100, 104; 101, concatenated_string; 101, 102; 101, 103; 102, string:"tobinarray: invalid size (%d) "; 103, string:"for given end address (%d)"; 104, tuple; 104, 105; 104, 106; 105, identifier:size; 106, identifier:end; 107, else_clause; 107, 108; 108, block; 108, 109; 108, 122; 108, 135; 109, if_statement; 109, 110; 109, 113; 110, comparison_operator:is; 110, 111; 110, 112; 111, identifier:start; 112, None; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:start; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:self; 120, identifier:minaddr; 121, argument_list; 122, if_statement; 122, 123; 122, 126; 123, comparison_operator:is; 123, 124; 123, 125; 124, identifier:end; 125, None; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:end; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:self; 133, identifier:maxaddr; 134, argument_list; 135, if_statement; 135, 136; 135, 139; 136, comparison_operator:>; 136, 137; 136, 138; 137, identifier:start; 138, identifier:end; 139, block; 139, 140; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 145; 142, pattern_list; 142, 143; 142, 144; 143, identifier:start; 144, identifier:end; 145, expression_list; 145, 146; 145, 147; 146, identifier:end; 147, identifier:start; 148, return_statement; 148, 149; 149, expression_list; 149, 150; 149, 151; 150, identifier:start; 151, identifier:end | def _get_start_end(self, start=None, end=None, size=None):
if (start,end) == (None,None) and self._buf == {}:
raise EmptyIntelHexError
if size is not None:
if None not in (start, end):
raise ValueError("tobinarray: you can't use start,end and size"
" arguments in the same time")
if (start, end) == (None, None):
start = self.minaddr()
if start is not None:
end = start + size - 1
else:
start = end - size + 1
if start < 0:
raise ValueError("tobinarray: invalid size (%d) "
"for given end address (%d)" % (size,end))
else:
if start is None:
start = self.minaddr()
if end is None:
end = self.maxaddr()
if start > end:
start, end = end, start
return start, end |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:dump; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tofile; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:width; 10, integer:16; 11, default_parameter; 11, 12; 11, 13; 12, identifier:withpadding; 13, False; 14, block; 14, 15; 14, 32; 14, 39; 14, 50; 14, 147; 14, 156; 15, if_statement; 15, 16; 15, 26; 16, boolean_operator:or; 16, 17; 16, 23; 17, not_operator; 17, 18; 18, call; 18, 19; 18, 20; 19, identifier:isinstance; 20, argument_list; 20, 21; 20, 22; 21, identifier:width; 22, identifier:int; 23, comparison_operator:<; 23, 24; 23, 25; 24, identifier:width; 25, integer:1; 26, block; 26, 27; 27, raise_statement; 27, 28; 28, call; 28, 29; 28, 30; 29, identifier:ValueError; 30, argument_list; 30, 31; 31, string:'width must be a positive integer.'; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:width; 35, call; 35, 36; 35, 37; 36, identifier:int; 37, argument_list; 37, 38; 38, identifier:width; 39, if_statement; 39, 40; 39, 43; 40, comparison_operator:is; 40, 41; 40, 42; 41, identifier:tofile; 42, None; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:tofile; 47, attribute; 47, 48; 47, 49; 48, identifier:sys; 49, identifier:stdout; 50, if_statement; 50, 51; 50, 56; 51, comparison_operator:is; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:start_addr; 55, None; 56, block; 56, 57; 56, 68; 56, 79; 56, 90; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:cs; 60, call; 60, 61; 60, 66; 61, attribute; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:start_addr; 65, identifier:get; 66, argument_list; 66, 67; 67, string:'CS'; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:ip; 71, call; 71, 72; 71, 77; 72, attribute; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:start_addr; 76, identifier:get; 77, argument_list; 77, 78; 78, string:'IP'; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:eip; 82, call; 82, 83; 82, 88; 83, attribute; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:self; 86, identifier:start_addr; 87, identifier:get; 88, argument_list; 88, 89; 89, string:'EIP'; 90, if_statement; 90, 91; 90, 102; 90, 112; 90, 136; 91, boolean_operator:and; 91, 92; 91, 99; 92, boolean_operator:and; 92, 93; 92, 96; 93, comparison_operator:is; 93, 94; 93, 95; 94, identifier:eip; 95, None; 96, comparison_operator:is; 96, 97; 96, 98; 97, identifier:cs; 98, None; 99, comparison_operator:is; 99, 100; 99, 101; 100, identifier:ip; 101, None; 102, block; 102, 103; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:tofile; 107, identifier:write; 108, argument_list; 108, 109; 109, binary_operator:%; 109, 110; 109, 111; 110, string:'EIP = 0x%08X\n'; 111, identifier:eip; 112, elif_clause; 112, 113; 112, 124; 113, boolean_operator:and; 113, 114; 113, 121; 114, boolean_operator:and; 114, 115; 114, 118; 115, comparison_operator:is; 115, 116; 115, 117; 116, identifier:eip; 117, None; 118, comparison_operator:is; 118, 119; 118, 120; 119, identifier:cs; 120, None; 121, comparison_operator:is; 121, 122; 121, 123; 122, identifier:ip; 123, None; 124, block; 124, 125; 125, expression_statement; 125, 126; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:tofile; 129, identifier:write; 130, argument_list; 130, 131; 131, binary_operator:%; 131, 132; 131, 133; 132, string:'CS = 0x%04X, IP = 0x%04X\n'; 133, tuple; 133, 134; 133, 135; 134, identifier:cs; 135, identifier:ip; 136, else_clause; 136, 137; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:tofile; 142, identifier:write; 143, argument_list; 143, 144; 144, binary_operator:%; 144, 145; 144, 146; 145, string:'start_addr = %r\n'; 146, identifier:start_addr; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:addresses; 150, call; 150, 151; 150, 152; 151, identifier:dict_keys; 152, argument_list; 152, 153; 153, attribute; 153, 154; 153, 155; 154, identifier:self; 155, identifier:_buf; 156, if_statement; 156, 157; 156, 158; 157, identifier:addresses; 158, block; 158, 159; 158, 165; 158, 171; 158, 178; 158, 187; 158, 199; 158, 215; 158, 221; 158, 228; 158, 243; 159, expression_statement; 159, 160; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:addresses; 163, identifier:sort; 164, argument_list; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:minaddr; 168, subscript; 168, 169; 168, 170; 169, identifier:addresses; 170, integer:0; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:maxaddr; 174, subscript; 174, 175; 174, 176; 175, identifier:addresses; 176, unary_operator:-; 176, 177; 177, integer:1; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:startaddr; 181, binary_operator:*; 181, 182; 181, 186; 182, parenthesized_expression; 182, 183; 183, binary_operator://; 183, 184; 183, 185; 184, identifier:minaddr; 185, identifier:width; 186, identifier:width; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 190; 189, identifier:endaddr; 190, binary_operator:*; 190, 191; 190, 198; 191, parenthesized_expression; 191, 192; 192, binary_operator:+; 192, 193; 192, 197; 193, parenthesized_expression; 193, 194; 194, binary_operator://; 194, 195; 194, 196; 195, identifier:maxaddr; 196, identifier:width; 197, integer:1; 198, identifier:width; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 202; 201, identifier:maxdigits; 202, call; 202, 203; 202, 204; 203, identifier:max; 204, argument_list; 204, 205; 204, 214; 205, binary_operator:-; 205, 206; 205, 213; 206, call; 206, 207; 206, 208; 207, identifier:len; 208, argument_list; 208, 209; 209, call; 209, 210; 209, 211; 210, identifier:hex; 211, argument_list; 211, 212; 212, identifier:endaddr; 213, integer:2; 214, integer:4; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:templa; 218, binary_operator:%; 218, 219; 218, 220; 219, string:'%%0%dX'; 220, identifier:maxdigits; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:rangewidth; 224, call; 224, 225; 224, 226; 225, identifier:range_l; 226, argument_list; 226, 227; 227, identifier:width; 228, if_statement; 228, 229; 228, 230; 228, 237; 229, identifier:withpadding; 230, block; 230, 231; 231, expression_statement; 231, 232; 232, assignment; 232, 233; 232, 234; 233, identifier:pad; 234, attribute; 234, 235; 234, 236; 235, identifier:self; 236, identifier:padding; 237, else_clause; 237, 238; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, assignment; 240, 241; 240, 242; 241, identifier:pad; 242, None; 243, for_statement; 243, 244; 243, 245; 243, 251; 244, identifier:i; 245, call; 245, 246; 245, 247; 246, identifier:range_g; 247, argument_list; 247, 248; 247, 249; 247, 250; 248, identifier:startaddr; 249, identifier:endaddr; 250, identifier:width; 251, block; 251, 252; 251, 261; 251, 268; 251, 272; 251, 345; 252, expression_statement; 252, 253; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:tofile; 256, identifier:write; 257, argument_list; 257, 258; 258, binary_operator:%; 258, 259; 258, 260; 259, identifier:templa; 260, identifier:i; 261, expression_statement; 261, 262; 262, call; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, identifier:tofile; 265, identifier:write; 266, argument_list; 266, 267; 267, string:' '; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 271; 270, identifier:s; 271, list:[]; 272, for_statement; 272, 273; 272, 274; 272, 275; 273, identifier:j; 274, identifier:rangewidth; 275, block; 275, 276; 275, 290; 276, expression_statement; 276, 277; 277, assignment; 277, 278; 277, 279; 278, identifier:x; 279, call; 279, 280; 279, 285; 280, attribute; 280, 281; 280, 284; 281, attribute; 281, 282; 281, 283; 282, identifier:self; 283, identifier:_buf; 284, identifier:get; 285, argument_list; 285, 286; 285, 289; 286, binary_operator:+; 286, 287; 286, 288; 287, identifier:i; 288, identifier:j; 289, identifier:pad; 290, if_statement; 290, 291; 290, 294; 290, 329; 291, comparison_operator:is; 291, 292; 291, 293; 292, identifier:x; 293, None; 294, block; 294, 295; 294, 304; 295, expression_statement; 295, 296; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:tofile; 299, identifier:write; 300, argument_list; 300, 301; 301, binary_operator:%; 301, 302; 301, 303; 302, string:' %02X'; 303, identifier:x; 304, if_statement; 304, 305; 304, 309; 304, 320; 305, comparison_operator:<=; 305, 306; 305, 307; 305, 308; 306, integer:32; 307, identifier:x; 308, integer:127; 309, block; 309, 310; 310, expression_statement; 310, 311; 311, call; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:s; 314, identifier:append; 315, argument_list; 315, 316; 316, call; 316, 317; 316, 318; 317, identifier:chr; 318, argument_list; 318, 319; 319, identifier:x; 320, else_clause; 320, 321; 321, block; 321, 322; 322, expression_statement; 322, 323; 323, call; 323, 324; 323, 327; 324, attribute; 324, 325; 324, 326; 325, identifier:s; 326, identifier:append; 327, argument_list; 327, 328; 328, string:'.'; 329, else_clause; 329, 330; 330, block; 330, 331; 330, 338; 331, expression_statement; 331, 332; 332, call; 332, 333; 332, 336; 333, attribute; 333, 334; 333, 335; 334, identifier:tofile; 335, identifier:write; 336, argument_list; 336, 337; 337, string:' --'; 338, expression_statement; 338, 339; 339, call; 339, 340; 339, 343; 340, attribute; 340, 341; 340, 342; 341, identifier:s; 342, identifier:append; 343, argument_list; 343, 344; 344, string:' '; 345, expression_statement; 345, 346; 346, call; 346, 347; 346, 350; 347, attribute; 347, 348; 347, 349; 348, identifier:tofile; 349, identifier:write; 350, argument_list; 350, 351; 351, binary_operator:+; 351, 352; 351, 360; 352, binary_operator:+; 352, 353; 352, 354; 353, string:' |'; 354, call; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, string:''; 357, identifier:join; 358, argument_list; 358, 359; 359, identifier:s; 360, string:'|\n' | def dump(self, tofile=None, width=16, withpadding=False):
if not isinstance(width,int) or width < 1:
raise ValueError('width must be a positive integer.')
width = int(width)
if tofile is None:
tofile = sys.stdout
if self.start_addr is not None:
cs = self.start_addr.get('CS')
ip = self.start_addr.get('IP')
eip = self.start_addr.get('EIP')
if eip is not None and cs is None and ip is None:
tofile.write('EIP = 0x%08X\n' % eip)
elif eip is None and cs is not None and ip is not None:
tofile.write('CS = 0x%04X, IP = 0x%04X\n' % (cs, ip))
else:
tofile.write('start_addr = %r\n' % start_addr)
addresses = dict_keys(self._buf)
if addresses:
addresses.sort()
minaddr = addresses[0]
maxaddr = addresses[-1]
startaddr = (minaddr // width) * width
endaddr = ((maxaddr // width) + 1) * width
maxdigits = max(len(hex(endaddr)) - 2, 4)
templa = '%%0%dX' % maxdigits
rangewidth = range_l(width)
if withpadding:
pad = self.padding
else:
pad = None
for i in range_g(startaddr, endaddr, width):
tofile.write(templa % i)
tofile.write(' ')
s = []
for j in rangewidth:
x = self._buf.get(i+j, pad)
if x is not None:
tofile.write(' %02X' % x)
if 32 <= x < 127:
s.append(chr(x))
else:
s.append('.')
else:
tofile.write(' --')
s.append(' ')
tofile.write(' |' + ''.join(s) + '|\n') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_recipe_folder; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:recipe_folder; 6, default_parameter; 6, 7; 6, 8; 7, identifier:whitelist; 8, None; 9, block; 9, 10; 9, 22; 9, 31; 9, 94; 10, if_statement; 10, 11; 10, 14; 11, comparison_operator:is; 11, 12; 11, 13; 12, identifier:whitelist; 13, None; 14, block; 14, 15; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:whitelist; 18, call; 18, 19; 18, 20; 19, identifier:set; 20, argument_list; 20, 21; 21, identifier:whitelist; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:==; 23, 24; 23, 25; 24, identifier:recipe_folder; 25, string:''; 26, block; 26, 27; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:recipe_folder; 30, string:'.'; 31, for_statement; 31, 32; 31, 33; 31, 50; 32, identifier:yaml_file; 33, list_comprehension; 33, 34; 33, 35; 33, 43; 34, identifier:x; 35, for_in_clause; 35, 36; 35, 37; 36, identifier:x; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:os; 40, identifier:listdir; 41, argument_list; 41, 42; 42, identifier:recipe_folder; 43, if_clause; 43, 44; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:x; 47, identifier:endswith; 48, argument_list; 48, 49; 49, string:'.yaml'; 50, block; 50, 51; 50, 61; 50, 84; 51, if_statement; 51, 52; 51, 59; 52, boolean_operator:and; 52, 53; 52, 56; 53, comparison_operator:is; 53, 54; 53, 55; 54, identifier:whitelist; 55, None; 56, comparison_operator:not; 56, 57; 56, 58; 57, identifier:yaml_file; 58, identifier:whitelist; 59, block; 59, 60; 60, continue_statement; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:recipe; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:RecipeObject; 67, identifier:FromFile; 68, argument_list; 68, 69; 68, 78; 68, 81; 69, call; 69, 70; 69, 75; 70, attribute; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:os; 73, identifier:path; 74, identifier:join; 75, argument_list; 75, 76; 75, 77; 76, identifier:recipe_folder; 77, identifier:yaml_file; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:_recipe_actions; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:_recipe_resources; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 93; 86, subscript; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:_recipes; 90, attribute; 90, 91; 90, 92; 91, identifier:recipe; 92, identifier:name; 93, identifier:recipe; 94, for_statement; 94, 95; 94, 96; 94, 113; 95, identifier:ship_file; 96, list_comprehension; 96, 97; 96, 98; 96, 106; 97, identifier:x; 98, for_in_clause; 98, 99; 98, 100; 99, identifier:x; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:os; 103, identifier:listdir; 104, argument_list; 104, 105; 105, identifier:recipe_folder; 106, if_clause; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:x; 110, identifier:endswith; 111, argument_list; 111, 112; 112, string:'.ship'; 113, block; 113, 114; 113, 124; 113, 147; 114, if_statement; 114, 115; 114, 122; 115, boolean_operator:and; 115, 116; 115, 119; 116, comparison_operator:is; 116, 117; 116, 118; 117, identifier:whitelist; 118, None; 119, comparison_operator:not; 119, 120; 119, 121; 120, identifier:ship_file; 121, identifier:whitelist; 122, block; 122, 123; 123, continue_statement; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:recipe; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:RecipeObject; 130, identifier:FromArchive; 131, argument_list; 131, 132; 131, 141; 131, 144; 132, call; 132, 133; 132, 138; 133, attribute; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:os; 136, identifier:path; 137, identifier:join; 138, argument_list; 138, 139; 138, 140; 139, identifier:recipe_folder; 140, identifier:ship_file; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:_recipe_actions; 144, attribute; 144, 145; 144, 146; 145, identifier:self; 146, identifier:_recipe_resources; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 156; 149, subscript; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:self; 152, identifier:_recipes; 153, attribute; 153, 154; 153, 155; 154, identifier:recipe; 155, identifier:name; 156, identifier:recipe | def add_recipe_folder(self, recipe_folder, whitelist=None):
if whitelist is not None:
whitelist = set(whitelist)
if recipe_folder == '':
recipe_folder = '.'
for yaml_file in [x for x in os.listdir(recipe_folder) if x.endswith('.yaml')]:
if whitelist is not None and yaml_file not in whitelist:
continue
recipe = RecipeObject.FromFile(os.path.join(recipe_folder, yaml_file), self._recipe_actions, self._recipe_resources)
self._recipes[recipe.name] = recipe
for ship_file in [x for x in os.listdir(recipe_folder) if x.endswith('.ship')]:
if whitelist is not None and ship_file not in whitelist:
continue
recipe = RecipeObject.FromArchive(os.path.join(recipe_folder, ship_file), self._recipe_actions, self._recipe_resources)
self._recipes[recipe.name] = recipe |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:include_reset; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:accelerated; 10, True; 11, block; 11, 12; 11, 20; 11, 31; 11, 35; 11, 39; 11, 92; 11, 113; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:_start_tick; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:tick_count; 20, if_statement; 20, 21; 20, 29; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_check_stop_conditions; 25, argument_list; 25, 26; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:sensor_graph; 29, block; 29, 30; 30, return_statement; 31, if_statement; 31, 32; 31, 33; 32, identifier:include_reset; 33, block; 33, 34; 34, pass_statement; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:i; 38, None; 39, for_statement; 39, 40; 39, 43; 39, 49; 40, pattern_list; 40, 41; 40, 42; 41, identifier:i; 42, identifier:stim; 43, call; 43, 44; 43, 45; 44, identifier:enumerate; 45, argument_list; 45, 46; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:stimuli; 49, block; 49, 50; 49, 58; 49, 77; 50, if_statement; 50, 51; 50, 56; 51, comparison_operator:!=; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:stim; 54, identifier:time; 55, integer:0; 56, block; 56, 57; 57, break_statement; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:reading; 61, call; 61, 62; 61, 63; 62, identifier:IOTileReading; 63, argument_list; 63, 64; 63, 67; 63, 74; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:tick_count; 67, call; 67, 68; 67, 73; 68, attribute; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:stim; 71, identifier:stream; 72, identifier:encode; 73, argument_list; 74, attribute; 74, 75; 74, 76; 75, identifier:stim; 76, identifier:value; 77, expression_statement; 77, 78; 78, call; 78, 79; 78, 84; 79, attribute; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:sensor_graph; 83, identifier:process_input; 84, argument_list; 84, 85; 84, 88; 84, 89; 85, attribute; 85, 86; 85, 87; 86, identifier:stim; 87, identifier:stream; 88, identifier:reading; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:rpc_executor; 92, if_statement; 92, 93; 92, 100; 93, boolean_operator:and; 93, 94; 93, 97; 94, comparison_operator:is; 94, 95; 94, 96; 95, identifier:i; 96, None; 97, comparison_operator:>; 97, 98; 97, 99; 98, identifier:i; 99, integer:0; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:self; 105, identifier:stimuli; 106, subscript; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:stimuli; 110, slice; 110, 111; 110, 112; 111, identifier:i; 112, colon; 113, while_statement; 113, 114; 113, 123; 114, not_operator; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:_check_stop_conditions; 119, argument_list; 119, 120; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:sensor_graph; 123, block; 123, 124; 123, 130; 123, 136; 123, 142; 123, 146; 123, 201; 123, 222; 123, 231; 123, 306; 123, 312; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:now; 127, call; 127, 128; 127, 129; 128, identifier:monotonic; 129, argument_list; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:next_tick; 133, binary_operator:+; 133, 134; 133, 135; 134, identifier:now; 135, float:1.0; 136, expression_statement; 136, 137; 137, augmented_assignment:+=; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:self; 140, identifier:tick_count; 141, integer:1; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:i; 145, None; 146, for_statement; 146, 147; 146, 150; 146, 156; 147, pattern_list; 147, 148; 147, 149; 148, identifier:i; 149, identifier:stim; 150, call; 150, 151; 150, 152; 151, identifier:enumerate; 152, argument_list; 152, 153; 153, attribute; 153, 154; 153, 155; 154, identifier:self; 155, identifier:stimuli; 156, block; 156, 157; 156, 167; 156, 186; 157, if_statement; 157, 158; 157, 165; 158, comparison_operator:!=; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:stim; 161, identifier:time; 162, attribute; 162, 163; 162, 164; 163, identifier:self; 164, identifier:tick_count; 165, block; 165, 166; 166, break_statement; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:reading; 170, call; 170, 171; 170, 172; 171, identifier:IOTileReading; 172, argument_list; 172, 173; 172, 176; 172, 183; 173, attribute; 173, 174; 173, 175; 174, identifier:self; 175, identifier:tick_count; 176, call; 176, 177; 176, 182; 177, attribute; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:stim; 180, identifier:stream; 181, identifier:encode; 182, argument_list; 183, attribute; 183, 184; 183, 185; 184, identifier:stim; 185, identifier:value; 186, expression_statement; 186, 187; 187, call; 187, 188; 187, 193; 188, attribute; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:self; 191, identifier:sensor_graph; 192, identifier:process_input; 193, argument_list; 193, 194; 193, 197; 193, 198; 194, attribute; 194, 195; 194, 196; 195, identifier:stim; 196, identifier:stream; 197, identifier:reading; 198, attribute; 198, 199; 198, 200; 199, identifier:self; 200, identifier:rpc_executor; 201, if_statement; 201, 202; 201, 209; 202, boolean_operator:and; 202, 203; 202, 206; 203, comparison_operator:is; 203, 204; 203, 205; 204, identifier:i; 205, None; 206, comparison_operator:>; 206, 207; 206, 208; 207, identifier:i; 208, integer:0; 209, block; 209, 210; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:self; 214, identifier:stimuli; 215, subscript; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:self; 218, identifier:stimuli; 219, slice; 219, 220; 219, 221; 220, identifier:i; 221, colon; 222, expression_statement; 222, 223; 223, call; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:self; 226, identifier:_check_additional_ticks; 227, argument_list; 227, 228; 228, attribute; 228, 229; 228, 230; 229, identifier:self; 230, identifier:tick_count; 231, if_statement; 231, 232; 231, 240; 232, comparison_operator:==; 232, 233; 232, 239; 233, parenthesized_expression; 233, 234; 234, binary_operator:%; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:self; 237, identifier:tick_count; 238, integer:10; 239, integer:0; 240, block; 240, 241; 240, 258; 240, 271; 240, 293; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:reading; 244, call; 244, 245; 244, 246; 245, identifier:IOTileReading; 246, argument_list; 246, 247; 246, 250; 246, 255; 247, attribute; 247, 248; 247, 249; 248, identifier:self; 249, identifier:tick_count; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:system_tick; 253, identifier:encode; 254, argument_list; 255, attribute; 255, 256; 255, 257; 256, identifier:self; 257, identifier:tick_count; 258, expression_statement; 258, 259; 259, call; 259, 260; 259, 265; 260, attribute; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:self; 263, identifier:sensor_graph; 264, identifier:process_input; 265, argument_list; 265, 266; 265, 267; 265, 268; 266, identifier:system_tick; 267, identifier:reading; 268, attribute; 268, 269; 268, 270; 269, identifier:self; 270, identifier:rpc_executor; 271, expression_statement; 271, 272; 272, assignment; 272, 273; 272, 274; 273, identifier:reading; 274, call; 274, 275; 274, 276; 275, identifier:IOTileReading; 276, argument_list; 276, 277; 276, 280; 276, 285; 277, attribute; 277, 278; 277, 279; 278, identifier:self; 279, identifier:tick_count; 280, call; 280, 281; 280, 284; 281, attribute; 281, 282; 281, 283; 282, identifier:battery_voltage; 283, identifier:encode; 284, argument_list; 285, call; 285, 286; 285, 287; 286, identifier:int; 287, argument_list; 287, 288; 288, binary_operator:*; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:self; 291, identifier:voltage; 292, integer:65536; 293, expression_statement; 293, 294; 294, call; 294, 295; 294, 300; 295, attribute; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:self; 298, identifier:sensor_graph; 299, identifier:process_input; 300, argument_list; 300, 301; 300, 302; 300, 303; 301, identifier:battery_voltage; 302, identifier:reading; 303, attribute; 303, 304; 303, 305; 304, identifier:self; 305, identifier:rpc_executor; 306, expression_statement; 306, 307; 307, assignment; 307, 308; 307, 309; 308, identifier:now; 309, call; 309, 310; 309, 311; 310, identifier:monotonic; 311, argument_list; 312, if_statement; 312, 313; 312, 321; 313, boolean_operator:and; 313, 314; 313, 317; 314, parenthesized_expression; 314, 315; 315, not_operator; 315, 316; 316, identifier:accelerated; 317, parenthesized_expression; 317, 318; 318, comparison_operator:<; 318, 319; 318, 320; 319, identifier:now; 320, identifier:next_tick; 321, block; 321, 322; 322, expression_statement; 322, 323; 323, call; 323, 324; 323, 327; 324, attribute; 324, 325; 324, 326; 325, identifier:time; 326, identifier:sleep; 327, argument_list; 327, 328; 328, binary_operator:-; 328, 329; 328, 330; 329, identifier:next_tick; 330, identifier:now | def run(self, include_reset=True, accelerated=True):
self._start_tick = self.tick_count
if self._check_stop_conditions(self.sensor_graph):
return
if include_reset:
pass
i = None
for i, stim in enumerate(self.stimuli):
if stim.time != 0:
break
reading = IOTileReading(self.tick_count, stim.stream.encode(), stim.value)
self.sensor_graph.process_input(stim.stream, reading, self.rpc_executor)
if i is not None and i > 0:
self.stimuli = self.stimuli[i:]
while not self._check_stop_conditions(self.sensor_graph):
now = monotonic()
next_tick = now + 1.0
self.tick_count += 1
i = None
for i, stim in enumerate(self.stimuli):
if stim.time != self.tick_count:
break
reading = IOTileReading(self.tick_count, stim.stream.encode(), stim.value)
self.sensor_graph.process_input(stim.stream, reading, self.rpc_executor)
if i is not None and i > 0:
self.stimuli = self.stimuli[i:]
self._check_additional_ticks(self.tick_count)
if (self.tick_count % 10) == 0:
reading = IOTileReading(self.tick_count, system_tick.encode(), self.tick_count)
self.sensor_graph.process_input(system_tick, reading, self.rpc_executor)
reading = IOTileReading(self.tick_count, battery_voltage.encode(), int(self.voltage * 65536))
self.sensor_graph.process_input(battery_voltage, reading, self.rpc_executor)
now = monotonic()
if (not accelerated) and (now < next_tick):
time.sleep(next_tick - now) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_convert_default_value; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:default; 6, block; 6, 7; 6, 14; 6, 45; 6, 73; 6, 85; 6, 99; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:default; 10, None; 11, block; 11, 12; 12, return_statement; 12, 13; 13, None; 14, if_statement; 14, 15; 14, 20; 15, call; 15, 16; 15, 17; 16, identifier:isinstance; 17, argument_list; 17, 18; 17, 19; 18, identifier:default; 19, identifier:str; 20, block; 20, 21; 20, 37; 21, if_statement; 21, 22; 21, 27; 22, comparison_operator:==; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:special_type; 26, string:'string'; 27, block; 27, 28; 28, return_statement; 28, 29; 29, binary_operator:+; 29, 30; 29, 36; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:default; 33, identifier:encode; 34, argument_list; 34, 35; 35, string:'utf-8'; 36, string:b'\0'; 37, raise_statement; 37, 38; 38, call; 38, 39; 38, 40; 39, identifier:DataError; 40, argument_list; 40, 41; 40, 42; 41, string:"You can only pass a unicode string if you are declaring a string type config variable"; 42, keyword_argument; 42, 43; 42, 44; 43, identifier:default; 44, identifier:default; 45, if_statement; 45, 46; 45, 53; 46, call; 46, 47; 46, 48; 47, identifier:isinstance; 48, argument_list; 48, 49; 48, 50; 49, identifier:default; 50, tuple; 50, 51; 50, 52; 51, identifier:bytes; 52, identifier:bytearray; 53, block; 53, 54; 53, 71; 54, if_statement; 54, 55; 54, 66; 55, boolean_operator:and; 55, 56; 55, 61; 56, comparison_operator:==; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:special_type; 60, string:'string'; 61, call; 61, 62; 61, 63; 62, identifier:isinstance; 63, argument_list; 63, 64; 63, 65; 64, identifier:default; 65, identifier:bytes; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, augmented_assignment:+=; 68, 69; 68, 70; 69, identifier:default; 70, string:b'\0'; 71, return_statement; 71, 72; 72, identifier:default; 73, if_statement; 73, 74; 73, 79; 74, call; 74, 75; 74, 76; 75, identifier:isinstance; 76, argument_list; 76, 77; 76, 78; 77, identifier:default; 78, identifier:int; 79, block; 79, 80; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:default; 83, list:[default]; 83, 84; 84, identifier:default; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:format_string; 88, binary_operator:+; 88, 89; 88, 90; 89, string:"<"; 90, parenthesized_expression; 90, 91; 91, binary_operator:*; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:self; 94, identifier:base_type; 95, call; 95, 96; 95, 97; 96, identifier:len; 97, argument_list; 97, 98; 98, identifier:default; 99, return_statement; 99, 100; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:struct; 103, identifier:pack; 104, argument_list; 104, 105; 104, 106; 105, identifier:format_string; 106, list_splat; 106, 107; 107, identifier:default | def _convert_default_value(self, default):
if default is None:
return None
if isinstance(default, str):
if self.special_type == 'string':
return default.encode('utf-8') + b'\0'
raise DataError("You can only pass a unicode string if you are declaring a string type config variable", default=default)
if isinstance(default, (bytes, bytearray)):
if self.special_type == 'string' and isinstance(default, bytes):
default += b'\0'
return default
if isinstance(default, int):
default = [default]
format_string = "<" + (self.base_type*len(default))
return struct.pack(format_string, *default) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:latch; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 26; 5, 39; 5, 53; 5, 102; 5, 123; 5, 135; 5, 169; 6, if_statement; 6, 7; 6, 15; 7, comparison_operator:==; 7, 8; 7, 14; 8, call; 8, 9; 8, 10; 9, identifier:len; 10, argument_list; 10, 11; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:current_value; 14, integer:0; 15, block; 15, 16; 16, raise_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:DataError; 19, argument_list; 19, 20; 19, 21; 20, string:"There was no data in a config variable during latching"; 21, keyword_argument; 21, 22; 21, 23; 22, identifier:name; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:name; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:remaining; 29, binary_operator:%; 29, 30; 29, 36; 30, call; 30, 31; 30, 32; 31, identifier:len; 32, argument_list; 32, 33; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:current_value; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:unit_size; 39, if_statement; 39, 40; 39, 43; 40, comparison_operator:>; 40, 41; 40, 42; 41, identifier:remaining; 42, integer:0; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, augmented_assignment:+=; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:current_value; 49, call; 49, 50; 49, 51; 50, identifier:bytearray; 51, argument_list; 51, 52; 52, identifier:remaining; 53, if_statement; 53, 54; 53, 59; 54, comparison_operator:==; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:special_type; 58, string:'string'; 59, block; 59, 60; 59, 85; 60, if_statement; 60, 61; 60, 69; 61, comparison_operator:!=; 61, 62; 61, 68; 62, subscript; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:current_value; 66, unary_operator:-; 66, 67; 67, integer:1; 68, integer:0; 69, block; 69, 70; 70, raise_statement; 70, 71; 71, call; 71, 72; 71, 73; 72, identifier:DataError; 73, argument_list; 73, 74; 73, 75; 73, 80; 74, string:"String type was specified by data did not end with a null byte"; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:data; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:current_value; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:name; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:name; 85, return_statement; 85, 86; 86, call; 86, 87; 86, 100; 87, attribute; 87, 88; 87, 99; 88, call; 88, 89; 88, 90; 89, identifier:bytes; 90, argument_list; 90, 91; 91, subscript; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:self; 94, identifier:current_value; 95, slice; 95, 96; 95, 97; 96, colon; 97, unary_operator:-; 97, 98; 98, integer:1; 99, identifier:decode; 100, argument_list; 100, 101; 101, string:'utf-8'; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:fmt_code; 105, binary_operator:+; 105, 106; 105, 107; 106, string:"<"; 107, parenthesized_expression; 107, 108; 108, binary_operator:*; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:base_type; 112, parenthesized_expression; 112, 113; 113, binary_operator://; 113, 114; 113, 120; 114, call; 114, 115; 114, 116; 115, identifier:len; 116, argument_list; 116, 117; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:current_value; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:unit_size; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:data; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:struct; 129, identifier:unpack; 130, argument_list; 130, 131; 130, 132; 131, identifier:fmt_code; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:current_value; 135, if_statement; 135, 136; 135, 139; 135, 147; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:variable; 139, block; 139, 140; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:data; 143, call; 143, 144; 143, 145; 144, identifier:list; 145, argument_list; 145, 146; 146, identifier:data; 147, else_clause; 147, 148; 148, block; 148, 149; 148, 155; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:data; 152, subscript; 152, 153; 152, 154; 153, identifier:data; 154, integer:0; 155, if_statement; 155, 156; 155, 161; 156, comparison_operator:==; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:self; 159, identifier:special_type; 160, string:'bool'; 161, block; 161, 162; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 165; 164, identifier:data; 165, call; 165, 166; 165, 167; 166, identifier:bool; 167, argument_list; 167, 168; 168, identifier:data; 169, return_statement; 169, 170; 170, identifier:data | def latch(self):
if len(self.current_value) == 0:
raise DataError("There was no data in a config variable during latching", name=self.name)
remaining = len(self.current_value) % self.unit_size
if remaining > 0:
self.current_value += bytearray(remaining)
if self.special_type == 'string':
if self.current_value[-1] != 0:
raise DataError("String type was specified by data did not end with a null byte", data=self.current_value, name=self.name)
return bytes(self.current_value[:-1]).decode('utf-8')
fmt_code = "<" + (self.base_type * (len(self.current_value) // self.unit_size))
data = struct.unpack(fmt_code, self.current_value)
if self.variable:
data = list(data)
else:
data = data[0]
if self.special_type == 'bool':
data = bool(data)
return data |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_contents_dir; 3, parameters; 3, 4; 4, identifier:node; 5, block; 5, 6; 5, 10; 5, 46; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:contents; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 28; 11, identifier:n; 12, call; 12, 13; 12, 14; 13, identifier:sorted; 14, argument_list; 14, 15; 14, 20; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:node; 18, identifier:children; 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:t; 25, attribute; 25, 26; 25, 27; 26, identifier:t; 27, identifier:name; 28, block; 28, 29; 29, expression_statement; 29, 30; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:contents; 33, identifier:append; 34, argument_list; 34, 35; 35, binary_operator:%; 35, 36; 35, 37; 36, string:'%s %s\n'; 37, tuple; 37, 38; 37, 43; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:n; 41, identifier:get_csig; 42, argument_list; 43, attribute; 43, 44; 43, 45; 44, identifier:n; 45, identifier:name; 46, return_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, string:''; 50, identifier:join; 51, argument_list; 51, 52; 52, identifier:contents | def get_contents_dir(node):
contents = []
for n in sorted(node.children(), key=lambda t: t.name):
contents.append('%s %s\n' % (n.get_csig(), n.name))
return ''.join(contents) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 43; 5, 80; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:depends; 11, None; 12, block; 12, 13; 13, for_statement; 13, 14; 13, 15; 13, 18; 14, identifier:d; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:depends; 18, block; 18, 19; 19, if_statement; 19, 20; 19, 25; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:d; 23, identifier:missing; 24, argument_list; 25, block; 25, 26; 25, 30; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:msg; 29, string:"Explicit dependency `%s' not found, needed by target `%s'."; 30, raise_statement; 30, 31; 31, call; 31, 32; 31, 37; 32, attribute; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:SCons; 35, identifier:Errors; 36, identifier:StopError; 37, argument_list; 37, 38; 38, binary_operator:%; 38, 39; 38, 40; 39, identifier:msg; 40, tuple; 40, 41; 40, 42; 41, identifier:d; 42, identifier:self; 43, if_statement; 43, 44; 43, 49; 44, comparison_operator:is; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:implicit; 48, None; 49, block; 49, 50; 50, for_statement; 50, 51; 50, 52; 50, 55; 51, identifier:i; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:implicit; 55, block; 55, 56; 56, if_statement; 56, 57; 56, 62; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:i; 60, identifier:missing; 61, argument_list; 62, block; 62, 63; 62, 67; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:msg; 66, string:"Implicit dependency `%s' not found, needed by target `%s'."; 67, raise_statement; 67, 68; 68, call; 68, 69; 68, 74; 69, attribute; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:SCons; 72, identifier:Errors; 73, identifier:StopError; 74, argument_list; 74, 75; 75, binary_operator:%; 75, 76; 75, 77; 76, identifier:msg; 77, tuple; 77, 78; 77, 79; 78, identifier:i; 79, identifier:self; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:binfo; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:self; 88, identifier:get_binfo; 89, argument_list | def prepare(self):
if self.depends is not None:
for d in self.depends:
if d.missing():
msg = "Explicit dependency `%s' not found, needed by target `%s'."
raise SCons.Errors.StopError(msg % (d, self))
if self.implicit is not None:
for i in self.implicit:
if i.missing():
msg = "Implicit dependency `%s' not found, needed by target `%s'."
raise SCons.Errors.StopError(msg % (i, self))
self.binfo = self.get_binfo() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:scan; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 20; 5, 28; 5, 34; 5, 43; 5, 51; 5, 59; 5, 125; 5, 136; 5, 144; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:implicit; 11, None; 12, block; 12, 13; 13, return_statement; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:implicit; 19, list:[]; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:implicit_set; 25, call; 25, 26; 25, 27; 26, identifier:set; 27, argument_list; 28, expression_statement; 28, 29; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:_children_reset; 33, argument_list; 34, if_statement; 34, 35; 34, 41; 35, not_operator; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:has_builder; 40, argument_list; 41, block; 41, 42; 42, return_statement; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:build_env; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:get_build_env; 50, argument_list; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:executor; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:get_executor; 58, argument_list; 59, if_statement; 59, 60; 59, 64; 60, boolean_operator:and; 60, 61; 60, 62; 61, identifier:implicit_cache; 62, not_operator; 62, 63; 63, identifier:implicit_deps_changed; 64, block; 64, 65; 64, 73; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:implicit; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:get_stored_implicit; 72, argument_list; 73, if_statement; 73, 74; 73, 77; 74, comparison_operator:is; 74, 75; 74, 76; 75, identifier:implicit; 76, None; 77, block; 77, 78; 77, 93; 77, 103; 78, for_statement; 78, 79; 78, 80; 78, 85; 79, identifier:tgt; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:executor; 83, identifier:get_all_targets; 84, argument_list; 85, block; 85, 86; 86, expression_statement; 86, 87; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:tgt; 90, identifier:add_to_implicit; 91, argument_list; 91, 92; 92, identifier:implicit; 93, if_statement; 93, 94; 93, 101; 94, boolean_operator:or; 94, 95; 94, 96; 95, identifier:implicit_deps_unchanged; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:is_up_to_date; 100, argument_list; 101, block; 101, 102; 102, return_statement; 103, for_statement; 103, 104; 103, 105; 103, 110; 104, identifier:tgt; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:executor; 108, identifier:get_all_targets; 109, argument_list; 110, block; 110, 111; 110, 117; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:tgt; 115, identifier:implicit; 116, list:[]; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:tgt; 121, identifier:implicit_set; 122, call; 122, 123; 122, 124; 123, identifier:set; 124, argument_list; 125, expression_statement; 125, 126; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:executor; 129, identifier:scan_sources; 130, argument_list; 130, 131; 131, attribute; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:builder; 135, identifier:source_scanner; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:scanner; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:get_target_scanner; 143, argument_list; 144, if_statement; 144, 145; 144, 146; 145, identifier:scanner; 146, block; 146, 147; 147, expression_statement; 147, 148; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:executor; 151, identifier:scan_targets; 152, argument_list; 152, 153; 153, identifier:scanner | def scan(self):
if self.implicit is not None:
return
self.implicit = []
self.implicit_set = set()
self._children_reset()
if not self.has_builder():
return
build_env = self.get_build_env()
executor = self.get_executor()
if implicit_cache and not implicit_deps_changed:
implicit = self.get_stored_implicit()
if implicit is not None:
for tgt in executor.get_all_targets():
tgt.add_to_implicit(implicit)
if implicit_deps_unchanged or self.is_up_to_date():
return
for tgt in executor.get_all_targets():
tgt.implicit = []
tgt.implicit_set = set()
executor.scan_sources(self.builder.source_scanner)
scanner = self.get_target_scanner()
if scanner:
executor.scan_targets(scanner) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_binfo; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 24; 5, 30; 5, 38; 5, 44; 5, 77; 5, 111; 5, 117; 5, 139; 5, 155; 5, 163; 5, 183; 5, 193; 5, 213; 6, try_statement; 6, 7; 6, 12; 7, block; 7, 8; 8, return_statement; 8, 9; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:binfo; 12, except_clause; 12, 13; 12, 14; 13, identifier:AttributeError; 14, block; 14, 15; 15, pass_statement; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:binfo; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:new_binfo; 23, argument_list; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:binfo; 29, identifier:binfo; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:executor; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:get_executor; 37, argument_list; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:ignore_set; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:ignore_set; 44, if_statement; 44, 45; 44, 50; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:has_builder; 49, argument_list; 50, block; 50, 51; 50, 60; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:binfo; 55, identifier:bact; 56, call; 56, 57; 56, 58; 57, identifier:str; 58, argument_list; 58, 59; 59, identifier:executor; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:binfo; 64, identifier:bactsig; 65, call; 65, 66; 65, 71; 66, attribute; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:SCons; 69, identifier:Util; 70, identifier:MD5signature; 71, argument_list; 71, 72; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:executor; 75, identifier:get_contents; 76, argument_list; 77, if_statement; 77, 78; 77, 81; 77, 97; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:_specific_sources; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:sources; 85, list_comprehension; 85, 86; 85, 87; 85, 92; 86, identifier:s; 87, for_in_clause; 87, 88; 87, 89; 88, identifier:s; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:sources; 92, if_clause; 92, 93; 93, not_operator; 93, 94; 94, comparison_operator:in; 94, 95; 94, 96; 95, identifier:s; 96, identifier:ignore_set; 97, else_clause; 97, 98; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:sources; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:executor; 105, identifier:get_unignored_sources; 106, argument_list; 106, 107; 106, 108; 107, identifier:self; 108, attribute; 108, 109; 108, 110; 109, identifier:self; 110, identifier:ignore; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:seen; 114, call; 114, 115; 114, 116; 115, identifier:set; 116, argument_list; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:binfo; 121, identifier:bsources; 122, list_comprehension; 122, 123; 122, 124; 122, 127; 123, identifier:s; 124, for_in_clause; 124, 125; 124, 126; 125, identifier:s; 126, identifier:sources; 127, if_clause; 127, 128; 128, boolean_operator:and; 128, 129; 128, 132; 129, comparison_operator:not; 129, 130; 129, 131; 130, identifier:s; 131, identifier:seen; 132, not_operator; 132, 133; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:seen; 136, identifier:add; 137, argument_list; 137, 138; 138, identifier:s; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:binfo; 143, identifier:bsourcesigs; 144, list_comprehension; 144, 145; 144, 150; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:s; 148, identifier:get_ninfo; 149, argument_list; 150, for_in_clause; 150, 151; 150, 152; 151, identifier:s; 152, attribute; 152, 153; 152, 154; 153, identifier:binfo; 154, identifier:bsources; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:binfo; 159, identifier:bdepends; 160, attribute; 160, 161; 160, 162; 161, identifier:self; 162, identifier:depends; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:binfo; 167, identifier:bdependsigs; 168, list_comprehension; 168, 169; 168, 174; 168, 179; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:d; 172, identifier:get_ninfo; 173, argument_list; 174, for_in_clause; 174, 175; 174, 176; 175, identifier:d; 176, attribute; 176, 177; 176, 178; 177, identifier:self; 178, identifier:depends; 179, if_clause; 179, 180; 180, comparison_operator:not; 180, 181; 180, 182; 181, identifier:d; 182, identifier:ignore_set; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:binfo; 187, identifier:bimplicit; 188, boolean_operator:or; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:self; 191, identifier:implicit; 192, list:[]; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:binfo; 197, identifier:bimplicitsigs; 198, list_comprehension; 198, 199; 198, 204; 198, 209; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:i; 202, identifier:get_ninfo; 203, argument_list; 204, for_in_clause; 204, 205; 204, 206; 205, identifier:i; 206, attribute; 206, 207; 206, 208; 207, identifier:binfo; 208, identifier:bimplicit; 209, if_clause; 209, 210; 210, comparison_operator:not; 210, 211; 210, 212; 211, identifier:i; 212, identifier:ignore_set; 213, return_statement; 213, 214; 214, identifier:binfo | def get_binfo(self):
try:
return self.binfo
except AttributeError:
pass
binfo = self.new_binfo()
self.binfo = binfo
executor = self.get_executor()
ignore_set = self.ignore_set
if self.has_builder():
binfo.bact = str(executor)
binfo.bactsig = SCons.Util.MD5signature(executor.get_contents())
if self._specific_sources:
sources = [ s for s in self.sources if not s in ignore_set]
else:
sources = executor.get_unignored_sources(self, self.ignore)
seen = set()
binfo.bsources = [s for s in sources if s not in seen and not seen.add(s)]
binfo.bsourcesigs = [s.get_ninfo() for s in binfo.bsources]
binfo.bdepends = self.depends
binfo.bdependsigs = [d.get_ninfo() for d in self.depends if d not in ignore_set]
binfo.bimplicit = self.implicit or []
binfo.bimplicitsigs = [i.get_ninfo() for i in binfo.bimplicit if i not in ignore_set]
return binfo |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:main; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:argv; 6, None; 7, block; 7, 8; 7, 23; 7, 30; 7, 36; 7, 42; 7, 46; 7, 54; 7, 89; 7, 96; 7, 104; 7, 112; 7, 120; 7, 126; 7, 134; 7, 152; 7, 156; 7, 215; 7, 230; 7, 235; 7, 361; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:argv; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:argv; 16, subscript; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:sys; 19, identifier:argv; 20, slice; 20, 21; 20, 22; 21, integer:1; 22, colon; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:args; 26, call; 26, 27; 26, 28; 27, identifier:parse_global_args; 28, argument_list; 28, 29; 29, identifier:argv; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:type_system; 34, identifier:interactive; 35, True; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:line; 39, attribute; 39, 40; 39, 41; 40, identifier:args; 41, identifier:commands; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:timeout_thread; 45, None; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:timeout_stop_event; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:threading; 52, identifier:Event; 53, argument_list; 54, if_statement; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:args; 57, identifier:timeout; 58, block; 58, 59; 58, 77; 58, 83; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:timeout_thread; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:threading; 65, identifier:Thread; 66, argument_list; 66, 67; 66, 70; 67, keyword_argument; 67, 68; 67, 69; 68, identifier:target; 69, identifier:timeout_thread_handler; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:args; 72, tuple; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:args; 75, identifier:timeout; 76, identifier:timeout_stop_event; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:timeout_thread; 81, identifier:daemon; 82, True; 83, expression_statement; 83, 84; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:timeout_thread; 87, identifier:start; 88, argument_list; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:shell; 92, call; 92, 93; 92, 94; 93, identifier:HierarchicalShell; 94, argument_list; 94, 95; 95, string:'iotile'; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:shell; 100, identifier:root_add; 101, argument_list; 101, 102; 101, 103; 102, string:"registry"; 103, string:"iotile.core.dev.annotated_registry,registry"; 104, expression_statement; 104, 105; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:shell; 108, identifier:root_add; 109, argument_list; 109, 110; 109, 111; 110, string:"config"; 111, string:"iotile.core.dev.config,ConfigManager"; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:shell; 116, identifier:root_add; 117, argument_list; 117, 118; 117, 119; 118, string:'hw'; 119, string:"iotile.core.hw.hwmanager,HardwareManager"; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:reg; 123, call; 123, 124; 123, 125; 124, identifier:ComponentRegistry; 125, argument_list; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:plugins; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:reg; 132, identifier:list_plugins; 133, argument_list; 134, for_statement; 134, 135; 134, 138; 134, 143; 135, pattern_list; 135, 136; 135, 137; 136, identifier:key; 137, identifier:val; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:plugins; 141, identifier:items; 142, argument_list; 143, block; 143, 144; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:shell; 148, identifier:root_add; 149, argument_list; 149, 150; 149, 151; 150, identifier:key; 151, identifier:val; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:finished; 155, False; 156, try_statement; 156, 157; 156, 175; 156, 198; 157, block; 157, 158; 158, if_statement; 158, 159; 158, 165; 159, comparison_operator:>; 159, 160; 159, 164; 160, call; 160, 161; 160, 162; 161, identifier:len; 162, argument_list; 162, 163; 163, identifier:line; 164, integer:0; 165, block; 165, 166; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 169; 168, identifier:finished; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:shell; 172, identifier:invoke; 173, argument_list; 173, 174; 174, identifier:line; 175, except_clause; 175, 176; 175, 180; 176, as_pattern; 176, 177; 176, 178; 177, identifier:IOTileException; 178, as_pattern_target; 178, 179; 179, identifier:exc; 180, block; 180, 181; 180, 190; 180, 196; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 184; 183, identifier:print; 184, argument_list; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:exc; 188, identifier:format; 189, argument_list; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:SharedLoop; 194, identifier:stop; 195, argument_list; 196, return_statement; 196, 197; 197, integer:1; 198, except_clause; 198, 199; 198, 200; 199, identifier:Exception; 200, block; 200, 201; 200, 207; 200, 213; 201, expression_statement; 201, 202; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:traceback; 205, identifier:print_exc; 206, argument_list; 207, expression_statement; 207, 208; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:SharedLoop; 211, identifier:stop; 212, argument_list; 213, return_statement; 213, 214; 214, integer:1; 215, if_statement; 215, 216; 215, 221; 216, boolean_operator:or; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:args; 219, identifier:quit; 220, identifier:finished; 221, block; 221, 222; 221, 228; 222, expression_statement; 222, 223; 223, call; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:SharedLoop; 226, identifier:stop; 227, argument_list; 228, return_statement; 228, 229; 229, integer:0; 230, expression_statement; 230, 231; 231, call; 231, 232; 231, 233; 232, identifier:setup_completion; 233, argument_list; 233, 234; 234, identifier:shell; 235, try_statement; 235, 236; 235, 337; 235, 345; 235, 353; 236, block; 236, 237; 237, while_statement; 237, 238; 237, 239; 238, True; 239, block; 239, 240; 239, 278; 239, 329; 240, try_statement; 240, 241; 240, 269; 241, block; 241, 242; 241, 255; 242, expression_statement; 242, 243; 243, assignment; 243, 244; 243, 245; 244, identifier:linebuf; 245, call; 245, 246; 245, 247; 246, identifier:input; 247, argument_list; 247, 248; 248, binary_operator:%; 248, 249; 248, 250; 249, string:"(%s) "; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:shell; 253, identifier:context_name; 254, argument_list; 255, ERROR; 255, 256; 256, boolean_operator:and; 256, 257; 256, 263; 257, comparison_operator:>; 257, 258; 257, 262; 258, call; 258, 259; 258, 260; 259, identifier:len; 260, argument_list; 260, 261; 261, identifier:linebuf; 262, integer:0; 263, comparison_operator:==; 263, 264; 263, 267; 263, 268; 264, subscript; 264, 265; 264, 266; 265, identifier:linebuf; 266, integer:0; 267, ERROR; 268, identifier:continue; 269, except_clause; 269, 270; 269, 271; 270, identifier:KeyboardInterrupt; 271, block; 271, 272; 271, 277; 272, expression_statement; 272, 273; 273, call; 273, 274; 273, 275; 274, identifier:print; 275, argument_list; 275, 276; 276, string:""; 277, continue_statement; 278, try_statement; 278, 279; 278, 289; 278, 305; 278, 320; 279, block; 279, 280; 280, expression_statement; 280, 281; 281, assignment; 281, 282; 281, 283; 282, identifier:finished; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:shell; 286, identifier:invoke_string; 287, argument_list; 287, 288; 288, identifier:linebuf; 289, except_clause; 289, 290; 289, 291; 290, identifier:KeyboardInterrupt; 291, block; 291, 292; 291, 297; 292, expression_statement; 292, 293; 293, call; 293, 294; 293, 295; 294, identifier:print; 295, argument_list; 295, 296; 296, string:""; 297, if_statement; 297, 298; 297, 303; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:timeout_stop_event; 301, identifier:is_set; 302, argument_list; 303, block; 303, 304; 304, break_statement; 305, except_clause; 305, 306; 305, 310; 306, as_pattern; 306, 307; 306, 308; 307, identifier:IOTileException; 308, as_pattern_target; 308, 309; 309, identifier:exc; 310, block; 310, 311; 311, expression_statement; 311, 312; 312, call; 312, 313; 312, 314; 313, identifier:print; 314, argument_list; 314, 315; 315, call; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:exc; 318, identifier:format; 319, argument_list; 320, except_clause; 320, 321; 320, 322; 321, identifier:Exception; 322, block; 322, 323; 323, expression_statement; 323, 324; 324, call; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:traceback; 327, identifier:print_exc; 328, argument_list; 329, if_statement; 329, 330; 329, 335; 330, call; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:shell; 333, identifier:finished; 334, argument_list; 335, block; 335, 336; 336, break_statement; 337, except_clause; 337, 338; 337, 339; 338, identifier:EOFError; 339, block; 339, 340; 340, expression_statement; 340, 341; 341, call; 341, 342; 341, 343; 342, identifier:print; 343, argument_list; 343, 344; 344, string:""; 345, except_clause; 345, 346; 345, 347; 346, identifier:KeyboardInterrupt; 347, block; 347, 348; 348, expression_statement; 348, 349; 349, call; 349, 350; 349, 351; 350, identifier:print; 351, argument_list; 351, 352; 352, string:""; 353, finally_clause; 353, 354; 354, block; 354, 355; 355, expression_statement; 355, 356; 356, call; 356, 357; 356, 360; 357, attribute; 357, 358; 357, 359; 358, identifier:SharedLoop; 359, identifier:stop; 360, argument_list; 361, if_statement; 361, 362; 361, 365; 362, comparison_operator:is; 362, 363; 362, 364; 363, identifier:timeout_thread; 364, None; 365, block; 365, 366; 365, 372; 366, expression_statement; 366, 367; 367, call; 367, 368; 367, 371; 368, attribute; 368, 369; 368, 370; 369, identifier:timeout_stop_event; 370, identifier:set; 371, argument_list; 372, expression_statement; 372, 373; 373, call; 373, 374; 373, 377; 374, attribute; 374, 375; 374, 376; 375, identifier:timeout_thread; 376, identifier:join; 377, argument_list | def main(argv=None):
if argv is None:
argv = sys.argv[1:]
args = parse_global_args(argv)
type_system.interactive = True
line = args.commands
timeout_thread = None
timeout_stop_event = threading.Event()
if args.timeout:
timeout_thread = threading.Thread(target=timeout_thread_handler, args=(args.timeout, timeout_stop_event))
timeout_thread.daemon = True
timeout_thread.start()
shell = HierarchicalShell('iotile')
shell.root_add("registry", "iotile.core.dev.annotated_registry,registry")
shell.root_add("config", "iotile.core.dev.config,ConfigManager")
shell.root_add('hw', "iotile.core.hw.hwmanager,HardwareManager")
reg = ComponentRegistry()
plugins = reg.list_plugins()
for key, val in plugins.items():
shell.root_add(key, val)
finished = False
try:
if len(line) > 0:
finished = shell.invoke(line)
except IOTileException as exc:
print(exc.format())
SharedLoop.stop()
return 1
except Exception:
traceback.print_exc()
SharedLoop.stop()
return 1
if args.quit or finished:
SharedLoop.stop()
return 0
setup_completion(shell)
try:
while True:
try:
linebuf = input("(%s) " % shell.context_name())
if len(linebuf) > 0 and linebuf[0] == '
continue
except KeyboardInterrupt:
print("")
continue
try:
finished = shell.invoke_string(linebuf)
except KeyboardInterrupt:
print("")
if timeout_stop_event.is_set():
break
except IOTileException as exc:
print(exc.format())
except Exception:
traceback.print_exc()
if shell.finished():
break
except EOFError:
print("")
except KeyboardInterrupt:
print("")
finally:
SharedLoop.stop()
if timeout_thread is not None:
timeout_stop_event.set()
timeout_thread.join() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:DialectAddToEnv; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:env; 5, identifier:dialect; 6, identifier:suffixes; 7, identifier:ppsuffixes; 8, default_parameter; 8, 9; 8, 10; 9, identifier:support_module; 10, integer:0; 11, block; 11, 12; 11, 18; 11, 33; 11, 51; 11, 62; 11, 74; 11, 87; 11, 123; 11, 159; 11, 181; 11, 205; 11, 220; 11, 235; 11, 248; 12, expression_statement; 12, 13; 13, call; 13, 14; 13, 15; 14, identifier:ComputeFortranSuffixes; 15, argument_list; 15, 16; 15, 17; 16, identifier:suffixes; 17, identifier:ppsuffixes; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:fscan; 21, call; 21, 22; 21, 29; 22, attribute; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:SCons; 26, identifier:Scanner; 27, identifier:Fortran; 28, identifier:FortranScan; 29, argument_list; 29, 30; 30, binary_operator:%; 30, 31; 30, 32; 31, string:"%sPATH"; 32, identifier:dialect; 33, for_statement; 33, 34; 33, 35; 33, 38; 34, identifier:suffix; 35, binary_operator:+; 35, 36; 35, 37; 36, identifier:suffixes; 37, identifier:ppsuffixes; 38, block; 38, 39; 39, expression_statement; 39, 40; 40, call; 40, 41; 40, 48; 41, attribute; 41, 42; 41, 47; 42, attribute; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:SCons; 45, identifier:Tool; 46, identifier:SourceFileScanner; 47, identifier:add_scanner; 48, argument_list; 48, 49; 48, 50; 49, identifier:suffix; 50, identifier:fscan; 51, expression_statement; 51, 52; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:env; 55, identifier:AppendUnique; 56, argument_list; 56, 57; 57, keyword_argument; 57, 58; 57, 59; 58, identifier:FORTRANSUFFIXES; 59, binary_operator:+; 59, 60; 59, 61; 60, identifier:suffixes; 61, identifier:ppsuffixes; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 69; 63, 70; 64, pattern_list; 64, 65; 64, 66; 64, 67; 64, 68; 65, identifier:compaction; 66, identifier:compppaction; 67, identifier:shcompaction; 68, identifier:shcompppaction; 69, line_continuation:\; 70, call; 70, 71; 70, 72; 71, identifier:CreateDialectActions; 72, argument_list; 72, 73; 73, identifier:dialect; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 79; 76, pattern_list; 76, 77; 76, 78; 77, identifier:static_obj; 78, identifier:shared_obj; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:SCons; 83, identifier:Tool; 84, identifier:createObjBuilders; 85, argument_list; 85, 86; 86, identifier:env; 87, for_statement; 87, 88; 87, 89; 87, 90; 88, identifier:suffix; 89, identifier:suffixes; 90, block; 90, 91; 90, 99; 90, 107; 90, 115; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:static_obj; 95, identifier:add_action; 96, argument_list; 96, 97; 96, 98; 97, identifier:suffix; 98, identifier:compaction; 99, expression_statement; 99, 100; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:shared_obj; 103, identifier:add_action; 104, argument_list; 104, 105; 104, 106; 105, identifier:suffix; 106, identifier:shcompaction; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:static_obj; 111, identifier:add_emitter; 112, argument_list; 112, 113; 112, 114; 113, identifier:suffix; 114, identifier:FortranEmitter; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:shared_obj; 119, identifier:add_emitter; 120, argument_list; 120, 121; 120, 122; 121, identifier:suffix; 122, identifier:ShFortranEmitter; 123, for_statement; 123, 124; 123, 125; 123, 126; 124, identifier:suffix; 125, identifier:ppsuffixes; 126, block; 126, 127; 126, 135; 126, 143; 126, 151; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:static_obj; 131, identifier:add_action; 132, argument_list; 132, 133; 132, 134; 133, identifier:suffix; 134, identifier:compppaction; 135, expression_statement; 135, 136; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:shared_obj; 139, identifier:add_action; 140, argument_list; 140, 141; 140, 142; 141, identifier:suffix; 142, identifier:shcompppaction; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:static_obj; 147, identifier:add_emitter; 148, argument_list; 148, 149; 148, 150; 149, identifier:suffix; 150, identifier:FortranEmitter; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:shared_obj; 155, identifier:add_emitter; 156, argument_list; 156, 157; 156, 158; 157, identifier:suffix; 158, identifier:ShFortranEmitter; 159, if_statement; 159, 160; 159, 165; 160, comparison_operator:not; 160, 161; 160, 164; 161, binary_operator:%; 161, 162; 161, 163; 162, string:'%sFLAGS'; 163, identifier:dialect; 164, identifier:env; 165, block; 165, 166; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 173; 168, subscript; 168, 169; 168, 170; 169, identifier:env; 170, binary_operator:%; 170, 171; 170, 172; 171, string:'%sFLAGS'; 172, identifier:dialect; 173, call; 173, 174; 173, 179; 174, attribute; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:SCons; 177, identifier:Util; 178, identifier:CLVar; 179, argument_list; 179, 180; 180, string:''; 181, if_statement; 181, 182; 181, 187; 182, comparison_operator:not; 182, 183; 182, 186; 183, binary_operator:%; 183, 184; 183, 185; 184, string:'SH%sFLAGS'; 185, identifier:dialect; 186, identifier:env; 187, block; 187, 188; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 195; 190, subscript; 190, 191; 190, 192; 191, identifier:env; 192, binary_operator:%; 192, 193; 192, 194; 193, string:'SH%sFLAGS'; 194, identifier:dialect; 195, call; 195, 196; 195, 201; 196, attribute; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:SCons; 199, identifier:Util; 200, identifier:CLVar; 201, argument_list; 201, 202; 202, binary_operator:%; 202, 203; 202, 204; 203, string:'$%sFLAGS'; 204, identifier:dialect; 205, if_statement; 205, 206; 205, 211; 206, comparison_operator:not; 206, 207; 206, 210; 207, binary_operator:%; 207, 208; 207, 209; 208, string:'INC%sPREFIX'; 209, identifier:dialect; 210, identifier:env; 211, block; 211, 212; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 219; 214, subscript; 214, 215; 214, 216; 215, identifier:env; 216, binary_operator:%; 216, 217; 216, 218; 217, string:'INC%sPREFIX'; 218, identifier:dialect; 219, string:'$INCPREFIX'; 220, if_statement; 220, 221; 220, 226; 221, comparison_operator:not; 221, 222; 221, 225; 222, binary_operator:%; 222, 223; 222, 224; 223, string:'INC%sSUFFIX'; 224, identifier:dialect; 225, identifier:env; 226, block; 226, 227; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 234; 229, subscript; 229, 230; 229, 231; 230, identifier:env; 231, binary_operator:%; 231, 232; 231, 233; 232, string:'INC%sSUFFIX'; 233, identifier:dialect; 234, string:'$INCSUFFIX'; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 242; 237, subscript; 237, 238; 237, 239; 238, identifier:env; 239, binary_operator:%; 239, 240; 239, 241; 240, string:'_%sINCFLAGS'; 241, identifier:dialect; 242, binary_operator:%; 242, 243; 242, 244; 243, string:'$( ${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'; 244, tuple; 244, 245; 244, 246; 244, 247; 245, identifier:dialect; 246, identifier:dialect; 247, identifier:dialect; 248, if_statement; 248, 249; 248, 252; 248, 305; 249, comparison_operator:==; 249, 250; 249, 251; 250, identifier:support_module; 251, integer:1; 252, block; 252, 253; 252, 266; 252, 279; 252, 292; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 260; 255, subscript; 255, 256; 255, 257; 256, identifier:env; 257, binary_operator:%; 257, 258; 257, 259; 258, string:'%sCOM'; 259, identifier:dialect; 260, binary_operator:%; 260, 261; 260, 262; 261, string:'$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'; 262, tuple; 262, 263; 262, 264; 262, 265; 263, identifier:dialect; 264, identifier:dialect; 265, identifier:dialect; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 273; 268, subscript; 268, 269; 268, 270; 269, identifier:env; 270, binary_operator:%; 270, 271; 270, 272; 271, string:'%sPPCOM'; 272, identifier:dialect; 273, binary_operator:%; 273, 274; 273, 275; 274, string:'$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'; 275, tuple; 275, 276; 275, 277; 275, 278; 276, identifier:dialect; 277, identifier:dialect; 278, identifier:dialect; 279, expression_statement; 279, 280; 280, assignment; 280, 281; 280, 286; 281, subscript; 281, 282; 281, 283; 282, identifier:env; 283, binary_operator:%; 283, 284; 283, 285; 284, string:'SH%sCOM'; 285, identifier:dialect; 286, binary_operator:%; 286, 287; 286, 288; 287, string:'$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'; 288, tuple; 288, 289; 288, 290; 288, 291; 289, identifier:dialect; 290, identifier:dialect; 291, identifier:dialect; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 299; 294, subscript; 294, 295; 294, 296; 295, identifier:env; 296, binary_operator:%; 296, 297; 296, 298; 297, string:'SH%sPPCOM'; 298, identifier:dialect; 299, binary_operator:%; 299, 300; 299, 301; 300, string:'$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES'; 301, tuple; 301, 302; 301, 303; 301, 304; 302, identifier:dialect; 303, identifier:dialect; 304, identifier:dialect; 305, else_clause; 305, 306; 306, block; 306, 307; 306, 320; 306, 333; 306, 346; 307, expression_statement; 307, 308; 308, assignment; 308, 309; 308, 314; 309, subscript; 309, 310; 309, 311; 310, identifier:env; 311, binary_operator:%; 311, 312; 311, 313; 312, string:'%sCOM'; 313, identifier:dialect; 314, binary_operator:%; 314, 315; 314, 316; 315, string:'$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $SOURCES'; 316, tuple; 316, 317; 316, 318; 316, 319; 317, identifier:dialect; 318, identifier:dialect; 319, identifier:dialect; 320, expression_statement; 320, 321; 321, assignment; 321, 322; 321, 327; 322, subscript; 322, 323; 322, 324; 323, identifier:env; 324, binary_operator:%; 324, 325; 324, 326; 325, string:'%sPPCOM'; 326, identifier:dialect; 327, binary_operator:%; 327, 328; 327, 329; 328, string:'$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES'; 329, tuple; 329, 330; 329, 331; 329, 332; 330, identifier:dialect; 331, identifier:dialect; 332, identifier:dialect; 333, expression_statement; 333, 334; 334, assignment; 334, 335; 334, 340; 335, subscript; 335, 336; 335, 337; 336, identifier:env; 337, binary_operator:%; 337, 338; 337, 339; 338, string:'SH%sCOM'; 339, identifier:dialect; 340, binary_operator:%; 340, 341; 340, 342; 341, string:'$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $SOURCES'; 342, tuple; 342, 343; 342, 344; 342, 345; 343, identifier:dialect; 344, identifier:dialect; 345, identifier:dialect; 346, expression_statement; 346, 347; 347, assignment; 347, 348; 347, 353; 348, subscript; 348, 349; 348, 350; 349, identifier:env; 350, binary_operator:%; 350, 351; 350, 352; 351, string:'SH%sPPCOM'; 352, identifier:dialect; 353, binary_operator:%; 353, 354; 353, 355; 354, string:'$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES'; 355, tuple; 355, 356; 355, 357; 355, 358; 356, identifier:dialect; 357, identifier:dialect; 358, identifier:dialect | def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0):
ComputeFortranSuffixes(suffixes, ppsuffixes)
fscan = SCons.Scanner.Fortran.FortranScan("%sPATH" % dialect)
for suffix in suffixes + ppsuffixes:
SCons.Tool.SourceFileScanner.add_scanner(suffix, fscan)
env.AppendUnique(FORTRANSUFFIXES = suffixes + ppsuffixes)
compaction, compppaction, shcompaction, shcompppaction = \
CreateDialectActions(dialect)
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
for suffix in suffixes:
static_obj.add_action(suffix, compaction)
shared_obj.add_action(suffix, shcompaction)
static_obj.add_emitter(suffix, FortranEmitter)
shared_obj.add_emitter(suffix, ShFortranEmitter)
for suffix in ppsuffixes:
static_obj.add_action(suffix, compppaction)
shared_obj.add_action(suffix, shcompppaction)
static_obj.add_emitter(suffix, FortranEmitter)
shared_obj.add_emitter(suffix, ShFortranEmitter)
if '%sFLAGS' % dialect not in env:
env['%sFLAGS' % dialect] = SCons.Util.CLVar('')
if 'SH%sFLAGS' % dialect not in env:
env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS' % dialect)
if 'INC%sPREFIX' % dialect not in env:
env['INC%sPREFIX' % dialect] = '$INCPREFIX'
if 'INC%sSUFFIX' % dialect not in env:
env['INC%sSUFFIX' % dialect] = '$INCSUFFIX'
env['_%sINCFLAGS' % dialect] = '$( ${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' % (dialect, dialect, dialect)
if support_module == 1:
env['%sCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
env['%sPPCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
env['SH%sCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
env['SH%sPPCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
else:
env['%sCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
env['%sPPCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
env['SH%sCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
env['SH%sPPCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:MergeFlags; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:args; 6, default_parameter; 6, 7; 6, 8; 7, identifier:unique; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:dict; 11, None; 12, block; 12, 13; 12, 22; 12, 42; 12, 56; 12, 203; 13, if_statement; 13, 14; 13, 17; 14, comparison_operator:is; 14, 15; 14, 16; 15, identifier:dict; 16, None; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:dict; 21, identifier:self; 22, if_statement; 22, 23; 22, 32; 23, not_operator; 23, 24; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:SCons; 28, identifier:Util; 29, identifier:is_Dict; 30, argument_list; 30, 31; 31, identifier:args; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:args; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:ParseFlags; 40, argument_list; 40, 41; 41, identifier:args; 42, if_statement; 42, 43; 42, 45; 43, not_operator; 43, 44; 44, identifier:unique; 45, block; 45, 46; 45, 54; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:Append; 51, argument_list; 51, 52; 52, dictionary_splat; 52, 53; 53, identifier:args; 54, return_statement; 54, 55; 55, identifier:self; 56, for_statement; 56, 57; 56, 60; 56, 65; 57, pattern_list; 57, 58; 57, 59; 58, identifier:key; 59, identifier:value; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:args; 63, identifier:items; 64, argument_list; 65, block; 65, 66; 65, 71; 65, 142; 65, 146; 65, 197; 66, if_statement; 66, 67; 66, 69; 67, not_operator; 67, 68; 68, identifier:value; 69, block; 69, 70; 70, continue_statement; 71, try_statement; 71, 72; 71, 79; 71, 86; 72, block; 72, 73; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:orig; 76, subscript; 76, 77; 76, 78; 77, identifier:self; 78, identifier:key; 79, except_clause; 79, 80; 79, 81; 80, identifier:KeyError; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:orig; 85, identifier:value; 86, else_clause; 86, 87; 87, block; 87, 88; 88, if_statement; 88, 89; 88, 91; 88, 96; 89, not_operator; 89, 90; 90, identifier:orig; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:orig; 95, identifier:value; 96, elif_clause; 96, 97; 96, 98; 97, identifier:value; 98, block; 98, 99; 99, try_statement; 99, 100; 99, 107; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:orig; 104, binary_operator:+; 104, 105; 104, 106; 105, identifier:orig; 106, identifier:value; 107, except_clause; 107, 108; 107, 111; 108, tuple; 108, 109; 108, 110; 109, identifier:KeyError; 110, identifier:TypeError; 111, block; 111, 112; 112, try_statement; 112, 113; 112, 120; 112, 135; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:add_to_orig; 117, attribute; 117, 118; 117, 119; 118, identifier:orig; 119, identifier:append; 120, except_clause; 120, 121; 120, 122; 121, identifier:AttributeError; 122, block; 122, 123; 122, 131; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:value; 127, identifier:insert; 128, argument_list; 128, 129; 128, 130; 129, integer:0; 130, identifier:orig; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:orig; 134, identifier:value; 135, else_clause; 135, 136; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 140; 139, identifier:add_to_orig; 140, argument_list; 140, 141; 141, identifier:value; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:t; 145, list:[]; 146, if_statement; 146, 147; 146, 155; 146, 172; 147, comparison_operator:==; 147, 148; 147, 154; 148, subscript; 148, 149; 148, 150; 149, identifier:key; 150, slice; 150, 151; 150, 153; 151, unary_operator:-; 151, 152; 152, integer:4; 153, colon; 154, string:'PATH'; 155, block; 155, 156; 156, for_statement; 156, 157; 156, 158; 156, 159; 157, identifier:v; 158, identifier:orig; 159, block; 159, 160; 160, if_statement; 160, 161; 160, 164; 161, comparison_operator:not; 161, 162; 161, 163; 162, identifier:v; 163, identifier:t; 164, block; 164, 165; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:t; 169, identifier:append; 170, argument_list; 170, 171; 171, identifier:v; 172, else_clause; 172, 173; 173, block; 173, 174; 173, 180; 174, expression_statement; 174, 175; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:orig; 178, identifier:reverse; 179, argument_list; 180, for_statement; 180, 181; 180, 182; 180, 183; 181, identifier:v; 182, identifier:orig; 183, block; 183, 184; 184, if_statement; 184, 185; 184, 188; 185, comparison_operator:not; 185, 186; 185, 187; 186, identifier:v; 187, identifier:t; 188, block; 188, 189; 189, expression_statement; 189, 190; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:t; 193, identifier:insert; 194, argument_list; 194, 195; 194, 196; 195, integer:0; 196, identifier:v; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 202; 199, subscript; 199, 200; 199, 201; 200, identifier:self; 201, identifier:key; 202, identifier:t; 203, return_statement; 203, 204; 204, identifier:self | def MergeFlags(self, args, unique=1, dict=None):
if dict is None:
dict = self
if not SCons.Util.is_Dict(args):
args = self.ParseFlags(args)
if not unique:
self.Append(**args)
return self
for key, value in args.items():
if not value:
continue
try:
orig = self[key]
except KeyError:
orig = value
else:
if not orig:
orig = value
elif value:
try:
orig = orig + value
except (KeyError, TypeError):
try:
add_to_orig = orig.append
except AttributeError:
value.insert(0, orig)
orig = value
else:
add_to_orig(value)
t = []
if key[-4:] == 'PATH':
for v in orig:
if v not in t:
t.append(v)
else:
orig.reverse()
for v in orig:
if v not in t:
t.insert(0, v)
self[key] = t
return self |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:Append; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kw; 7, block; 7, 8; 7, 15; 7, 304; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:kw; 11, call; 11, 12; 11, 13; 12, identifier:copy_non_reserved_keywords; 13, argument_list; 13, 14; 14, identifier:kw; 15, for_statement; 15, 16; 15, 19; 15, 24; 16, pattern_list; 16, 17; 16, 18; 17, identifier:key; 18, identifier:val; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:kw; 22, identifier:items; 23, argument_list; 24, block; 24, 25; 25, try_statement; 25, 26; 25, 66; 25, 102; 26, block; 26, 27; 26, 58; 27, if_statement; 27, 28; 27, 44; 28, boolean_operator:and; 28, 29; 28, 32; 29, comparison_operator:==; 29, 30; 29, 31; 30, identifier:key; 31, string:'CPPDEFINES'; 32, call; 32, 33; 32, 38; 33, attribute; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:SCons; 36, identifier:Util; 37, identifier:is_String; 38, argument_list; 38, 39; 39, subscript; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:_dict; 43, identifier:key; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 52; 47, subscript; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:_dict; 51, identifier:key; 52, list:[self._dict[key]]; 52, 53; 53, subscript; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:self; 56, identifier:_dict; 57, identifier:key; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:orig; 61, subscript; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:_dict; 65, identifier:key; 66, except_clause; 66, 67; 66, 68; 67, identifier:KeyError; 68, block; 68, 69; 69, if_statement; 69, 70; 69, 82; 69, 92; 70, boolean_operator:and; 70, 71; 70, 74; 71, comparison_operator:==; 71, 72; 71, 73; 72, identifier:key; 73, string:'CPPDEFINES'; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:SCons; 78, identifier:Util; 79, identifier:is_String; 80, argument_list; 80, 81; 81, identifier:val; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 90; 85, subscript; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:self; 88, identifier:_dict; 89, identifier:key; 90, list:[val]; 90, 91; 91, identifier:val; 92, else_clause; 92, 93; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 101; 96, subscript; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:_dict; 100, identifier:key; 101, identifier:val; 102, else_clause; 102, 103; 103, block; 103, 104; 104, try_statement; 104, 105; 104, 112; 104, 172; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:update_dict; 109, attribute; 109, 110; 109, 111; 110, identifier:orig; 111, identifier:update; 112, except_clause; 112, 113; 112, 114; 113, identifier:AttributeError; 114, block; 114, 115; 115, try_statement; 115, 116; 115, 127; 116, block; 116, 117; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 124; 119, subscript; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:_dict; 123, identifier:key; 124, binary_operator:+; 124, 125; 124, 126; 125, identifier:orig; 126, identifier:val; 127, except_clause; 127, 128; 127, 131; 128, tuple; 128, 129; 128, 130; 129, identifier:KeyError; 130, identifier:TypeError; 131, block; 131, 132; 132, try_statement; 132, 133; 132, 140; 132, 162; 133, block; 133, 134; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:add_to_orig; 137, attribute; 137, 138; 137, 139; 138, identifier:orig; 139, identifier:append; 140, except_clause; 140, 141; 140, 142; 141, identifier:AttributeError; 142, block; 142, 143; 142, 154; 143, if_statement; 143, 144; 143, 145; 144, identifier:orig; 145, block; 145, 146; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:val; 150, identifier:insert; 151, argument_list; 151, 152; 151, 153; 152, integer:0; 153, identifier:orig; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 161; 156, subscript; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:self; 159, identifier:_dict; 160, identifier:key; 161, identifier:val; 162, else_clause; 162, 163; 163, block; 163, 164; 164, if_statement; 164, 165; 164, 166; 165, identifier:val; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 170; 169, identifier:add_to_orig; 170, argument_list; 170, 171; 171, identifier:val; 172, else_clause; 172, 173; 173, block; 173, 174; 174, if_statement; 174, 175; 174, 183; 174, 255; 175, call; 175, 176; 175, 181; 176, attribute; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:SCons; 179, identifier:Util; 180, identifier:is_List; 181, argument_list; 181, 182; 182, identifier:val; 183, block; 183, 184; 184, if_statement; 184, 185; 184, 188; 184, 243; 185, comparison_operator:==; 185, 186; 185, 187; 186, identifier:key; 187, string:'CPPDEFINES'; 188, block; 188, 189; 188, 193; 188, 227; 188, 231; 188, 235; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:tmp; 192, list:[]; 193, for_statement; 193, 194; 193, 197; 193, 202; 194, tuple_pattern; 194, 195; 194, 196; 195, identifier:k; 196, identifier:v; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:orig; 200, identifier:items; 201, argument_list; 202, block; 202, 203; 203, if_statement; 203, 204; 203, 207; 203, 217; 204, comparison_operator:is; 204, 205; 204, 206; 205, identifier:v; 206, None; 207, block; 207, 208; 208, expression_statement; 208, 209; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:tmp; 212, identifier:append; 213, argument_list; 213, 214; 214, tuple; 214, 215; 214, 216; 215, identifier:k; 216, identifier:v; 217, else_clause; 217, 218; 218, block; 218, 219; 219, expression_statement; 219, 220; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:tmp; 223, identifier:append; 224, argument_list; 224, 225; 225, tuple; 225, 226; 226, identifier:k; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:orig; 230, identifier:tmp; 231, expression_statement; 231, 232; 232, augmented_assignment:+=; 232, 233; 232, 234; 233, identifier:orig; 234, identifier:val; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 242; 237, subscript; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:self; 240, identifier:_dict; 241, identifier:key; 242, identifier:orig; 243, else_clause; 243, 244; 244, block; 244, 245; 245, for_statement; 245, 246; 245, 247; 245, 248; 246, identifier:v; 247, identifier:val; 248, block; 248, 249; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 254; 251, subscript; 251, 252; 251, 253; 252, identifier:orig; 253, identifier:v; 254, None; 255, else_clause; 255, 256; 256, block; 256, 257; 257, try_statement; 257, 258; 257, 264; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 262; 261, identifier:update_dict; 262, argument_list; 262, 263; 263, identifier:val; 264, except_clause; 264, 265; 264, 269; 265, tuple; 265, 266; 265, 267; 265, 268; 266, identifier:AttributeError; 267, identifier:TypeError; 268, identifier:ValueError; 269, block; 269, 270; 270, if_statement; 270, 271; 270, 279; 270, 296; 271, call; 271, 272; 271, 277; 272, attribute; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:SCons; 275, identifier:Util; 276, identifier:is_Dict; 277, argument_list; 277, 278; 278, identifier:val; 279, block; 279, 280; 280, for_statement; 280, 281; 280, 284; 280, 289; 281, pattern_list; 281, 282; 281, 283; 282, identifier:k; 283, identifier:v; 284, call; 284, 285; 284, 288; 285, attribute; 285, 286; 285, 287; 286, identifier:val; 287, identifier:items; 288, argument_list; 289, block; 289, 290; 290, expression_statement; 290, 291; 291, assignment; 291, 292; 291, 295; 292, subscript; 292, 293; 292, 294; 293, identifier:orig; 294, identifier:k; 295, identifier:v; 296, else_clause; 296, 297; 297, block; 297, 298; 298, expression_statement; 298, 299; 299, assignment; 299, 300; 299, 303; 300, subscript; 300, 301; 300, 302; 301, identifier:orig; 302, identifier:val; 303, None; 304, expression_statement; 304, 305; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:self; 308, identifier:scanner_map_delete; 309, argument_list; 309, 310; 310, identifier:kw | def Append(self, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
try:
if key == 'CPPDEFINES' and SCons.Util.is_String(self._dict[key]):
self._dict[key] = [self._dict[key]]
orig = self._dict[key]
except KeyError:
if key == 'CPPDEFINES' and SCons.Util.is_String(val):
self._dict[key] = [val]
else:
self._dict[key] = val
else:
try:
update_dict = orig.update
except AttributeError:
try:
self._dict[key] = orig + val
except (KeyError, TypeError):
try:
add_to_orig = orig.append
except AttributeError:
if orig:
val.insert(0, orig)
self._dict[key] = val
else:
if val:
add_to_orig(val)
else:
if SCons.Util.is_List(val):
if key == 'CPPDEFINES':
tmp = []
for (k, v) in orig.items():
if v is not None:
tmp.append((k, v))
else:
tmp.append((k,))
orig = tmp
orig += val
self._dict[key] = orig
else:
for v in val:
orig[v] = None
else:
try:
update_dict(val)
except (AttributeError, TypeError, ValueError):
if SCons.Util.is_Dict(val):
for k, v in val.items():
orig[k] = v
else:
orig[val] = None
self.scanner_map_delete(kw) |
0, module; 0, 1; 0, 95; 0, 115; 0, 156; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 93; 2, function_name:ParseDepends; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:filename; 6, default_parameter; 6, 7; 6, 8; 7, identifier:must_exist; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:only_one; 11, integer:0; 12, ERROR; 12, 13; 12, 22; 12, 40; 12, 55; 12, 88; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:filename; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:subst; 20, argument_list; 20, 21; 21, identifier:filename; 22, try_statement; 22, 23; 22, 32; 23, block; 23, 24; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:fp; 27, call; 27, 28; 27, 29; 28, identifier:open; 29, argument_list; 29, 30; 29, 31; 30, identifier:filename; 31, string:'r'; 32, except_clause; 32, 33; 32, 34; 33, identifier:IOError; 34, block; 34, 35; 34, 39; 35, if_statement; 35, 36; 35, 37; 36, identifier:must_exist; 37, block; 37, 38; 38, raise_statement; 39, return_statement; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:lines; 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:SCons; 49, identifier:Util; 50, identifier:LogicalLines; 51, argument_list; 51, 52; 52, identifier:fp; 53, identifier:readlines; 54, argument_list; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 81; 57, pattern_list; 57, 58; 57, 59; 57, 80; 58, identifier:lines; 59, ERROR; 59, 60; 59, 61; 59, 64; 59, 72; 59, 73; 59, 74; 60, identifier:l; 61, for_in_clause; 61, 62; 61, 63; 62, identifier:l; 63, identifier:lines; 64, if_clause; 64, 65; 65, comparison_operator:!=; 65, 66; 65, 69; 65, 71; 66, subscript; 66, 67; 66, 68; 67, identifier:l; 68, integer:0; 69, ERROR; 69, 70; 70, identifier:tdlist; 71, list:[]; 72, identifier:line; 73, identifier:lines; 74, type; 74, 75; 75, constrained_type; 75, 76; 75, 78; 76, type; 76, 77; 77, identifier:try; 78, type; 78, 79; 79, identifier:target; 80, identifier:depends; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:line; 84, identifier:split; 85, argument_list; 85, 86; 85, 87; 86, string:':'; 87, integer:1; 88, call; 88, 89; 88, 90; 89, identifier:except; 90, argument_list; 90, 91; 90, 92; 91, identifier:AttributeError; 92, identifier:ValueError; 93, block; 93, 94; 94, pass_statement; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:else; 98, type; 98, 99; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:tdlist; 102, identifier:append; 103, argument_list; 103, 104; 104, tuple; 104, 105; 104, 110; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:target; 108, identifier:split; 109, argument_list; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:depends; 113, identifier:split; 114, argument_list; 115, if_statement; 115, 116; 115, 117; 116, identifier:only_one; 117, block; 117, 118; 117, 122; 117, 135; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 121; 120, identifier:targets; 121, list:[]; 122, for_statement; 122, 123; 122, 124; 122, 125; 123, identifier:td; 124, identifier:tdlist; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:targets; 130, identifier:extend; 131, argument_list; 131, 132; 132, subscript; 132, 133; 132, 134; 133, identifier:td; 134, integer:0; 135, if_statement; 135, 136; 135, 142; 136, comparison_operator:>; 136, 137; 136, 141; 137, call; 137, 138; 137, 139; 138, identifier:len; 139, argument_list; 139, 140; 140, identifier:targets; 141, integer:1; 142, block; 142, 143; 143, raise_statement; 143, 144; 144, call; 144, 145; 144, 150; 145, attribute; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:SCons; 148, identifier:Errors; 149, identifier:UserError; 150, argument_list; 150, 151; 151, binary_operator:%; 151, 152; 151, 153; 152, string:"More than one dependency target found in `%s': %s"; 153, tuple; 153, 154; 153, 155; 154, identifier:filename; 155, identifier:targets; 156, for_statement; 156, 157; 156, 160; 156, 161; 156, 171; 157, pattern_list; 157, 158; 157, 159; 158, identifier:target; 159, identifier:depends; 160, identifier:tdlist; 161, ERROR; 161, 162; 162, block; 162, 163; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:Depends; 168, argument_list; 168, 169; 168, 170; 169, identifier:target; 170, identifier:depends; 171, block: | def ParseDepends(self, filename, must_exist=None, only_one=0):
filename = self.subst(filename)
try:
fp = open(filename, 'r')
except IOError:
if must_exist:
raise
return
lines = SCons.Util.LogicalLines(fp).readlines()
lines = [l for l in lines if l[0] != '
tdlist = []
for line in lines:
try:
target, depends = line.split(':', 1)
except (AttributeError, ValueError):
pass
else:
tdlist.append((target.split(), depends.split()))
if only_one:
targets = []
for td in tdlist:
targets.extend(td[0])
if len(targets) > 1:
raise SCons.Errors.UserError(
"More than one dependency target found in `%s': %s"
% (filename, targets))
for target, depends in tdlist:
self.Depends(target, depends) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:Prepend; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kw; 7, block; 7, 8; 7, 15; 7, 187; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:kw; 11, call; 11, 12; 11, 13; 12, identifier:copy_non_reserved_keywords; 13, argument_list; 13, 14; 14, identifier:kw; 15, for_statement; 15, 16; 15, 19; 15, 24; 16, pattern_list; 16, 17; 16, 18; 17, identifier:key; 18, identifier:val; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:kw; 22, identifier:items; 23, argument_list; 24, block; 24, 25; 25, try_statement; 25, 26; 25, 35; 25, 46; 26, block; 26, 27; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:orig; 30, subscript; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:_dict; 34, identifier:key; 35, except_clause; 35, 36; 35, 37; 36, identifier:KeyError; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 45; 40, subscript; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:_dict; 44, identifier:key; 45, identifier:val; 46, else_clause; 46, 47; 47, block; 47, 48; 48, try_statement; 48, 49; 48, 56; 48, 116; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:update_dict; 53, attribute; 53, 54; 53, 55; 54, identifier:orig; 55, identifier:update; 56, except_clause; 56, 57; 56, 58; 57, identifier:AttributeError; 58, block; 58, 59; 59, try_statement; 59, 60; 59, 71; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 68; 63, subscript; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:_dict; 67, identifier:key; 68, binary_operator:+; 68, 69; 68, 70; 69, identifier:val; 70, identifier:orig; 71, except_clause; 71, 72; 71, 75; 72, tuple; 72, 73; 72, 74; 73, identifier:KeyError; 74, identifier:TypeError; 75, block; 75, 76; 76, try_statement; 76, 77; 76, 84; 76, 98; 77, block; 77, 78; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:add_to_val; 81, attribute; 81, 82; 81, 83; 82, identifier:val; 83, identifier:append; 84, except_clause; 84, 85; 84, 86; 85, identifier:AttributeError; 86, block; 86, 87; 87, if_statement; 87, 88; 87, 89; 88, identifier:val; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:orig; 94, identifier:insert; 95, argument_list; 95, 96; 95, 97; 96, integer:0; 97, identifier:val; 98, else_clause; 98, 99; 99, block; 99, 100; 99, 108; 100, if_statement; 100, 101; 100, 102; 101, identifier:orig; 102, block; 102, 103; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 106; 105, identifier:add_to_val; 106, argument_list; 106, 107; 107, identifier:orig; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 115; 110, subscript; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:_dict; 114, identifier:key; 115, identifier:val; 116, else_clause; 116, 117; 117, block; 117, 118; 118, if_statement; 118, 119; 118, 127; 118, 138; 119, call; 119, 120; 119, 125; 120, attribute; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:SCons; 123, identifier:Util; 124, identifier:is_List; 125, argument_list; 125, 126; 126, identifier:val; 127, block; 127, 128; 128, for_statement; 128, 129; 128, 130; 128, 131; 129, identifier:v; 130, identifier:val; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 137; 134, subscript; 134, 135; 134, 136; 135, identifier:orig; 136, identifier:v; 137, None; 138, else_clause; 138, 139; 139, block; 139, 140; 140, try_statement; 140, 141; 140, 147; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, call; 143, 144; 143, 145; 144, identifier:update_dict; 145, argument_list; 145, 146; 146, identifier:val; 147, except_clause; 147, 148; 147, 152; 148, tuple; 148, 149; 148, 150; 148, 151; 149, identifier:AttributeError; 150, identifier:TypeError; 151, identifier:ValueError; 152, block; 152, 153; 153, if_statement; 153, 154; 153, 162; 153, 179; 154, call; 154, 155; 154, 160; 155, attribute; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:SCons; 158, identifier:Util; 159, identifier:is_Dict; 160, argument_list; 160, 161; 161, identifier:val; 162, block; 162, 163; 163, for_statement; 163, 164; 163, 167; 163, 172; 164, pattern_list; 164, 165; 164, 166; 165, identifier:k; 166, identifier:v; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:val; 170, identifier:items; 171, argument_list; 172, block; 172, 173; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 178; 175, subscript; 175, 176; 175, 177; 176, identifier:orig; 177, identifier:k; 178, identifier:v; 179, else_clause; 179, 180; 180, block; 180, 181; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 186; 183, subscript; 183, 184; 183, 185; 184, identifier:orig; 185, identifier:val; 186, None; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:self; 191, identifier:scanner_map_delete; 192, argument_list; 192, 193; 193, identifier:kw | def Prepend(self, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
try:
orig = self._dict[key]
except KeyError:
self._dict[key] = val
else:
try:
update_dict = orig.update
except AttributeError:
try:
self._dict[key] = val + orig
except (KeyError, TypeError):
try:
add_to_val = val.append
except AttributeError:
if val:
orig.insert(0, val)
else:
if orig:
add_to_val(orig)
self._dict[key] = val
else:
if SCons.Util.is_List(val):
for v in val:
orig[v] = None
else:
try:
update_dict(val)
except (AttributeError, TypeError, ValueError):
if SCons.Util.is_Dict(val):
for k, v in val.items():
orig[k] = v
else:
orig[val] = None
self.scanner_map_delete(kw) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:PrependUnique; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:delete_existing; 7, integer:0; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kw; 10, block; 10, 11; 10, 18; 10, 272; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:kw; 14, call; 14, 15; 14, 16; 15, identifier:copy_non_reserved_keywords; 16, argument_list; 16, 17; 17, identifier:kw; 18, for_statement; 18, 19; 18, 22; 18, 27; 19, pattern_list; 19, 20; 19, 21; 20, identifier:key; 21, identifier:val; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:kw; 25, identifier:items; 26, argument_list; 27, block; 27, 28; 27, 47; 28, if_statement; 28, 29; 28, 37; 29, call; 29, 30; 29, 35; 30, attribute; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:SCons; 33, identifier:Util; 34, identifier:is_List; 35, argument_list; 35, 36; 36, identifier:val; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:val; 41, call; 41, 42; 41, 43; 42, identifier:_delete_duplicates; 43, argument_list; 43, 44; 43, 45; 44, identifier:val; 45, not_operator; 45, 46; 46, identifier:delete_existing; 47, if_statement; 47, 48; 47, 63; 47, 72; 47, 107; 47, 180; 48, boolean_operator:or; 48, 49; 48, 54; 49, comparison_operator:not; 49, 50; 49, 51; 50, identifier:key; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:_dict; 54, comparison_operator:in; 54, 55; 54, 60; 55, subscript; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:_dict; 59, identifier:key; 60, tuple; 60, 61; 60, 62; 61, string:''; 62, None; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 71; 66, subscript; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:_dict; 70, identifier:key; 71, identifier:val; 72, elif_clause; 72, 73; 72, 95; 73, boolean_operator:and; 73, 74; 73, 86; 73, 87; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:SCons; 78, identifier:Util; 79, identifier:is_Dict; 80, argument_list; 80, 81; 81, subscript; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:_dict; 85, identifier:key; 86, line_continuation:\; 87, call; 87, 88; 87, 93; 88, attribute; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:SCons; 91, identifier:Util; 92, identifier:is_Dict; 93, argument_list; 93, 94; 94, identifier:val; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 105; 98, attribute; 98, 99; 98, 104; 99, subscript; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:_dict; 103, identifier:key; 104, identifier:update; 105, argument_list; 105, 106; 106, identifier:val; 107, elif_clause; 107, 108; 107, 116; 108, call; 108, 109; 108, 114; 109, attribute; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:SCons; 112, identifier:Util; 113, identifier:is_List; 114, argument_list; 114, 115; 115, identifier:val; 116, block; 116, 117; 116, 125; 116, 141; 116, 170; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:dk; 120, subscript; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:self; 123, identifier:_dict; 124, identifier:key; 125, if_statement; 125, 126; 125, 135; 126, not_operator; 126, 127; 127, call; 127, 128; 127, 133; 128, attribute; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:SCons; 131, identifier:Util; 132, identifier:is_List; 133, argument_list; 133, 134; 134, identifier:dk; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:dk; 139, list:[dk]; 139, 140; 140, identifier:dk; 141, if_statement; 141, 142; 141, 143; 141, 156; 142, identifier:delete_existing; 143, block; 143, 144; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:dk; 147, list_comprehension; 147, 148; 147, 149; 147, 152; 148, identifier:x; 149, for_in_clause; 149, 150; 149, 151; 150, identifier:x; 151, identifier:dk; 152, if_clause; 152, 153; 153, comparison_operator:not; 153, 154; 153, 155; 154, identifier:x; 155, identifier:val; 156, else_clause; 156, 157; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:val; 161, list_comprehension; 161, 162; 161, 163; 161, 166; 162, identifier:x; 163, for_in_clause; 163, 164; 163, 165; 164, identifier:x; 165, identifier:val; 166, if_clause; 166, 167; 167, comparison_operator:not; 167, 168; 167, 169; 168, identifier:x; 169, identifier:dk; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 177; 172, subscript; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:self; 175, identifier:_dict; 176, identifier:key; 177, binary_operator:+; 177, 178; 177, 179; 178, identifier:val; 179, identifier:dk; 180, else_clause; 180, 181; 181, block; 181, 182; 181, 190; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:dk; 185, subscript; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:_dict; 189, identifier:key; 190, if_statement; 190, 191; 190, 199; 190, 245; 191, call; 191, 192; 191, 197; 192, attribute; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:SCons; 195, identifier:Util; 196, identifier:is_List; 197, argument_list; 197, 198; 198, identifier:dk; 199, block; 199, 200; 200, if_statement; 200, 201; 200, 202; 200, 226; 201, identifier:delete_existing; 202, block; 202, 203; 202, 215; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:dk; 206, list_comprehension; 206, 207; 206, 208; 206, 211; 207, identifier:x; 208, for_in_clause; 208, 209; 208, 210; 209, identifier:x; 210, identifier:dk; 211, if_clause; 211, 212; 212, comparison_operator:not; 212, 213; 212, 214; 213, identifier:x; 214, identifier:val; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 222; 217, subscript; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:self; 220, identifier:_dict; 221, identifier:key; 222, binary_operator:+; 222, 223; 222, 225; 223, list:[val]; 223, 224; 224, identifier:val; 225, identifier:dk; 226, else_clause; 226, 227; 227, block; 227, 228; 228, if_statement; 228, 229; 228, 233; 229, not_operator; 229, 230; 230, comparison_operator:in; 230, 231; 230, 232; 231, identifier:val; 232, identifier:dk; 233, block; 233, 234; 234, expression_statement; 234, 235; 235, assignment; 235, 236; 235, 241; 236, subscript; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:self; 239, identifier:_dict; 240, identifier:key; 241, binary_operator:+; 241, 242; 241, 244; 242, list:[val]; 242, 243; 243, identifier:val; 244, identifier:dk; 245, else_clause; 245, 246; 246, block; 246, 247; 246, 262; 247, if_statement; 247, 248; 247, 249; 248, identifier:delete_existing; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:dk; 253, list_comprehension; 253, 254; 253, 255; 253, 258; 254, identifier:x; 255, for_in_clause; 255, 256; 255, 257; 256, identifier:x; 257, identifier:dk; 258, if_clause; 258, 259; 259, comparison_operator:not; 259, 260; 259, 261; 260, identifier:x; 261, identifier:val; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 269; 264, subscript; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:self; 267, identifier:_dict; 268, identifier:key; 269, binary_operator:+; 269, 270; 269, 271; 270, identifier:val; 271, identifier:dk; 272, expression_statement; 272, 273; 273, call; 273, 274; 273, 277; 274, attribute; 274, 275; 274, 276; 275, identifier:self; 276, identifier:scanner_map_delete; 277, argument_list; 277, 278; 278, identifier:kw | def PrependUnique(self, delete_existing=0, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
if SCons.Util.is_List(val):
val = _delete_duplicates(val, not delete_existing)
if key not in self._dict or self._dict[key] in ('', None):
self._dict[key] = val
elif SCons.Util.is_Dict(self._dict[key]) and \
SCons.Util.is_Dict(val):
self._dict[key].update(val)
elif SCons.Util.is_List(val):
dk = self._dict[key]
if not SCons.Util.is_List(dk):
dk = [dk]
if delete_existing:
dk = [x for x in dk if x not in val]
else:
val = [x for x in val if x not in dk]
self._dict[key] = val + dk
else:
dk = self._dict[key]
if SCons.Util.is_List(dk):
if delete_existing:
dk = [x for x in dk if x not in val]
self._dict[key] = [val] + dk
else:
if not val in dk:
self._dict[key] = [val] + dk
else:
if delete_existing:
dk = [x for x in dk if x not in val]
self._dict[key] = val + dk
self.scanner_map_delete(kw) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:wait_idle; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:timeout; 7, float:1.0; 8, block; 8, 9; 8, 83; 8, 102; 8, 111; 9, function_definition; 9, 10; 9, 11; 9, 12; 10, function_name:_awaiter; 11, parameters; 12, block; 12, 13; 12, 27; 12, 52; 12, 67; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:background_work; 16, set_comprehension; 16, 17; 16, 22; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:x; 20, identifier:join; 21, argument_list; 22, for_in_clause; 22, 23; 22, 24; 23, identifier:x; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:_work_queues; 27, for_statement; 27, 28; 27, 29; 27, 32; 28, identifier:event; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:_events; 32, block; 32, 33; 33, if_statement; 33, 34; 33, 40; 34, not_operator; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:event; 38, identifier:is_set; 39, argument_list; 40, block; 40, 41; 41, expression_statement; 41, 42; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:background_work; 45, identifier:add; 46, argument_list; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:event; 50, identifier:wait; 51, argument_list; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 57; 54, pattern_list; 54, 55; 54, 56; 55, identifier:_done; 56, identifier:pending; 57, await; 57, 58; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:asyncio; 61, identifier:wait; 62, argument_list; 62, 63; 62, 64; 63, identifier:background_work; 64, keyword_argument; 64, 65; 64, 66; 65, identifier:timeout; 66, identifier:timeout; 67, if_statement; 67, 68; 67, 74; 68, comparison_operator:>; 68, 69; 68, 73; 69, call; 69, 70; 69, 71; 70, identifier:len; 71, argument_list; 71, 72; 72, identifier:pending; 73, integer:0; 74, block; 74, 75; 75, raise_statement; 75, 76; 76, call; 76, 77; 76, 78; 77, identifier:TimeoutExpiredError; 78, argument_list; 78, 79; 78, 80; 79, string:"Timeout waiting for event loop to become idle"; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:pending; 82, identifier:pending; 83, if_statement; 83, 84; 83, 89; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:_on_emulation_thread; 88, argument_list; 89, block; 89, 90; 90, return_statement; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:asyncio; 94, identifier:wait_for; 95, argument_list; 95, 96; 95, 99; 96, call; 96, 97; 96, 98; 97, identifier:_awaiter; 98, argument_list; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:timeout; 101, identifier:timeout; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:run_task_external; 107, argument_list; 107, 108; 108, call; 108, 109; 108, 110; 109, identifier:_awaiter; 110, argument_list; 111, return_statement; 111, 112; 112, None | def wait_idle(self, timeout=1.0):
async def _awaiter():
background_work = {x.join() for x in self._work_queues}
for event in self._events:
if not event.is_set():
background_work.add(event.wait())
_done, pending = await asyncio.wait(background_work, timeout=timeout)
if len(pending) > 0:
raise TimeoutExpiredError("Timeout waiting for event loop to become idle", pending=pending)
if self._on_emulation_thread():
return asyncio.wait_for(_awaiter(), timeout=timeout)
self.run_task_external(_awaiter())
return None |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_process_long_opt; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:rargs; 6, identifier:values; 7, block; 7, 8; 7, 17; 7, 56; 7, 98; 7, 106; 7, 281; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:arg; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:rargs; 14, identifier:pop; 15, argument_list; 15, 16; 16, integer:0; 17, if_statement; 17, 18; 17, 21; 17, 46; 18, comparison_operator:in; 18, 19; 18, 20; 19, string:"="; 20, identifier:arg; 21, block; 21, 22; 21, 34; 21, 42; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 27; 24, tuple_pattern; 24, 25; 24, 26; 25, identifier:opt; 26, identifier:next_arg; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:arg; 30, identifier:split; 31, argument_list; 31, 32; 31, 33; 32, string:"="; 33, integer:1; 34, expression_statement; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:rargs; 38, identifier:insert; 39, argument_list; 39, 40; 39, 41; 40, integer:0; 41, identifier:next_arg; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:had_explicit_value; 45, True; 46, else_clause; 46, 47; 47, block; 47, 48; 47, 52; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:opt; 51, identifier:arg; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:had_explicit_value; 55, False; 56, try_statement; 56, 57; 56, 67; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:opt; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:_match_long_opt; 65, argument_list; 65, 66; 66, identifier:opt; 67, except_clause; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:optparse; 70, identifier:BadOptionError; 71, block; 71, 72; 71, 97; 72, if_statement; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:preserve_unknown_options; 76, block; 76, 77; 76, 86; 76, 96; 77, expression_statement; 77, 78; 78, call; 78, 79; 78, 84; 79, attribute; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:largs; 83, identifier:append; 84, argument_list; 84, 85; 85, identifier:arg; 86, if_statement; 86, 87; 86, 88; 87, identifier:had_explicit_value; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:rargs; 93, identifier:pop; 94, argument_list; 94, 95; 95, integer:0; 96, return_statement; 97, raise_statement; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:option; 101, subscript; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:_long_opt; 105, identifier:opt; 106, if_statement; 106, 107; 106, 112; 106, 260; 106, 275; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:option; 110, identifier:takes_value; 111, argument_list; 112, block; 112, 113; 112, 119; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:nargs; 116, attribute; 116, 117; 116, 118; 117, identifier:option; 118, identifier:nargs; 119, if_statement; 119, 120; 119, 123; 119, 144; 119, 225; 119, 239; 120, comparison_operator:==; 120, 121; 120, 122; 121, identifier:nargs; 122, string:'?'; 123, block; 123, 124; 124, if_statement; 124, 125; 124, 126; 124, 136; 125, identifier:had_explicit_value; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:value; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:rargs; 133, identifier:pop; 134, argument_list; 134, 135; 135, integer:0; 136, else_clause; 136, 137; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:value; 141, attribute; 141, 142; 141, 143; 142, identifier:option; 143, identifier:const; 144, elif_clause; 144, 145; 144, 151; 145, comparison_operator:<; 145, 146; 145, 150; 146, call; 146, 147; 146, 148; 147, identifier:len; 148, argument_list; 148, 149; 149, identifier:rargs; 150, identifier:nargs; 151, block; 151, 152; 152, if_statement; 152, 153; 152, 156; 152, 209; 153, comparison_operator:==; 153, 154; 153, 155; 154, identifier:nargs; 155, integer:1; 156, block; 156, 157; 157, if_statement; 157, 158; 157, 162; 157, 175; 158, not_operator; 158, 159; 159, attribute; 159, 160; 159, 161; 160, identifier:option; 161, identifier:choices; 162, block; 162, 163; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:error; 168, argument_list; 168, 169; 169, binary_operator:%; 169, 170; 169, 174; 170, call; 170, 171; 170, 172; 171, identifier:_; 172, argument_list; 172, 173; 173, string:"%s option requires an argument"; 174, identifier:opt; 175, else_clause; 175, 176; 176, block; 176, 177; 176, 186; 176, 202; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:msg; 180, call; 180, 181; 180, 182; 181, identifier:_; 182, argument_list; 182, 183; 183, binary_operator:%; 183, 184; 183, 185; 184, string:"%s option requires an argument "; 185, identifier:opt; 186, expression_statement; 186, 187; 187, augmented_assignment:+=; 187, 188; 187, 189; 188, identifier:msg; 189, call; 189, 190; 189, 191; 190, identifier:_; 191, argument_list; 191, 192; 192, binary_operator:%; 192, 193; 192, 194; 193, string:"(choose from %s)"; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, string:', '; 197, identifier:join; 198, argument_list; 198, 199; 199, attribute; 199, 200; 199, 201; 200, identifier:option; 201, identifier:choices; 202, expression_statement; 202, 203; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:self; 206, identifier:error; 207, argument_list; 207, 208; 208, identifier:msg; 209, else_clause; 209, 210; 210, block; 210, 211; 211, expression_statement; 211, 212; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:self; 215, identifier:error; 216, argument_list; 216, 217; 217, binary_operator:%; 217, 218; 217, 222; 218, call; 218, 219; 218, 220; 219, identifier:_; 220, argument_list; 220, 221; 221, string:"%s option requires %d arguments"; 222, tuple; 222, 223; 222, 224; 223, identifier:opt; 224, identifier:nargs; 225, elif_clause; 225, 226; 225, 229; 226, comparison_operator:==; 226, 227; 226, 228; 227, identifier:nargs; 228, integer:1; 229, block; 229, 230; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:value; 233, call; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:rargs; 236, identifier:pop; 237, argument_list; 237, 238; 238, integer:0; 239, else_clause; 239, 240; 240, block; 240, 241; 240, 253; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:value; 244, call; 244, 245; 244, 246; 245, identifier:tuple; 246, argument_list; 246, 247; 247, subscript; 247, 248; 247, 249; 248, identifier:rargs; 249, slice; 249, 250; 249, 251; 249, 252; 250, integer:0; 251, colon; 252, identifier:nargs; 253, delete_statement; 253, 254; 254, subscript; 254, 255; 254, 256; 255, identifier:rargs; 256, slice; 256, 257; 256, 258; 256, 259; 257, integer:0; 258, colon; 259, identifier:nargs; 260, elif_clause; 260, 261; 260, 262; 261, identifier:had_explicit_value; 262, block; 262, 263; 263, expression_statement; 263, 264; 264, call; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:self; 267, identifier:error; 268, argument_list; 268, 269; 269, binary_operator:%; 269, 270; 269, 274; 270, call; 270, 271; 270, 272; 271, identifier:_; 272, argument_list; 272, 273; 273, string:"%s option does not take a value"; 274, identifier:opt; 275, else_clause; 275, 276; 276, block; 276, 277; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 280; 279, identifier:value; 280, None; 281, expression_statement; 281, 282; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:option; 285, identifier:process; 286, argument_list; 286, 287; 286, 288; 286, 289; 286, 290; 287, identifier:opt; 288, identifier:value; 289, identifier:values; 290, identifier:self | def _process_long_opt(self, rargs, values):
arg = rargs.pop(0)
if "=" in arg:
(opt, next_arg) = arg.split("=", 1)
rargs.insert(0, next_arg)
had_explicit_value = True
else:
opt = arg
had_explicit_value = False
try:
opt = self._match_long_opt(opt)
except optparse.BadOptionError:
if self.preserve_unknown_options:
self.largs.append(arg)
if had_explicit_value:
rargs.pop(0)
return
raise
option = self._long_opt[opt]
if option.takes_value():
nargs = option.nargs
if nargs == '?':
if had_explicit_value:
value = rargs.pop(0)
else:
value = option.const
elif len(rargs) < nargs:
if nargs == 1:
if not option.choices:
self.error(_("%s option requires an argument") % opt)
else:
msg = _("%s option requires an argument " % opt)
msg += _("(choose from %s)"
% ', '.join(option.choices))
self.error(msg)
else:
self.error(_("%s option requires %d arguments")
% (opt, nargs))
elif nargs == 1:
value = rargs.pop(0)
else:
value = tuple(rargs[0:nargs])
del rargs[0:nargs]
elif had_explicit_value:
self.error(_("%s option does not take a value") % opt)
else:
value = None
option.process(opt, value, values, self) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:Tag; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 9; 4, identifier:env; 5, identifier:target; 6, identifier:source; 7, list_splat_pattern; 7, 8; 8, identifier:more_tags; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kw_tags; 11, block; 11, 12; 11, 30; 11, 41; 11, 61; 11, 71; 11, 98; 12, if_statement; 12, 13; 12, 15; 12, 24; 13, not_operator; 13, 14; 14, identifier:target; 15, block; 15, 16; 15, 20; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:target; 19, identifier:source; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:first_tag; 23, None; 24, else_clause; 24, 25; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:first_tag; 29, identifier:source; 30, if_statement; 30, 31; 30, 32; 31, identifier:first_tag; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 40; 35, subscript; 35, 36; 35, 37; 36, identifier:kw_tags; 37, subscript; 37, 38; 37, 39; 38, identifier:first_tag; 39, integer:0; 40, string:''; 41, if_statement; 41, 42; 41, 55; 42, boolean_operator:and; 42, 43; 42, 49; 43, comparison_operator:==; 43, 44; 43, 48; 44, call; 44, 45; 44, 46; 45, identifier:len; 46, argument_list; 46, 47; 47, identifier:kw_tags; 48, integer:0; 49, comparison_operator:==; 49, 50; 49, 54; 50, call; 50, 51; 50, 52; 51, identifier:len; 52, argument_list; 52, 53; 53, identifier:more_tags; 54, integer:0; 55, block; 55, 56; 56, raise_statement; 56, 57; 57, call; 57, 58; 57, 59; 58, identifier:UserError; 59, argument_list; 59, 60; 60, string:"No tags given."; 61, for_statement; 61, 62; 61, 63; 61, 64; 62, identifier:x; 63, identifier:more_tags; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:kw_tags; 69, identifier:x; 70, string:''; 71, if_statement; 71, 72; 71, 81; 71, 87; 72, not_operator; 72, 73; 73, call; 73, 74; 73, 79; 74, attribute; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:SCons; 77, identifier:Util; 78, identifier:is_List; 79, argument_list; 79, 80; 80, identifier:target; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:target; 85, list:[target]; 85, 86; 86, identifier:target; 87, else_clause; 87, 88; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:target; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:env; 95, identifier:Flatten; 96, argument_list; 96, 97; 97, identifier:target; 98, for_statement; 98, 99; 98, 100; 98, 101; 99, identifier:t; 100, identifier:target; 101, block; 101, 102; 102, for_statement; 102, 103; 102, 106; 102, 111; 103, tuple_pattern; 103, 104; 103, 105; 104, identifier:k; 105, identifier:v; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:kw_tags; 109, identifier:items; 110, argument_list; 111, block; 111, 112; 111, 127; 112, if_statement; 112, 113; 112, 120; 113, comparison_operator:!=; 113, 114; 113, 119; 114, subscript; 114, 115; 114, 116; 115, identifier:k; 116, slice; 116, 117; 116, 118; 117, colon; 118, integer:10; 119, string:'PACKAGING_'; 120, block; 120, 121; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:k; 124, binary_operator:+; 124, 125; 124, 126; 125, string:'PACKAGING_'; 126, identifier:k; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:t; 131, identifier:Tag; 132, argument_list; 132, 133; 132, 134; 133, identifier:k; 134, identifier:v | def Tag(env, target, source, *more_tags, **kw_tags):
if not target:
target=source
first_tag=None
else:
first_tag=source
if first_tag:
kw_tags[first_tag[0]] = ''
if len(kw_tags) == 0 and len(more_tags) == 0:
raise UserError("No tags given.")
for x in more_tags:
kw_tags[x] = ''
if not SCons.Util.is_List(target):
target=[target]
else:
target=env.Flatten(target)
for t in target:
for (k,v) in kw_tags.items():
if k[:10] != 'PACKAGING_':
k='PACKAGING_'+k
t.Tag(k, v) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_vc_pdir; 3, parameters; 3, 4; 4, identifier:msvc_version; 5, block; 5, 6; 5, 10; 5, 35; 5, 202; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:root; 9, string:'Software\\'; 10, try_statement; 10, 11; 10, 18; 11, block; 11, 12; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:hkeys; 15, subscript; 15, 16; 15, 17; 16, identifier:_VCVER_TO_PRODUCT_DIR; 17, identifier:msvc_version; 18, except_clause; 18, 19; 18, 20; 19, identifier:KeyError; 20, block; 20, 21; 20, 28; 21, expression_statement; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:debug; 24, argument_list; 24, 25; 25, binary_operator:%; 25, 26; 25, 27; 26, string:"Unknown version of MSVC: %s"; 27, identifier:msvc_version; 28, raise_statement; 28, 29; 29, call; 29, 30; 29, 31; 30, identifier:UnsupportedVersion; 31, argument_list; 31, 32; 32, binary_operator:%; 32, 33; 32, 34; 33, string:"Unknown version %s"; 34, identifier:msvc_version; 35, for_statement; 35, 36; 35, 39; 35, 40; 36, pattern_list; 36, 37; 36, 38; 37, identifier:hkroot; 38, identifier:key; 39, identifier:hkeys; 40, block; 40, 41; 41, try_statement; 41, 42; 41, 133; 41, 156; 42, block; 42, 43; 42, 47; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:comps; 46, None; 47, if_statement; 47, 48; 47, 50; 47, 81; 48, not_operator; 48, 49; 49, identifier:key; 50, block; 50, 51; 50, 58; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:comps; 54, call; 54, 55; 54, 56; 55, identifier:find_vc_pdir_vswhere; 56, argument_list; 56, 57; 57, identifier:msvc_version; 58, if_statement; 58, 59; 58, 61; 59, not_operator; 59, 60; 60, identifier:comps; 61, block; 61, 62; 61, 75; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:debug; 65, argument_list; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, string:'find_vc_dir(): no VC found via vswhere for version {}'; 69, identifier:format; 70, argument_list; 70, 71; 71, call; 71, 72; 71, 73; 72, identifier:repr; 73, argument_list; 73, 74; 74, identifier:key; 75, raise_statement; 75, 76; 76, attribute; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:SCons; 79, identifier:Util; 80, identifier:WinError; 81, else_clause; 81, 82; 82, block; 82, 83; 82, 117; 83, if_statement; 83, 84; 83, 89; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:common; 87, identifier:is_win64; 88, argument_list; 89, block; 89, 90; 90, try_statement; 90, 91; 90, 106; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:comps; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:common; 98, identifier:read_reg; 99, argument_list; 99, 100; 99, 105; 100, binary_operator:+; 100, 101; 100, 104; 101, binary_operator:+; 101, 102; 101, 103; 102, identifier:root; 103, string:'Wow6432Node\\'; 104, identifier:key; 105, identifier:hkroot; 106, except_clause; 106, 107; 106, 115; 107, as_pattern; 107, 108; 107, 113; 108, attribute; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:SCons; 111, identifier:Util; 112, identifier:WinError; 113, as_pattern_target; 113, 114; 114, identifier:e; 115, block; 115, 116; 116, pass_statement; 117, if_statement; 117, 118; 117, 120; 118, not_operator; 118, 119; 119, identifier:comps; 120, block; 120, 121; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:comps; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:common; 127, identifier:read_reg; 128, argument_list; 128, 129; 128, 132; 129, binary_operator:+; 129, 130; 129, 131; 130, identifier:root; 131, identifier:key; 132, identifier:hkroot; 133, except_clause; 133, 134; 133, 142; 134, as_pattern; 134, 135; 134, 140; 135, attribute; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:SCons; 138, identifier:Util; 139, identifier:WinError; 140, as_pattern_target; 140, 141; 141, identifier:e; 142, block; 142, 143; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 146; 145, identifier:debug; 146, argument_list; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, string:'find_vc_dir(): no VC registry key {}'; 150, identifier:format; 151, argument_list; 151, 152; 152, call; 152, 153; 152, 154; 153, identifier:repr; 154, argument_list; 154, 155; 155, identifier:key; 156, else_clause; 156, 157; 157, block; 157, 158; 157, 168; 158, expression_statement; 158, 159; 159, call; 159, 160; 159, 161; 160, identifier:debug; 161, argument_list; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, string:'find_vc_dir(): found VC in registry: {}'; 165, identifier:format; 166, argument_list; 166, 167; 167, identifier:comps; 168, if_statement; 168, 169; 168, 177; 168, 180; 169, call; 169, 170; 169, 175; 170, attribute; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:os; 173, identifier:path; 174, identifier:exists; 175, argument_list; 175, 176; 176, identifier:comps; 177, block; 177, 178; 178, return_statement; 178, 179; 179, identifier:comps; 180, else_clause; 180, 181; 181, block; 181, 182; 181, 192; 182, expression_statement; 182, 183; 183, call; 183, 184; 183, 185; 184, identifier:debug; 185, argument_list; 185, 186; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, string:'find_vc_dir(): reg says dir is {}, but it does not exist. (ignoring)'; 189, identifier:format; 190, argument_list; 190, 191; 191, identifier:comps; 192, raise_statement; 192, 193; 193, call; 193, 194; 193, 195; 194, identifier:MissingConfiguration; 195, argument_list; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, string:"registry dir {} not found on the filesystem"; 199, identifier:format; 200, argument_list; 200, 201; 201, identifier:comps; 202, return_statement; 202, 203; 203, None | def find_vc_pdir(msvc_version):
root = 'Software\\'
try:
hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version]
except KeyError:
debug("Unknown version of MSVC: %s" % msvc_version)
raise UnsupportedVersion("Unknown version %s" % msvc_version)
for hkroot, key in hkeys:
try:
comps = None
if not key:
comps = find_vc_pdir_vswhere(msvc_version)
if not comps:
debug('find_vc_dir(): no VC found via vswhere for version {}'.format(repr(key)))
raise SCons.Util.WinError
else:
if common.is_win64():
try:
comps = common.read_reg(root + 'Wow6432Node\\' + key, hkroot)
except SCons.Util.WinError as e:
pass
if not comps:
comps = common.read_reg(root + key, hkroot)
except SCons.Util.WinError as e:
debug('find_vc_dir(): no VC registry key {}'.format(repr(key)))
else:
debug('find_vc_dir(): found VC in registry: {}'.format(comps))
if os.path.exists(comps):
return comps
else:
debug('find_vc_dir(): reg says dir is {}, but it does not exist. (ignoring)'.format(comps))
raise MissingConfiguration("registry dir {} not found on the filesystem".format(comps))
return None |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:allocate_stream; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:stream_type; 6, default_parameter; 6, 7; 6, 8; 7, identifier:stream_id; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:previous; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:attach; 14, False; 15, block; 15, 16; 15, 31; 15, 55; 15, 93; 15, 101; 15, 119; 15, 131; 16, if_statement; 16, 17; 16, 22; 17, comparison_operator:not; 17, 18; 17, 19; 18, identifier:stream_type; 19, attribute; 19, 20; 19, 21; 20, identifier:DataStream; 21, identifier:TypeToString; 22, block; 22, 23; 23, raise_statement; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:ArgumentError; 26, argument_list; 26, 27; 26, 28; 27, string:"Unknown stream type in allocate_stream"; 28, keyword_argument; 28, 29; 28, 30; 29, identifier:stream_type; 30, identifier:stream_type; 31, if_statement; 31, 32; 31, 41; 32, boolean_operator:and; 32, 33; 32, 36; 33, comparison_operator:is; 33, 34; 33, 35; 34, identifier:stream_id; 35, None; 36, comparison_operator:>=; 36, 37; 36, 38; 37, identifier:stream_id; 38, attribute; 38, 39; 38, 40; 39, identifier:StreamAllocator; 40, identifier:StartingID; 41, block; 41, 42; 42, raise_statement; 42, 43; 43, call; 43, 44; 43, 45; 44, identifier:ArgumentError; 45, argument_list; 45, 46; 45, 47; 45, 50; 46, string:"Attempted to explicitly allocate a stream id in the internally managed id range"; 47, keyword_argument; 47, 48; 47, 49; 48, identifier:stream_id; 49, identifier:stream_id; 50, keyword_argument; 50, 51; 50, 52; 51, identifier:started_id; 52, attribute; 52, 53; 52, 54; 53, identifier:StreamAllocator; 54, identifier:StartingID; 55, if_statement; 55, 56; 55, 59; 56, comparison_operator:is; 56, 57; 56, 58; 57, identifier:stream_id; 58, None; 59, block; 59, 60; 59, 77; 59, 85; 60, if_statement; 60, 61; 60, 66; 61, comparison_operator:not; 61, 62; 61, 63; 62, identifier:stream_type; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:_next_id; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 74; 69, subscript; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:_next_id; 73, identifier:stream_type; 74, attribute; 74, 75; 74, 76; 75, identifier:StreamAllocator; 76, identifier:StartingID; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:stream_id; 80, subscript; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:_next_id; 84, identifier:stream_type; 85, expression_statement; 85, 86; 86, augmented_assignment:+=; 86, 87; 86, 92; 87, subscript; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:_next_id; 91, identifier:stream_type; 92, integer:1; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:stream; 96, call; 96, 97; 96, 98; 97, identifier:DataStream; 98, argument_list; 98, 99; 98, 100; 99, identifier:stream_type; 100, identifier:stream_id; 101, if_statement; 101, 102; 101, 107; 102, comparison_operator:not; 102, 103; 102, 104; 103, identifier:stream; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:_allocated_streams; 107, block; 107, 108; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 115; 110, subscript; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:_allocated_streams; 114, identifier:stream; 115, tuple; 115, 116; 115, 117; 115, 118; 116, identifier:stream; 117, integer:0; 118, identifier:previous; 119, if_statement; 119, 120; 119, 121; 120, identifier:attach; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:stream; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:attach_stream; 129, argument_list; 129, 130; 130, identifier:stream; 131, return_statement; 131, 132; 132, identifier:stream | def allocate_stream(self, stream_type, stream_id=None, previous=None, attach=False):
if stream_type not in DataStream.TypeToString:
raise ArgumentError("Unknown stream type in allocate_stream", stream_type=stream_type)
if stream_id is not None and stream_id >= StreamAllocator.StartingID:
raise ArgumentError("Attempted to explicitly allocate a stream id in the internally managed id range", stream_id=stream_id, started_id=StreamAllocator.StartingID)
if stream_id is None:
if stream_type not in self._next_id:
self._next_id[stream_type] = StreamAllocator.StartingID
stream_id = self._next_id[stream_type]
self._next_id[stream_type] += 1
stream = DataStream(stream_type, stream_id)
if stream not in self._allocated_streams:
self._allocated_streams[stream] = (stream, 0, previous)
if attach:
stream = self.attach_stream(stream)
return stream |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_products; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:product_type; 6, block; 6, 7; 6, 26; 6, 83; 6, 96; 6, 107; 6, 126; 7, if_statement; 7, 8; 7, 23; 8, boolean_operator:and; 8, 9; 8, 18; 9, boolean_operator:and; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:filter_prods; 13, comparison_operator:in; 13, 14; 13, 15; 14, identifier:product_type; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:LIST_PRODUCTS; 18, comparison_operator:not; 18, 19; 18, 20; 19, identifier:product_type; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:desired_prods; 23, block; 23, 24; 24, return_statement; 24, 25; 25, list:[]; 26, if_statement; 26, 27; 26, 32; 26, 45; 27, comparison_operator:in; 27, 28; 27, 29; 28, identifier:product_type; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:LIST_PRODUCTS; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:found_products; 36, call; 36, 37; 36, 42; 37, attribute; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:products; 41, identifier:get; 42, argument_list; 42, 43; 42, 44; 43, identifier:product_type; 44, list:[]; 45, else_clause; 45, 46; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:found_products; 50, list_comprehension; 50, 51; 50, 54; 50, 63; 51, subscript; 51, 52; 51, 53; 52, identifier:x; 53, integer:0; 54, for_in_clause; 54, 55; 54, 56; 55, identifier:x; 56, call; 56, 57; 56, 62; 57, attribute; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:products; 61, identifier:items; 62, argument_list; 63, if_clause; 63, 64; 64, boolean_operator:and; 64, 65; 64, 70; 65, comparison_operator:==; 65, 66; 65, 69; 66, subscript; 66, 67; 66, 68; 67, identifier:x; 68, integer:1; 69, identifier:product_type; 70, parenthesized_expression; 70, 71; 71, boolean_operator:or; 71, 72; 71, 76; 72, not_operator; 72, 73; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:filter_prods; 76, comparison_operator:in; 76, 77; 76, 80; 77, subscript; 77, 78; 77, 79; 78, identifier:x; 79, integer:0; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:desired_prods; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:found_products; 86, list_comprehension; 86, 87; 86, 93; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:_ensure_product_string; 91, argument_list; 91, 92; 92, identifier:x; 93, for_in_clause; 93, 94; 93, 95; 94, identifier:x; 95, identifier:found_products; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:declaration; 99, call; 99, 100; 99, 105; 100, attribute; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:self; 103, identifier:PATH_PRODUCTS; 104, identifier:get; 105, argument_list; 105, 106; 106, identifier:product_type; 107, if_statement; 107, 108; 107, 111; 108, comparison_operator:is; 108, 109; 108, 110; 109, identifier:declaration; 110, None; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:found_products; 115, list_comprehension; 115, 116; 115, 123; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:_process_product_path; 120, argument_list; 120, 121; 120, 122; 121, identifier:x; 122, identifier:declaration; 123, for_in_clause; 123, 124; 123, 125; 124, identifier:x; 125, identifier:found_products; 126, return_statement; 126, 127; 127, identifier:found_products | def find_products(self, product_type):
if self.filter_prods and product_type in self.LIST_PRODUCTS and product_type not in self.desired_prods:
return []
if product_type in self.LIST_PRODUCTS:
found_products = self.products.get(product_type, [])
else:
found_products = [x[0] for x in self.products.items()
if x[1] == product_type and (not self.filter_prods or x[0] in self.desired_prods)]
found_products = [self._ensure_product_string(x) for x in found_products]
declaration = self.PATH_PRODUCTS.get(product_type)
if declaration is not None:
found_products = [self._process_product_path(x, declaration) for x in found_products]
return found_products |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_node; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node_descriptor; 6, block; 6, 7; 6, 35; 6, 48; 6, 52; 6, 190; 6, 221; 6, 230; 6, 243; 6, 251; 7, if_statement; 7, 8; 7, 24; 8, boolean_operator:and; 8, 9; 8, 14; 9, comparison_operator:is; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:_max_nodes; 13, None; 14, comparison_operator:>=; 14, 15; 14, 21; 15, call; 15, 16; 15, 17; 16, identifier:len; 17, argument_list; 17, 18; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:nodes; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:_max_nodes; 24, block; 24, 25; 25, raise_statement; 25, 26; 26, call; 26, 27; 26, 28; 27, identifier:ResourceUsageError; 28, argument_list; 28, 29; 28, 30; 29, string:"Maximum number of nodes exceeded"; 30, keyword_argument; 30, 31; 30, 32; 31, identifier:max_nodes; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:_max_nodes; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 41; 37, pattern_list; 37, 38; 37, 39; 37, 40; 38, identifier:node; 39, identifier:inputs; 40, identifier:processor; 41, call; 41, 42; 41, 43; 42, identifier:parse_node_descriptor; 43, argument_list; 43, 44; 43, 45; 44, identifier:node_descriptor; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:model; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:in_root; 51, False; 52, for_statement; 52, 53; 52, 56; 52, 60; 53, pattern_list; 53, 54; 53, 55; 54, identifier:i; 55, identifier:input_data; 56, call; 56, 57; 56, 58; 57, identifier:enumerate; 58, argument_list; 58, 59; 59, identifier:inputs; 60, block; 60, 61; 60, 67; 60, 78; 60, 102; 60, 111; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 66; 63, pattern_list; 63, 64; 63, 65; 64, identifier:selector; 65, identifier:trigger; 66, identifier:input_data; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:walker; 70, call; 70, 71; 70, 76; 71, attribute; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:sensor_log; 75, identifier:create_walker; 76, argument_list; 76, 77; 77, identifier:selector; 78, if_statement; 78, 79; 78, 84; 79, attribute; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:walker; 82, identifier:selector; 83, identifier:inexhaustible; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:walker; 89, identifier:reading; 90, call; 90, 91; 90, 92; 91, identifier:IOTileReading; 92, argument_list; 92, 93; 92, 94; 92, 101; 93, integer:0xFFFFFFFF; 94, call; 94, 95; 94, 100; 95, attribute; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:walker; 98, identifier:selector; 99, identifier:as_stream; 100, argument_list; 101, integer:0; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:node; 106, identifier:connect_input; 107, argument_list; 107, 108; 107, 109; 107, 110; 108, identifier:i; 109, identifier:walker; 110, identifier:trigger; 111, if_statement; 111, 112; 111, 118; 111, 132; 112, boolean_operator:and; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:selector; 115, identifier:input; 116, not_operator; 116, 117; 117, identifier:in_root; 118, block; 118, 119; 118, 128; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 126; 121, attribute; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:self; 124, identifier:roots; 125, identifier:append; 126, argument_list; 126, 127; 127, identifier:node; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:in_root; 131, True; 132, else_clause; 132, 133; 133, block; 133, 134; 133, 138; 133, 165; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:found; 137, False; 138, for_statement; 138, 139; 138, 140; 138, 143; 139, identifier:other; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:nodes; 143, block; 143, 144; 144, if_statement; 144, 145; 144, 153; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:selector; 148, identifier:matches; 149, argument_list; 149, 150; 150, attribute; 150, 151; 150, 152; 151, identifier:other; 152, identifier:stream; 153, block; 153, 154; 153, 161; 154, expression_statement; 154, 155; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:other; 158, identifier:connect_output; 159, argument_list; 159, 160; 160, identifier:node; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:found; 164, True; 165, if_statement; 165, 166; 165, 172; 166, boolean_operator:and; 166, 167; 166, 169; 167, not_operator; 167, 168; 168, identifier:found; 169, attribute; 169, 170; 169, 171; 170, identifier:selector; 171, identifier:buffered; 172, block; 172, 173; 173, raise_statement; 173, 174; 174, call; 174, 175; 174, 176; 175, identifier:NodeConnectionError; 176, argument_list; 176, 177; 176, 178; 176, 181; 176, 187; 177, string:"Node has input that refers to another node that has not been created yet"; 178, keyword_argument; 178, 179; 178, 180; 179, identifier:node_descriptor; 180, identifier:node_descriptor; 181, keyword_argument; 181, 182; 181, 183; 182, identifier:input_selector; 183, call; 183, 184; 183, 185; 184, identifier:str; 185, argument_list; 185, 186; 186, identifier:selector; 187, keyword_argument; 187, 188; 187, 189; 188, identifier:input_index; 189, identifier:i; 190, for_statement; 190, 191; 190, 192; 190, 195; 191, identifier:other_node; 192, attribute; 192, 193; 192, 194; 193, identifier:self; 194, identifier:nodes; 195, block; 195, 196; 196, for_statement; 196, 197; 196, 200; 196, 203; 197, pattern_list; 197, 198; 197, 199; 198, identifier:selector; 199, identifier:trigger; 200, attribute; 200, 201; 200, 202; 201, identifier:other_node; 202, identifier:inputs; 203, block; 203, 204; 204, if_statement; 204, 205; 204, 213; 205, call; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:selector; 208, identifier:matches; 209, argument_list; 209, 210; 210, attribute; 210, 211; 210, 212; 211, identifier:node; 212, identifier:stream; 213, block; 213, 214; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:node; 218, identifier:connect_output; 219, argument_list; 219, 220; 220, identifier:other_node; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:func; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:self; 227, identifier:find_processing_function; 228, argument_list; 228, 229; 229, identifier:processor; 230, if_statement; 230, 231; 230, 234; 231, comparison_operator:is; 231, 232; 231, 233; 232, identifier:func; 233, None; 234, block; 234, 235; 235, raise_statement; 235, 236; 236, call; 236, 237; 236, 238; 237, identifier:ProcessingFunctionError; 238, argument_list; 238, 239; 238, 240; 239, string:"Could not find processing function in installed packages"; 240, keyword_argument; 240, 241; 240, 242; 241, identifier:func_name; 242, identifier:processor; 243, expression_statement; 243, 244; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:node; 247, identifier:set_func; 248, argument_list; 248, 249; 248, 250; 249, identifier:processor; 250, identifier:func; 251, expression_statement; 251, 252; 252, call; 252, 253; 252, 258; 253, attribute; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:self; 256, identifier:nodes; 257, identifier:append; 258, argument_list; 258, 259; 259, identifier:node | def add_node(self, node_descriptor):
if self._max_nodes is not None and len(self.nodes) >= self._max_nodes:
raise ResourceUsageError("Maximum number of nodes exceeded", max_nodes=self._max_nodes)
node, inputs, processor = parse_node_descriptor(node_descriptor, self.model)
in_root = False
for i, input_data in enumerate(inputs):
selector, trigger = input_data
walker = self.sensor_log.create_walker(selector)
if walker.selector.inexhaustible:
walker.reading = IOTileReading(0xFFFFFFFF, walker.selector.as_stream(), 0)
node.connect_input(i, walker, trigger)
if selector.input and not in_root:
self.roots.append(node)
in_root = True
else:
found = False
for other in self.nodes:
if selector.matches(other.stream):
other.connect_output(node)
found = True
if not found and selector.buffered:
raise NodeConnectionError("Node has input that refers to another node that has not been created yet", node_descriptor=node_descriptor, input_selector=str(selector), input_index=i)
for other_node in self.nodes:
for selector, trigger in other_node.inputs:
if selector.matches(node.stream):
node.connect_output(other_node)
func = self.find_processing_function(processor)
if func is None:
raise ProcessingFunctionError("Could not find processing function in installed packages", func_name=processor)
node.set_func(processor, func)
self.nodes.append(node) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check_streamers; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:blacklist; 7, None; 8, block; 8, 9; 8, 13; 8, 19; 8, 161; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ready; 12, list:[]; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:selected; 16, call; 16, 17; 16, 18; 17, identifier:set; 18, argument_list; 19, for_statement; 19, 20; 19, 23; 19, 29; 20, pattern_list; 20, 21; 20, 22; 21, identifier:i; 22, identifier:streamer; 23, call; 23, 24; 23, 25; 24, identifier:enumerate; 25, argument_list; 25, 26; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:streamers; 29, block; 29, 30; 29, 40; 29, 46; 29, 50; 29, 70; 30, if_statement; 30, 31; 30, 38; 31, boolean_operator:and; 31, 32; 31, 35; 32, comparison_operator:is; 32, 33; 32, 34; 33, identifier:blacklist; 34, None; 35, comparison_operator:in; 35, 36; 35, 37; 36, identifier:i; 37, identifier:blacklist; 38, block; 38, 39; 39, continue_statement; 40, if_statement; 40, 41; 40, 44; 41, comparison_operator:in; 41, 42; 41, 43; 42, identifier:i; 43, identifier:selected; 44, block; 44, 45; 45, continue_statement; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:marked; 49, False; 50, if_statement; 50, 51; 50, 56; 51, comparison_operator:in; 51, 52; 51, 53; 52, identifier:i; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:_manually_triggered_streamers; 56, block; 56, 57; 56, 61; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:marked; 60, True; 61, expression_statement; 61, 62; 62, call; 62, 63; 62, 68; 63, attribute; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:_manually_triggered_streamers; 67, identifier:remove; 68, argument_list; 68, 69; 69, identifier:i; 70, if_statement; 70, 71; 70, 77; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:streamer; 74, identifier:triggered; 75, argument_list; 75, 76; 76, identifier:marked; 77, block; 77, 78; 77, 89; 77, 96; 77, 103; 78, expression_statement; 78, 79; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:_logger; 84, identifier:debug; 85, argument_list; 85, 86; 85, 87; 85, 88; 86, string:"Streamer %d triggered, manual=%s"; 87, identifier:i; 88, identifier:marked; 89, expression_statement; 89, 90; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:ready; 93, identifier:append; 94, argument_list; 94, 95; 95, identifier:streamer; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:selected; 100, identifier:add; 101, argument_list; 101, 102; 102, identifier:i; 103, for_statement; 103, 104; 103, 107; 103, 117; 104, pattern_list; 104, 105; 104, 106; 105, identifier:j; 106, identifier:streamer2; 107, call; 107, 108; 107, 109; 108, identifier:enumerate; 109, argument_list; 109, 110; 110, subscript; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:streamers; 114, slice; 114, 115; 114, 116; 115, identifier:i; 116, colon; 117, block; 117, 118; 118, if_statement; 118, 119; 118, 135; 119, boolean_operator:and; 119, 120; 119, 129; 120, boolean_operator:and; 120, 121; 120, 126; 121, comparison_operator:==; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:streamer2; 124, identifier:with_other; 125, identifier:i; 126, comparison_operator:not; 126, 127; 126, 128; 127, identifier:j; 128, identifier:selected; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:streamer2; 132, identifier:triggered; 133, argument_list; 133, 134; 134, True; 135, block; 135, 136; 135, 147; 135, 154; 136, expression_statement; 136, 137; 137, call; 137, 138; 137, 143; 138, attribute; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:_logger; 142, identifier:debug; 143, argument_list; 143, 144; 143, 145; 143, 146; 144, string:"Streamer %d triggered due to with-other on %d"; 145, identifier:j; 146, identifier:i; 147, expression_statement; 147, 148; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:ready; 151, identifier:append; 152, argument_list; 152, 153; 153, identifier:streamer2; 154, expression_statement; 154, 155; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:selected; 158, identifier:add; 159, argument_list; 159, 160; 160, identifier:j; 161, return_statement; 161, 162; 162, identifier:ready | def check_streamers(self, blacklist=None):
ready = []
selected = set()
for i, streamer in enumerate(self.streamers):
if blacklist is not None and i in blacklist:
continue
if i in selected:
continue
marked = False
if i in self._manually_triggered_streamers:
marked = True
self._manually_triggered_streamers.remove(i)
if streamer.triggered(marked):
self._logger.debug("Streamer %d triggered, manual=%s", i, marked)
ready.append(streamer)
selected.add(i)
for j, streamer2 in enumerate(self.streamers[i:]):
if streamer2.with_other == i and j not in selected and streamer2.triggered(True):
self._logger.debug("Streamer %d triggered due to with-other on %d", j, i)
ready.append(streamer2)
selected.add(j)
return ready |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_nodes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 26; 5, 30; 5, 69; 5, 76; 5, 90; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:node_map; 9, dictionary_comprehension; 9, 10; 9, 16; 10, pair; 10, 11; 10, 15; 11, call; 11, 12; 11, 13; 12, identifier:id; 13, argument_list; 13, 14; 14, identifier:node; 15, identifier:i; 16, for_in_clause; 16, 17; 16, 20; 17, pattern_list; 17, 18; 17, 19; 18, identifier:i; 19, identifier:node; 20, call; 20, 21; 20, 22; 21, identifier:enumerate; 22, argument_list; 22, 23; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:nodes; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:node_deps; 29, dictionary; 30, for_statement; 30, 31; 30, 35; 30, 40; 31, pattern_list; 31, 32; 31, 33; 31, 34; 32, identifier:node; 33, identifier:inputs; 34, identifier:_outputs; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:iterate_bfs; 39, argument_list; 40, block; 40, 41; 40, 50; 40, 63; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:node_index; 44, subscript; 44, 45; 44, 46; 45, identifier:node_map; 46, call; 46, 47; 46, 48; 47, identifier:id; 48, argument_list; 48, 49; 49, identifier:node; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:deps; 53, set_comprehension; 53, 54; 53, 60; 54, subscript; 54, 55; 54, 56; 55, identifier:node_map; 56, call; 56, 57; 56, 58; 57, identifier:id; 58, argument_list; 58, 59; 59, identifier:x; 60, for_in_clause; 60, 61; 60, 62; 61, identifier:x; 62, identifier:inputs; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 68; 65, subscript; 65, 66; 65, 67; 66, identifier:node_deps; 67, identifier:node_index; 68, identifier:deps; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:node_order; 72, call; 72, 73; 72, 74; 73, identifier:toposort_flatten; 74, argument_list; 74, 75; 75, identifier:node_deps; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:nodes; 81, list_comprehension; 81, 82; 81, 87; 82, subscript; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:self; 85, identifier:nodes; 86, identifier:x; 87, for_in_clause; 87, 88; 87, 89; 88, identifier:x; 89, identifier:node_order; 90, for_statement; 90, 91; 90, 92; 90, 95; 91, identifier:root; 92, attribute; 92, 93; 92, 94; 93, identifier:self; 94, identifier:roots; 95, block; 95, 96; 96, if_statement; 96, 97; 96, 112; 97, comparison_operator:not; 97, 98; 97, 99; 98, identifier:root; 99, subscript; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:nodes; 103, slice; 103, 104; 103, 105; 103, 106; 104, integer:0; 105, colon; 106, call; 106, 107; 106, 108; 107, identifier:len; 108, argument_list; 108, 109; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:roots; 112, block; 112, 113; 113, raise_statement; 113, 114; 114, call; 114, 115; 114, 116; 115, identifier:NodeConnectionError; 116, argument_list; 116, 117; 116, 118; 116, 124; 117, string:"Inputs not sorted in the beginning"; 118, keyword_argument; 118, 119; 118, 120; 119, identifier:node; 120, call; 120, 121; 120, 122; 121, identifier:str; 122, argument_list; 122, 123; 123, identifier:root; 124, keyword_argument; 124, 125; 124, 126; 125, identifier:node_position; 126, call; 126, 127; 126, 132; 127, attribute; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:self; 130, identifier:nodes; 131, identifier:index; 132, argument_list; 132, 133; 133, identifier:root | def sort_nodes(self):
node_map = {id(node): i for i, node in enumerate(self.nodes)}
node_deps = {}
for node, inputs, _outputs in self.iterate_bfs():
node_index = node_map[id(node)]
deps = {node_map[id(x)] for x in inputs}
node_deps[node_index] = deps
node_order = toposort_flatten(node_deps)
self.nodes = [self.nodes[x] for x in node_order]
for root in self.roots:
if root not in self.nodes[0:len(self.roots)]:
raise NodeConnectionError("Inputs not sorted in the beginning", node=str(root), node_position=self.nodes.index(root)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mark_typed_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:type_object; 7, block; 7, 8; 7, 23; 7, 38; 7, 80; 7, 103; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:hasattr; 12, argument_list; 12, 13; 12, 14; 13, identifier:type_object; 14, string:'dump'; 15, block; 15, 16; 16, raise_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:ArgumentError; 19, argument_list; 19, 20; 20, binary_operator:%; 20, 21; 20, 22; 21, string:"The passed type object %s is missing required method: dump()"; 22, identifier:type_object; 23, if_statement; 23, 24; 23, 30; 24, not_operator; 24, 25; 25, call; 25, 26; 25, 27; 26, identifier:hasattr; 27, argument_list; 27, 28; 27, 29; 28, identifier:type_object; 29, string:'Restore'; 30, block; 30, 31; 31, raise_statement; 31, 32; 32, call; 32, 33; 32, 34; 33, identifier:ArgumentError; 34, argument_list; 34, 35; 35, binary_operator:%; 35, 36; 35, 37; 36, string:"The passed type object %s is missing required method: Restore()"; 37, identifier:type_object; 38, function_definition; 38, 39; 38, 40; 38, 42; 39, function_name:_dump_list; 40, parameters; 40, 41; 41, identifier:obj; 42, block; 42, 43; 42, 50; 42, 70; 43, if_statement; 43, 44; 43, 47; 44, comparison_operator:is; 44, 45; 44, 46; 45, identifier:obj; 46, None; 47, block; 47, 48; 48, return_statement; 48, 49; 49, None; 50, if_statement; 50, 51; 50, 57; 51, not_operator; 51, 52; 52, call; 52, 53; 52, 54; 53, identifier:isinstance; 54, argument_list; 54, 55; 54, 56; 55, identifier:obj; 56, identifier:list; 57, block; 57, 58; 58, raise_statement; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:DataError; 61, argument_list; 61, 62; 62, binary_operator:%; 62, 63; 62, 64; 63, string:"Property %s marked as list was not a list: %s"; 64, tuple; 64, 65; 64, 66; 65, identifier:name; 66, call; 66, 67; 66, 68; 67, identifier:repr; 68, argument_list; 68, 69; 69, identifier:obj; 70, return_statement; 70, 71; 71, list_comprehension; 71, 72; 71, 77; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:x; 75, identifier:dump; 76, argument_list; 77, for_in_clause; 77, 78; 77, 79; 78, identifier:x; 79, identifier:obj; 80, function_definition; 80, 81; 80, 82; 80, 84; 81, function_name:_restore_list; 82, parameters; 82, 83; 83, identifier:obj; 84, block; 84, 85; 84, 92; 85, if_statement; 85, 86; 85, 89; 86, comparison_operator:is; 86, 87; 86, 88; 87, identifier:obj; 88, None; 89, block; 89, 90; 90, return_statement; 90, 91; 91, identifier:obj; 92, return_statement; 92, 93; 93, list_comprehension; 93, 94; 93, 100; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:type_object; 97, identifier:Restore; 98, argument_list; 98, 99; 99, identifier:x; 100, for_in_clause; 100, 101; 100, 102; 101, identifier:x; 102, identifier:obj; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:self; 107, identifier:mark_complex; 108, argument_list; 108, 109; 108, 110; 108, 111; 109, identifier:name; 110, identifier:_dump_list; 111, identifier:_restore_list | def mark_typed_list(self, name, type_object):
if not hasattr(type_object, 'dump'):
raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object)
if not hasattr(type_object, 'Restore'):
raise ArgumentError("The passed type object %s is missing required method: Restore()" % type_object)
def _dump_list(obj):
if obj is None:
return None
if not isinstance(obj, list):
raise DataError("Property %s marked as list was not a list: %s" % (name, repr(obj)))
return [x.dump() for x in obj]
def _restore_list(obj):
if obj is None:
return obj
return [type_object.Restore(x) for x in obj]
self.mark_complex(name, _dump_list, _restore_list) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mark_typed_map; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:type_object; 7, block; 7, 8; 7, 23; 7, 38; 7, 88; 7, 119; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:hasattr; 12, argument_list; 12, 13; 12, 14; 13, identifier:type_object; 14, string:'dump'; 15, block; 15, 16; 16, raise_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:ArgumentError; 19, argument_list; 19, 20; 20, binary_operator:%; 20, 21; 20, 22; 21, string:"The passed type object %s is missing required method: dump()"; 22, identifier:type_object; 23, if_statement; 23, 24; 23, 30; 24, not_operator; 24, 25; 25, call; 25, 26; 25, 27; 26, identifier:hasattr; 27, argument_list; 27, 28; 27, 29; 28, identifier:type_object; 29, string:'Restore'; 30, block; 30, 31; 31, raise_statement; 31, 32; 32, call; 32, 33; 32, 34; 33, identifier:ArgumentError; 34, argument_list; 34, 35; 35, binary_operator:%; 35, 36; 35, 37; 36, string:"The passed type object %s is missing required method: Restore()"; 37, identifier:type_object; 38, function_definition; 38, 39; 38, 40; 38, 42; 39, function_name:_dump_map; 40, parameters; 40, 41; 41, identifier:obj; 42, block; 42, 43; 42, 50; 42, 70; 43, if_statement; 43, 44; 43, 47; 44, comparison_operator:is; 44, 45; 44, 46; 45, identifier:obj; 46, None; 47, block; 47, 48; 48, return_statement; 48, 49; 49, None; 50, if_statement; 50, 51; 50, 57; 51, not_operator; 51, 52; 52, call; 52, 53; 52, 54; 53, identifier:isinstance; 54, argument_list; 54, 55; 54, 56; 55, identifier:obj; 56, identifier:dict; 57, block; 57, 58; 58, raise_statement; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:DataError; 61, argument_list; 61, 62; 62, binary_operator:%; 62, 63; 62, 64; 63, string:"Property %s marked as list was not a dict: %s"; 64, tuple; 64, 65; 64, 66; 65, identifier:name; 66, call; 66, 67; 66, 68; 67, identifier:repr; 68, argument_list; 68, 69; 69, identifier:obj; 70, return_statement; 70, 71; 71, dictionary_comprehension; 71, 72; 71, 79; 72, pair; 72, 73; 72, 74; 73, identifier:key; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:val; 77, identifier:dump; 78, argument_list; 79, for_in_clause; 79, 80; 79, 83; 80, pattern_list; 80, 81; 80, 82; 81, identifier:key; 82, identifier:val; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:obj; 86, identifier:items; 87, argument_list; 88, function_definition; 88, 89; 88, 90; 88, 92; 89, function_name:_restore_map; 90, parameters; 90, 91; 91, identifier:obj; 92, block; 92, 93; 92, 100; 93, if_statement; 93, 94; 93, 97; 94, comparison_operator:is; 94, 95; 94, 96; 95, identifier:obj; 96, None; 97, block; 97, 98; 98, return_statement; 98, 99; 99, identifier:obj; 100, return_statement; 100, 101; 101, dictionary_comprehension; 101, 102; 101, 110; 102, pair; 102, 103; 102, 104; 103, identifier:key; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:type_object; 107, identifier:Restore; 108, argument_list; 108, 109; 109, identifier:val; 110, for_in_clause; 110, 111; 110, 114; 111, pattern_list; 111, 112; 111, 113; 112, identifier:key; 113, identifier:val; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:obj; 117, identifier:items; 118, argument_list; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:self; 123, identifier:mark_complex; 124, argument_list; 124, 125; 124, 126; 124, 127; 125, identifier:name; 126, identifier:_dump_map; 127, identifier:_restore_map | def mark_typed_map(self, name, type_object):
if not hasattr(type_object, 'dump'):
raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object)
if not hasattr(type_object, 'Restore'):
raise ArgumentError("The passed type object %s is missing required method: Restore()" % type_object)
def _dump_map(obj):
if obj is None:
return None
if not isinstance(obj, dict):
raise DataError("Property %s marked as list was not a dict: %s" % (name, repr(obj)))
return {key: val.dump() for key, val in obj.items()}
def _restore_map(obj):
if obj is None:
return obj
return {key: type_object.Restore(val) for key, val in obj.items()}
self.mark_complex(name, _dump_map, _restore_map) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mark_typed_object; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:type_object; 7, block; 7, 8; 7, 23; 7, 38; 7, 56; 7, 75; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:hasattr; 12, argument_list; 12, 13; 12, 14; 13, identifier:type_object; 14, string:'dump'; 15, block; 15, 16; 16, raise_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:ArgumentError; 19, argument_list; 19, 20; 20, binary_operator:%; 20, 21; 20, 22; 21, string:"The passed type object %s is missing required method: dump()"; 22, identifier:type_object; 23, if_statement; 23, 24; 23, 30; 24, not_operator; 24, 25; 25, call; 25, 26; 25, 27; 26, identifier:hasattr; 27, argument_list; 27, 28; 27, 29; 28, identifier:type_object; 29, string:'Restore'; 30, block; 30, 31; 31, raise_statement; 31, 32; 32, call; 32, 33; 32, 34; 33, identifier:ArgumentError; 34, argument_list; 34, 35; 35, binary_operator:%; 35, 36; 35, 37; 36, string:"The passed type object %s is missing required method: Restore()"; 37, identifier:type_object; 38, function_definition; 38, 39; 38, 40; 38, 42; 39, function_name:_dump_obj; 40, parameters; 40, 41; 41, identifier:obj; 42, block; 42, 43; 42, 50; 43, if_statement; 43, 44; 43, 47; 44, comparison_operator:is; 44, 45; 44, 46; 45, identifier:obj; 46, None; 47, block; 47, 48; 48, return_statement; 48, 49; 49, None; 50, return_statement; 50, 51; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:obj; 54, identifier:dump; 55, argument_list; 56, function_definition; 56, 57; 56, 58; 56, 60; 57, function_name:_restore_obj; 58, parameters; 58, 59; 59, identifier:obj; 60, block; 60, 61; 60, 68; 61, if_statement; 61, 62; 61, 65; 62, comparison_operator:is; 62, 63; 62, 64; 63, identifier:obj; 64, None; 65, block; 65, 66; 66, return_statement; 66, 67; 67, identifier:obj; 68, return_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:type_object; 72, identifier:Restore; 73, argument_list; 73, 74; 74, identifier:obj; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:mark_complex; 80, argument_list; 80, 81; 80, 82; 80, 83; 81, identifier:name; 82, identifier:_dump_obj; 83, identifier:_restore_obj | def mark_typed_object(self, name, type_object):
if not hasattr(type_object, 'dump'):
raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object)
if not hasattr(type_object, 'Restore'):
raise ArgumentError("The passed type object %s is missing required method: Restore()" % type_object)
def _dump_obj(obj):
if obj is None:
return None
return obj.dump()
def _restore_obj(obj):
if obj is None:
return obj
return type_object.Restore(obj)
self.mark_complex(name, _dump_obj, _restore_obj) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:scan; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:node; 5, identifier:env; 6, default_parameter; 6, 7; 6, 8; 7, identifier:libpath; 8, tuple; 9, block; 9, 10; 9, 23; 9, 31; 9, 63; 9, 95; 9, 99; 9, 128; 9, 132; 9, 144; 9, 154; 9, 162; 9, 221; 10, try_statement; 10, 11; 10, 18; 11, block; 11, 12; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:libs; 15, subscript; 15, 16; 15, 17; 16, identifier:env; 17, string:'LIBS'; 18, except_clause; 18, 19; 18, 20; 19, identifier:KeyError; 20, block; 20, 21; 21, return_statement; 21, 22; 22, list:[]; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:libs; 26, call; 26, 27; 26, 28; 27, identifier:_subst_libs; 28, argument_list; 28, 29; 28, 30; 29, identifier:env; 30, identifier:libs; 31, try_statement; 31, 32; 31, 55; 32, block; 32, 33; 32, 39; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:prefix; 36, subscript; 36, 37; 36, 38; 37, identifier:env; 38, string:'LIBPREFIXES'; 39, if_statement; 39, 40; 39, 49; 40, not_operator; 40, 41; 41, call; 41, 42; 41, 47; 42, attribute; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:SCons; 45, identifier:Util; 46, identifier:is_List; 47, argument_list; 47, 48; 48, identifier:prefix; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:prefix; 53, list:[ prefix ]; 53, 54; 54, identifier:prefix; 55, except_clause; 55, 56; 55, 57; 56, identifier:KeyError; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:prefix; 61, list:[ '' ]; 61, 62; 62, string:''; 63, try_statement; 63, 64; 63, 87; 64, block; 64, 65; 64, 71; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:suffix; 68, subscript; 68, 69; 68, 70; 69, identifier:env; 70, string:'LIBSUFFIXES'; 71, if_statement; 71, 72; 71, 81; 72, not_operator; 72, 73; 73, call; 73, 74; 73, 79; 74, attribute; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:SCons; 77, identifier:Util; 78, identifier:is_List; 79, argument_list; 79, 80; 80, identifier:suffix; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:suffix; 85, list:[ suffix ]; 85, 86; 86, identifier:suffix; 87, except_clause; 87, 88; 87, 89; 88, identifier:KeyError; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:suffix; 93, list:[ '' ]; 93, 94; 94, string:''; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:pairs; 98, list:[]; 99, for_statement; 99, 100; 99, 101; 99, 108; 100, identifier:suf; 101, call; 101, 102; 101, 103; 102, identifier:map; 103, argument_list; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:env; 106, identifier:subst; 107, identifier:suffix; 108, block; 108, 109; 109, for_statement; 109, 110; 109, 111; 109, 118; 110, identifier:pref; 111, call; 111, 112; 111, 113; 112, identifier:map; 113, argument_list; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:env; 116, identifier:subst; 117, identifier:prefix; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:pairs; 123, identifier:append; 124, argument_list; 124, 125; 125, tuple; 125, 126; 125, 127; 126, identifier:pref; 127, identifier:suf; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:result; 131, list:[]; 132, if_statement; 132, 133; 132, 137; 133, call; 133, 134; 133, 135; 134, identifier:callable; 135, argument_list; 135, 136; 136, identifier:libpath; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:libpath; 141, call; 141, 142; 141, 143; 142, identifier:libpath; 143, argument_list; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:find_file; 147, attribute; 147, 148; 147, 153; 148, attribute; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:SCons; 151, identifier:Node; 152, identifier:FS; 153, identifier:find_file; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:adjustixes; 157, attribute; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:SCons; 160, identifier:Util; 161, identifier:adjustixes; 162, for_statement; 162, 163; 162, 164; 162, 165; 163, identifier:lib; 164, identifier:libs; 165, block; 165, 166; 166, if_statement; 166, 167; 166, 175; 166, 212; 167, call; 167, 168; 167, 173; 168, attribute; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:SCons; 171, identifier:Util; 172, identifier:is_String; 173, argument_list; 173, 174; 174, identifier:lib; 175, block; 175, 176; 176, for_statement; 176, 177; 176, 180; 176, 181; 177, pattern_list; 177, 178; 177, 179; 178, identifier:pref; 179, identifier:suf; 180, identifier:pairs; 181, block; 181, 182; 181, 191; 181, 202; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:l; 185, call; 185, 186; 185, 187; 186, identifier:adjustixes; 187, argument_list; 187, 188; 187, 189; 187, 190; 188, identifier:lib; 189, identifier:pref; 190, identifier:suf; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:l; 194, call; 194, 195; 194, 196; 195, identifier:find_file; 196, argument_list; 196, 197; 196, 198; 196, 199; 197, identifier:l; 198, identifier:libpath; 199, keyword_argument; 199, 200; 199, 201; 200, identifier:verbose; 201, identifier:print_find_libs; 202, if_statement; 202, 203; 202, 204; 203, identifier:l; 204, block; 204, 205; 205, expression_statement; 205, 206; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:result; 209, identifier:append; 210, argument_list; 210, 211; 211, identifier:l; 212, else_clause; 212, 213; 213, block; 213, 214; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:result; 218, identifier:append; 219, argument_list; 219, 220; 220, identifier:lib; 221, return_statement; 221, 222; 222, identifier:result | def scan(node, env, libpath = ()):
try:
libs = env['LIBS']
except KeyError:
return []
libs = _subst_libs(env, libs)
try:
prefix = env['LIBPREFIXES']
if not SCons.Util.is_List(prefix):
prefix = [ prefix ]
except KeyError:
prefix = [ '' ]
try:
suffix = env['LIBSUFFIXES']
if not SCons.Util.is_List(suffix):
suffix = [ suffix ]
except KeyError:
suffix = [ '' ]
pairs = []
for suf in map(env.subst, suffix):
for pref in map(env.subst, prefix):
pairs.append((pref, suf))
result = []
if callable(libpath):
libpath = libpath()
find_file = SCons.Node.FS.find_file
adjustixes = SCons.Util.adjustixes
for lib in libs:
if SCons.Util.is_String(lib):
for pref, suf in pairs:
l = adjustixes(lib, pref, suf)
l = find_file(l, libpath, verbose=print_find_libs)
if l:
result.append(l)
else:
result.append(lib)
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:render_recursive_template; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:template_folder; 5, identifier:info; 6, identifier:out_folder; 7, default_parameter; 7, 8; 7, 9; 8, identifier:preserve; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:dry_run; 12, False; 13, block; 13, 14; 13, 29; 13, 38; 13, 45; 13, 55; 13, 67; 13, 111; 13, 115; 13, 119; 13, 245; 13, 361; 14, if_statement; 14, 15; 14, 20; 15, call; 15, 16; 15, 17; 16, identifier:isinstance; 17, argument_list; 17, 18; 17, 19; 18, identifier:preserve; 19, identifier:str; 20, block; 20, 21; 21, raise_statement; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:ArgumentError; 24, argument_list; 24, 25; 24, 26; 25, string:"You must pass a list of strings to preserve, not a string"; 26, keyword_argument; 26, 27; 26, 28; 27, identifier:preserve; 28, identifier:preserve; 29, if_statement; 29, 30; 29, 33; 30, comparison_operator:is; 30, 31; 30, 32; 31, identifier:preserve; 32, None; 33, block; 33, 34; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:preserve; 37, list:[]; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:preserve; 41, call; 41, 42; 41, 43; 42, identifier:set; 43, argument_list; 43, 44; 44, identifier:preserve; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:template_dir; 48, call; 48, 49; 48, 50; 49, identifier:resource_path; 50, argument_list; 50, 51; 50, 52; 51, string:'templates'; 52, keyword_argument; 52, 53; 52, 54; 53, identifier:expect; 54, string:'folder'; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:indir; 58, call; 58, 59; 58, 64; 59, attribute; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:os; 62, identifier:path; 63, identifier:join; 64, argument_list; 64, 65; 64, 66; 65, identifier:template_dir; 66, identifier:template_folder; 67, if_statement; 67, 68; 67, 77; 67, 89; 68, not_operator; 68, 69; 69, call; 69, 70; 69, 75; 70, attribute; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:os; 73, identifier:path; 74, identifier:exists; 75, argument_list; 75, 76; 76, identifier:indir; 77, block; 77, 78; 78, raise_statement; 78, 79; 79, call; 79, 80; 79, 81; 80, identifier:ArgumentError; 81, argument_list; 81, 82; 81, 83; 81, 86; 82, string:"Input template folder for recursive template not found"; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:template_folder; 85, identifier:template_folder; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:absolute_path; 88, identifier:indir; 89, elif_clause; 89, 90; 89, 99; 90, not_operator; 90, 91; 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:isdir; 97, argument_list; 97, 98; 98, identifier:indir; 99, block; 99, 100; 100, raise_statement; 100, 101; 101, call; 101, 102; 101, 103; 102, identifier:ArgumentError; 103, argument_list; 103, 104; 103, 105; 103, 108; 104, string:"Input template folder is not a directory"; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:template_folder; 107, identifier:template_folder; 108, keyword_argument; 108, 109; 108, 110; 109, identifier:absolute_path; 110, identifier:indir; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:create_dirs; 114, list:[]; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:file_map; 118, dictionary; 119, for_statement; 119, 120; 119, 124; 119, 130; 120, pattern_list; 120, 121; 120, 122; 120, 123; 121, identifier:dirpath; 122, identifier:dirs; 123, identifier:files; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:os; 127, identifier:walk; 128, argument_list; 128, 129; 129, identifier:indir; 130, block; 130, 131; 131, for_statement; 131, 132; 131, 133; 131, 134; 132, identifier:file; 133, identifier:files; 134, block; 134, 135; 134, 154; 134, 176; 134, 204; 134, 212; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:in_abspath; 138, call; 138, 139; 138, 144; 139, attribute; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:os; 142, identifier:path; 143, identifier:abspath; 144, argument_list; 144, 145; 145, call; 145, 146; 145, 151; 146, attribute; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:os; 149, identifier:path; 150, identifier:join; 151, argument_list; 151, 152; 151, 153; 152, identifier:dirpath; 153, identifier:file; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:in_path; 157, call; 157, 158; 157, 163; 158, attribute; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:os; 161, identifier:path; 162, identifier:relpath; 163, argument_list; 163, 164; 163, 173; 164, call; 164, 165; 164, 170; 165, attribute; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:os; 168, identifier:path; 169, identifier:join; 170, argument_list; 170, 171; 170, 172; 171, identifier:dirpath; 172, identifier:file; 173, keyword_argument; 173, 174; 173, 175; 174, identifier:start; 175, identifier:indir; 176, if_statement; 176, 177; 176, 188; 176, 198; 177, boolean_operator:and; 177, 178; 177, 184; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:file; 181, identifier:endswith; 182, argument_list; 182, 183; 183, string:".tpl"; 184, not_operator; 184, 185; 185, comparison_operator:in; 185, 186; 185, 187; 186, identifier:in_path; 187, identifier:preserve; 188, block; 188, 189; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:out_path; 192, subscript; 192, 193; 192, 194; 193, identifier:in_path; 194, slice; 194, 195; 194, 196; 195, colon; 196, unary_operator:-; 196, 197; 197, integer:4; 198, else_clause; 198, 199; 199, block; 199, 200; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:out_path; 203, identifier:in_path; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 209; 206, subscript; 206, 207; 206, 208; 207, identifier:file_map; 208, identifier:out_path; 209, tuple; 209, 210; 209, 211; 210, identifier:in_path; 211, identifier:in_abspath; 212, for_statement; 212, 213; 212, 214; 212, 215; 213, identifier:folder; 214, identifier:dirs; 215, block; 215, 216; 215, 238; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:dir_path; 219, call; 219, 220; 219, 225; 220, attribute; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:os; 223, identifier:path; 224, identifier:relpath; 225, argument_list; 225, 226; 225, 235; 226, call; 226, 227; 226, 232; 227, attribute; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:os; 230, identifier:path; 231, identifier:join; 232, argument_list; 232, 233; 232, 234; 233, identifier:dirpath; 234, identifier:folder; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:start; 237, identifier:indir; 238, expression_statement; 238, 239; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:create_dirs; 242, identifier:append; 243, argument_list; 243, 244; 244, identifier:dir_path; 245, if_statement; 245, 246; 245, 248; 246, not_operator; 246, 247; 247, identifier:dry_run; 248, block; 248, 249; 248, 283; 249, for_statement; 249, 250; 249, 251; 249, 252; 250, identifier:folder; 251, identifier:create_dirs; 252, block; 252, 253; 252, 265; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 256; 255, identifier:out_path; 256, call; 256, 257; 256, 262; 257, attribute; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:os; 260, identifier:path; 261, identifier:join; 262, argument_list; 262, 263; 262, 264; 263, identifier:out_folder; 264, identifier:folder; 265, if_statement; 265, 266; 265, 275; 266, not_operator; 266, 267; 267, call; 267, 268; 267, 273; 268, attribute; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:os; 271, identifier:path; 272, identifier:isdir; 273, argument_list; 273, 274; 274, identifier:out_path; 275, block; 275, 276; 276, expression_statement; 276, 277; 277, call; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, identifier:os; 280, identifier:makedirs; 281, argument_list; 281, 282; 282, identifier:out_path; 283, for_statement; 283, 284; 283, 289; 283, 294; 284, pattern_list; 284, 285; 284, 286; 285, identifier:out_rel; 286, tuple_pattern; 286, 287; 286, 288; 287, identifier:in_path; 288, identifier:in_abspath; 289, call; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:file_map; 292, identifier:items; 293, argument_list; 294, block; 294, 295; 294, 307; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:out_path; 298, call; 298, 299; 298, 304; 299, attribute; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:os; 302, identifier:path; 303, identifier:join; 304, argument_list; 304, 305; 304, 306; 305, identifier:out_folder; 306, identifier:out_rel; 307, if_statement; 307, 308; 307, 319; 307, 328; 308, boolean_operator:or; 308, 309; 308, 312; 309, comparison_operator:in; 309, 310; 309, 311; 310, identifier:in_path; 311, identifier:preserve; 312, not_operator; 312, 313; 313, call; 313, 314; 313, 317; 314, attribute; 314, 315; 314, 316; 315, identifier:in_path; 316, identifier:endswith; 317, argument_list; 317, 318; 318, string:".tpl"; 319, block; 319, 320; 320, expression_statement; 320, 321; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:shutil; 324, identifier:copyfile; 325, argument_list; 325, 326; 325, 327; 326, identifier:in_abspath; 327, identifier:out_path; 328, else_clause; 328, 329; 329, block; 329, 330; 329, 352; 330, expression_statement; 330, 331; 331, assignment; 331, 332; 331, 333; 332, identifier:in_template_path; 333, call; 333, 334; 333, 345; 334, attribute; 334, 335; 334, 344; 335, call; 335, 336; 335, 341; 336, attribute; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:os; 339, identifier:path; 340, identifier:join; 341, argument_list; 341, 342; 341, 343; 342, identifier:template_folder; 343, identifier:in_path; 344, identifier:replace; 345, argument_list; 345, 346; 345, 351; 346, attribute; 346, 347; 346, 350; 347, attribute; 347, 348; 347, 349; 348, identifier:os; 349, identifier:path; 350, identifier:sep; 351, string:'/'; 352, expression_statement; 352, 353; 353, call; 353, 354; 353, 355; 354, identifier:render_template; 355, argument_list; 355, 356; 355, 357; 355, 358; 356, identifier:in_template_path; 357, identifier:info; 358, keyword_argument; 358, 359; 358, 360; 359, identifier:out_path; 360, identifier:out_path; 361, return_statement; 361, 362; 362, expression_list; 362, 363; 362, 364; 363, identifier:file_map; 364, identifier:create_dirs | def render_recursive_template(template_folder, info, out_folder, preserve=None, dry_run=False):
if isinstance(preserve, str):
raise ArgumentError("You must pass a list of strings to preserve, not a string", preserve=preserve)
if preserve is None:
preserve = []
preserve = set(preserve)
template_dir = resource_path('templates', expect='folder')
indir = os.path.join(template_dir, template_folder)
if not os.path.exists(indir):
raise ArgumentError("Input template folder for recursive template not found",
template_folder=template_folder, absolute_path=indir)
elif not os.path.isdir(indir):
raise ArgumentError("Input template folder is not a directory",
template_folder=template_folder, absolute_path=indir)
create_dirs = []
file_map = {}
for dirpath, dirs, files in os.walk(indir):
for file in files:
in_abspath = os.path.abspath(os.path.join(dirpath, file))
in_path = os.path.relpath(os.path.join(dirpath, file), start=indir)
if file.endswith(".tpl") and not in_path in preserve:
out_path = in_path[:-4]
else:
out_path = in_path
file_map[out_path] = (in_path, in_abspath)
for folder in dirs:
dir_path = os.path.relpath(os.path.join(dirpath, folder), start=indir)
create_dirs.append(dir_path)
if not dry_run:
for folder in create_dirs:
out_path = os.path.join(out_folder, folder)
if not os.path.isdir(out_path):
os.makedirs(out_path)
for out_rel, (in_path, in_abspath) in file_map.items():
out_path = os.path.join(out_folder, out_rel)
if in_path in preserve or not in_path.endswith(".tpl"):
shutil.copyfile(in_abspath, out_path)
else:
in_template_path = os.path.join(template_folder, in_path).replace(os.path.sep, '/')
render_template(in_template_path, info, out_path=out_path)
return file_map, create_dirs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:Update; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:env; 6, default_parameter; 6, 7; 6, 8; 7, identifier:args; 8, None; 9, block; 9, 10; 9, 14; 9, 38; 9, 137; 9, 148; 9, 207; 9, 231; 9, 316; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:values; 13, dictionary; 14, for_statement; 14, 15; 14, 16; 14, 19; 15, identifier:option; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:options; 19, block; 19, 20; 20, if_statement; 20, 21; 20, 27; 21, not_operator; 21, 22; 22, comparison_operator:is; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:option; 25, identifier:default; 26, None; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 35; 30, subscript; 30, 31; 30, 32; 31, identifier:values; 32, attribute; 32, 33; 32, 34; 33, identifier:option; 34, identifier:key; 35, attribute; 35, 36; 35, 37; 36, identifier:option; 37, identifier:default; 38, for_statement; 38, 39; 38, 40; 38, 43; 39, identifier:filename; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:files; 43, block; 43, 44; 44, if_statement; 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:exists; 51, argument_list; 51, 52; 52, identifier:filename; 53, block; 53, 54; 53, 74; 53, 87; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:dir; 57, subscript; 57, 58; 57, 73; 58, call; 58, 59; 58, 64; 59, attribute; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:os; 62, identifier:path; 63, identifier:split; 64, argument_list; 64, 65; 65, call; 65, 66; 65, 71; 66, attribute; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:os; 69, identifier:path; 70, identifier:abspath; 71, argument_list; 71, 72; 72, identifier:filename; 73, integer:0; 74, if_statement; 74, 75; 74, 76; 75, identifier:dir; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, call; 78, 79; 78, 84; 79, attribute; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:sys; 82, identifier:path; 83, identifier:insert; 84, argument_list; 84, 85; 84, 86; 85, integer:0; 86, identifier:dir; 87, try_statement; 87, 88; 87, 122; 88, block; 88, 89; 88, 95; 88, 115; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 94; 91, subscript; 91, 92; 91, 93; 92, identifier:values; 93, string:'__name__'; 94, identifier:filename; 95, with_statement; 95, 96; 95, 106; 96, with_clause; 96, 97; 97, with_item; 97, 98; 98, as_pattern; 98, 99; 98, 104; 99, call; 99, 100; 99, 101; 100, identifier:open; 101, argument_list; 101, 102; 101, 103; 102, identifier:filename; 103, string:'r'; 104, as_pattern_target; 104, 105; 105, identifier:f; 106, block; 106, 107; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:contents; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:f; 113, identifier:read; 114, argument_list; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 118; 117, identifier:exec; 118, argument_list; 118, 119; 118, 120; 118, 121; 119, identifier:contents; 120, dictionary; 121, identifier:values; 122, finally_clause; 122, 123; 123, block; 123, 124; 123, 133; 124, if_statement; 124, 125; 124, 126; 125, identifier:dir; 126, block; 126, 127; 127, delete_statement; 127, 128; 128, subscript; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:sys; 131, identifier:path; 132, integer:0; 133, delete_statement; 133, 134; 134, subscript; 134, 135; 134, 136; 135, identifier:values; 136, string:'__name__'; 137, if_statement; 137, 138; 137, 141; 138, comparison_operator:is; 138, 139; 138, 140; 139, identifier:args; 140, None; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:args; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:args; 148, for_statement; 148, 149; 148, 152; 148, 157; 149, pattern_list; 149, 150; 149, 151; 150, identifier:arg; 151, identifier:value; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:args; 155, identifier:items; 156, argument_list; 157, block; 157, 158; 157, 162; 157, 195; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:added; 161, False; 162, for_statement; 162, 163; 162, 164; 162, 167; 163, identifier:option; 164, attribute; 164, 165; 164, 166; 165, identifier:self; 166, identifier:options; 167, block; 167, 168; 168, if_statement; 168, 169; 168, 182; 169, comparison_operator:in; 169, 170; 169, 171; 170, identifier:arg; 171, binary_operator:+; 171, 172; 171, 178; 172, call; 172, 173; 172, 174; 173, identifier:list; 174, argument_list; 174, 175; 175, attribute; 175, 176; 175, 177; 176, identifier:option; 177, identifier:aliases; 178, list:[ option.key ]; 178, 179; 179, attribute; 179, 180; 179, 181; 180, identifier:option; 181, identifier:key; 182, block; 182, 183; 182, 191; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 190; 185, subscript; 185, 186; 185, 187; 186, identifier:values; 187, attribute; 187, 188; 187, 189; 188, identifier:option; 189, identifier:key; 190, identifier:value; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:added; 194, True; 195, if_statement; 195, 196; 195, 198; 196, not_operator; 196, 197; 197, identifier:added; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 206; 201, subscript; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:self; 204, identifier:unknown; 205, identifier:arg; 206, identifier:value; 207, for_statement; 207, 208; 207, 209; 207, 212; 208, identifier:option; 209, attribute; 209, 210; 209, 211; 210, identifier:self; 211, identifier:options; 212, block; 212, 213; 213, try_statement; 213, 214; 213, 227; 214, block; 214, 215; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 222; 217, subscript; 217, 218; 217, 219; 218, identifier:env; 219, attribute; 219, 220; 219, 221; 220, identifier:option; 221, identifier:key; 222, subscript; 222, 223; 222, 224; 223, identifier:values; 224, attribute; 224, 225; 224, 226; 225, identifier:option; 226, identifier:key; 227, except_clause; 227, 228; 227, 229; 228, identifier:KeyError; 229, block; 229, 230; 230, pass_statement; 231, for_statement; 231, 232; 231, 233; 231, 236; 232, identifier:option; 233, attribute; 233, 234; 233, 235; 234, identifier:self; 235, identifier:options; 236, block; 236, 237; 237, if_statement; 237, 238; 237, 247; 238, boolean_operator:and; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:option; 241, identifier:converter; 242, comparison_operator:in; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:option; 245, identifier:key; 246, identifier:values; 247, block; 247, 248; 247, 261; 248, expression_statement; 248, 249; 249, assignment; 249, 250; 249, 251; 250, identifier:value; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:env; 254, identifier:subst; 255, argument_list; 255, 256; 256, binary_operator:%; 256, 257; 256, 258; 257, string:'${%s}'; 258, attribute; 258, 259; 258, 260; 259, identifier:option; 260, identifier:key; 261, try_statement; 261, 262; 261, 295; 262, block; 262, 263; 263, try_statement; 263, 264; 263, 278; 264, block; 264, 265; 265, expression_statement; 265, 266; 266, assignment; 266, 267; 266, 272; 267, subscript; 267, 268; 267, 269; 268, identifier:env; 269, attribute; 269, 270; 269, 271; 270, identifier:option; 271, identifier:key; 272, call; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:option; 275, identifier:converter; 276, argument_list; 276, 277; 277, identifier:value; 278, except_clause; 278, 279; 278, 280; 279, identifier:TypeError; 280, block; 280, 281; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 288; 283, subscript; 283, 284; 283, 285; 284, identifier:env; 285, attribute; 285, 286; 285, 287; 286, identifier:option; 287, identifier:key; 288, call; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:option; 291, identifier:converter; 292, argument_list; 292, 293; 292, 294; 293, identifier:value; 294, identifier:env; 295, except_clause; 295, 296; 295, 300; 296, as_pattern; 296, 297; 296, 298; 297, identifier:ValueError; 298, as_pattern_target; 298, 299; 299, identifier:x; 300, block; 300, 301; 301, raise_statement; 301, 302; 302, call; 302, 303; 302, 308; 303, attribute; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, identifier:SCons; 306, identifier:Errors; 307, identifier:UserError; 308, argument_list; 308, 309; 309, binary_operator:%; 309, 310; 309, 311; 310, string:'Error converting option: %s\n%s'; 311, tuple; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:option; 314, identifier:key; 315, identifier:x; 316, for_statement; 316, 317; 316, 318; 316, 321; 317, identifier:option; 318, attribute; 318, 319; 318, 320; 319, identifier:self; 320, identifier:options; 321, block; 321, 322; 322, if_statement; 322, 323; 322, 332; 323, boolean_operator:and; 323, 324; 323, 327; 324, attribute; 324, 325; 324, 326; 325, identifier:option; 326, identifier:validator; 327, comparison_operator:in; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:option; 330, identifier:key; 331, identifier:values; 332, block; 332, 333; 333, expression_statement; 333, 334; 334, call; 334, 335; 334, 338; 335, attribute; 335, 336; 335, 337; 336, identifier:option; 337, identifier:validator; 338, argument_list; 338, 339; 338, 342; 338, 352; 339, attribute; 339, 340; 339, 341; 340, identifier:option; 341, identifier:key; 342, call; 342, 343; 342, 346; 343, attribute; 343, 344; 343, 345; 344, identifier:env; 345, identifier:subst; 346, argument_list; 346, 347; 347, binary_operator:%; 347, 348; 347, 349; 348, string:'${%s}'; 349, attribute; 349, 350; 349, 351; 350, identifier:option; 351, identifier:key; 352, identifier:env | def Update(self, env, args=None):
values = {}
for option in self.options:
if not option.default is None:
values[option.key] = option.default
for filename in self.files:
if os.path.exists(filename):
dir = os.path.split(os.path.abspath(filename))[0]
if dir:
sys.path.insert(0, dir)
try:
values['__name__'] = filename
with open(filename, 'r') as f:
contents = f.read()
exec(contents, {}, values)
finally:
if dir:
del sys.path[0]
del values['__name__']
if args is None:
args = self.args
for arg, value in args.items():
added = False
for option in self.options:
if arg in list(option.aliases) + [ option.key ]:
values[option.key] = value
added = True
if not added:
self.unknown[arg] = value
for option in self.options:
try:
env[option.key] = values[option.key]
except KeyError:
pass
for option in self.options:
if option.converter and option.key in values:
value = env.subst('${%s}'%option.key)
try:
try:
env[option.key] = option.converter(value)
except TypeError:
env[option.key] = option.converter(value, env)
except ValueError as x:
raise SCons.Errors.UserError('Error converting option: %s\n%s'%(option.key, x))
for option in self.options:
if option.validator and option.key in values:
option.validator(option.key, env.subst('${%s}'%option.key), env) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:GenerateHelpText; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:env; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, block; 9, 10; 9, 73; 9, 130; 9, 144; 10, if_statement; 10, 11; 10, 15; 10, 43; 10, 65; 11, call; 11, 12; 11, 13; 12, identifier:callable; 13, argument_list; 13, 14; 14, identifier:sort; 15, block; 15, 16; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:options; 19, call; 19, 20; 19, 21; 20, identifier:sorted; 21, argument_list; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:options; 25, keyword_argument; 25, 26; 25, 27; 26, identifier:key; 27, call; 27, 28; 27, 29; 28, identifier:cmp_to_key; 29, argument_list; 29, 30; 30, lambda; 30, 31; 30, 34; 31, lambda_parameters; 31, 32; 31, 33; 32, identifier:x; 33, identifier:y; 34, call; 34, 35; 34, 36; 35, identifier:sort; 36, argument_list; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:x; 39, identifier:key; 40, attribute; 40, 41; 40, 42; 41, identifier:y; 42, identifier:key; 43, elif_clause; 43, 44; 43, 47; 44, comparison_operator:is; 44, 45; 44, 46; 45, identifier:sort; 46, True; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:options; 51, call; 51, 52; 51, 53; 52, identifier:sorted; 53, argument_list; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:self; 56, identifier:options; 57, keyword_argument; 57, 58; 57, 59; 58, identifier:key; 59, lambda; 59, 60; 59, 62; 60, lambda_parameters; 60, 61; 61, identifier:x; 62, attribute; 62, 63; 62, 64; 63, identifier:x; 64, identifier:key; 65, else_clause; 65, 66; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:options; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:options; 73, function_definition; 73, 74; 73, 75; 73, 83; 74, function_name:format; 75, parameters; 75, 76; 75, 77; 75, 80; 76, identifier:opt; 77, default_parameter; 77, 78; 77, 79; 78, identifier:self; 79, identifier:self; 80, default_parameter; 80, 81; 80, 82; 81, identifier:env; 82, identifier:env; 83, block; 83, 84; 83, 110; 84, if_statement; 84, 85; 84, 90; 84, 104; 85, comparison_operator:in; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:opt; 88, identifier:key; 89, identifier:env; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:actual; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:env; 97, identifier:subst; 98, argument_list; 98, 99; 99, binary_operator:%; 99, 100; 99, 101; 100, string:'${%s}'; 101, attribute; 101, 102; 101, 103; 102, identifier:opt; 103, identifier:key; 104, else_clause; 104, 105; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:actual; 109, None; 110, return_statement; 110, 111; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:self; 114, identifier:FormatVariableHelpText; 115, argument_list; 115, 116; 115, 117; 115, 120; 115, 123; 115, 126; 115, 127; 116, identifier:env; 117, attribute; 117, 118; 117, 119; 118, identifier:opt; 119, identifier:key; 120, attribute; 120, 121; 120, 122; 121, identifier:opt; 122, identifier:help; 123, attribute; 123, 124; 123, 125; 124, identifier:opt; 125, identifier:default; 126, identifier:actual; 127, attribute; 127, 128; 127, 129; 128, identifier:opt; 129, identifier:aliases; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:lines; 133, list_comprehension; 133, 134; 133, 135; 133, 142; 134, identifier:_f; 135, for_in_clause; 135, 136; 135, 137; 136, identifier:_f; 137, call; 137, 138; 137, 139; 138, identifier:map; 139, argument_list; 139, 140; 139, 141; 140, identifier:format; 141, identifier:options; 142, if_clause; 142, 143; 143, identifier:_f; 144, return_statement; 144, 145; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, string:''; 148, identifier:join; 149, argument_list; 149, 150; 150, identifier:lines | def GenerateHelpText(self, env, sort=None):
if callable(sort):
options = sorted(self.options, key=cmp_to_key(lambda x,y: sort(x.key,y.key)))
elif sort is True:
options = sorted(self.options, key=lambda x: x.key)
else:
options = self.options
def format(opt, self=self, env=env):
if opt.key in env:
actual = env.subst('${%s}' % opt.key)
else:
actual = None
return self.FormatVariableHelpText(env, opt.key, opt.help, opt.default, actual, opt.aliases)
lines = [_f for _f in map(format, options) if _f]
return ''.join(lines) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:render_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 13; 4, identifier:root; 5, identifier:child_func; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prune; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:margin; 11, list:[0]; 11, 12; 12, integer:0; 13, default_parameter; 13, 14; 13, 15; 14, identifier:visited; 15, None; 16, block; 16, 17; 16, 24; 16, 33; 16, 40; 16, 44; 16, 70; 16, 83; 16, 93; 16, 106; 16, 112; 16, 157; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:rname; 20, call; 20, 21; 20, 22; 21, identifier:str; 22, argument_list; 22, 23; 23, identifier:root; 24, if_statement; 24, 25; 24, 28; 25, comparison_operator:is; 25, 26; 25, 27; 26, identifier:visited; 27, None; 28, block; 28, 29; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:visited; 32, dictionary; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:children; 36, call; 36, 37; 36, 38; 37, identifier:child_func; 38, argument_list; 38, 39; 39, identifier:root; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:retval; 43, string:""; 44, for_statement; 44, 45; 44, 46; 44, 52; 45, identifier:pipe; 46, subscript; 46, 47; 46, 48; 47, identifier:margin; 48, slice; 48, 49; 48, 50; 49, colon; 50, unary_operator:-; 50, 51; 51, integer:1; 52, block; 52, 53; 53, if_statement; 53, 54; 53, 55; 53, 62; 54, identifier:pipe; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:retval; 59, binary_operator:+; 59, 60; 59, 61; 60, identifier:retval; 61, string:"| "; 62, else_clause; 62, 63; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:retval; 67, binary_operator:+; 67, 68; 67, 69; 68, identifier:retval; 69, string:" "; 70, if_statement; 70, 71; 70, 74; 71, comparison_operator:in; 71, 72; 71, 73; 72, identifier:rname; 73, identifier:visited; 74, block; 74, 75; 75, return_statement; 75, 76; 76, binary_operator:+; 76, 77; 76, 82; 77, binary_operator:+; 77, 78; 77, 81; 78, binary_operator:+; 78, 79; 78, 80; 79, identifier:retval; 80, string:"+-["; 81, identifier:rname; 82, string:"]\n"; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:retval; 86, binary_operator:+; 86, 87; 86, 92; 87, binary_operator:+; 87, 88; 87, 91; 88, binary_operator:+; 88, 89; 88, 90; 89, identifier:retval; 90, string:"+-"; 91, identifier:rname; 92, string:"\n"; 93, if_statement; 93, 94; 93, 96; 94, not_operator; 94, 95; 95, identifier:prune; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:visited; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:copy; 103, identifier:copy; 104, argument_list; 104, 105; 105, identifier:visited; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 111; 108, subscript; 108, 109; 108, 110; 109, identifier:visited; 110, identifier:rname; 111, integer:1; 112, for_statement; 112, 113; 112, 114; 112, 121; 113, identifier:i; 114, call; 114, 115; 114, 116; 115, identifier:range; 116, argument_list; 116, 117; 117, call; 117, 118; 117, 119; 118, identifier:len; 119, argument_list; 119, 120; 120, identifier:children; 121, block; 121, 122; 121, 136; 121, 151; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:margin; 126, identifier:append; 127, argument_list; 127, 128; 128, comparison_operator:<; 128, 129; 128, 130; 129, identifier:i; 130, binary_operator:-; 130, 131; 130, 135; 131, call; 131, 132; 131, 133; 132, identifier:len; 133, argument_list; 133, 134; 134, identifier:children; 135, integer:1; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:retval; 139, binary_operator:+; 139, 140; 139, 141; 140, identifier:retval; 141, call; 141, 142; 141, 143; 142, identifier:render_tree; 143, argument_list; 143, 144; 143, 147; 143, 148; 143, 149; 143, 150; 144, subscript; 144, 145; 144, 146; 145, identifier:children; 146, identifier:i; 147, identifier:child_func; 148, identifier:prune; 149, identifier:margin; 150, identifier:visited; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:margin; 155, identifier:pop; 156, argument_list; 157, return_statement; 157, 158; 158, identifier:retval | def render_tree(root, child_func, prune=0, margin=[0], visited=None):
rname = str(root)
if visited is None:
visited = {}
children = child_func(root)
retval = ""
for pipe in margin[:-1]:
if pipe:
retval = retval + "| "
else:
retval = retval + " "
if rname in visited:
return retval + "+-[" + rname + "]\n"
retval = retval + "+-" + rname + "\n"
if not prune:
visited = copy.copy(visited)
visited[rname] = 1
for i in range(len(children)):
margin.append(i < len(children)-1)
retval = retval + render_tree(children[i], child_func, prune, margin, visited)
margin.pop()
return retval |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:print_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 16; 4, identifier:root; 5, identifier:child_func; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prune; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:showtags; 11, integer:0; 12, default_parameter; 12, 13; 12, 14; 13, identifier:margin; 14, list:[0]; 14, 15; 15, integer:0; 16, default_parameter; 16, 17; 16, 18; 17, identifier:visited; 18, None; 19, block; 19, 20; 19, 27; 19, 36; 19, 254; 19, 265; 19, 281; 19, 288; 19, 321; 19, 343; 19, 349; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:rname; 23, call; 23, 24; 23, 25; 24, identifier:str; 25, argument_list; 25, 26; 26, identifier:root; 27, if_statement; 27, 28; 27, 31; 28, comparison_operator:is; 28, 29; 28, 30; 29, identifier:visited; 30, None; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:visited; 35, dictionary; 36, if_statement; 36, 37; 36, 38; 36, 248; 37, identifier:showtags; 38, block; 38, 39; 38, 78; 38, 83; 38, 99; 38, 122; 38, 155; 38, 169; 38, 183; 38, 197; 38, 213; 38, 227; 38, 241; 39, if_statement; 39, 40; 39, 43; 40, comparison_operator:==; 40, 41; 40, 42; 41, identifier:showtags; 42, integer:2; 43, block; 43, 44; 43, 69; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:legend; 47, parenthesized_expression; 47, 48; 48, binary_operator:+; 48, 49; 48, 68; 49, binary_operator:+; 49, 50; 49, 67; 50, binary_operator:+; 50, 51; 50, 66; 51, binary_operator:+; 51, 52; 51, 65; 52, binary_operator:+; 52, 53; 52, 64; 53, binary_operator:+; 53, 54; 53, 63; 54, binary_operator:+; 54, 55; 54, 62; 55, binary_operator:+; 55, 56; 55, 61; 56, binary_operator:+; 56, 57; 56, 60; 57, binary_operator:+; 57, 58; 57, 59; 58, string:' E = exists\n'; 59, string:' R = exists in repository only\n'; 60, string:' b = implicit builder\n'; 61, string:' B = explicit builder\n'; 62, string:' S = side effect\n'; 63, string:' P = precious\n'; 64, string:' A = always build\n'; 65, string:' C = current\n'; 66, string:' N = no clean\n'; 67, string:' H = no cache\n'; 68, string:'\n'; 69, expression_statement; 69, 70; 70, call; 70, 71; 70, 76; 71, attribute; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:sys; 74, identifier:stdout; 75, identifier:write; 76, argument_list; 76, 77; 77, identifier:legend; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:tags; 81, list:['[']; 81, 82; 82, string:'['; 83, expression_statement; 83, 84; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:tags; 87, identifier:append; 88, argument_list; 88, 89; 89, subscript; 89, 90; 89, 91; 90, string:' E'; 91, call; 91, 92; 91, 93; 92, identifier:IDX; 93, argument_list; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:root; 97, identifier:exists; 98, argument_list; 99, expression_statement; 99, 100; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:tags; 103, identifier:append; 104, argument_list; 104, 105; 105, subscript; 105, 106; 105, 107; 106, string:' R'; 107, call; 107, 108; 107, 109; 108, identifier:IDX; 109, argument_list; 109, 110; 110, boolean_operator:and; 110, 111; 110, 116; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:root; 114, identifier:rexists; 115, argument_list; 116, not_operator; 116, 117; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:root; 120, identifier:exists; 121, argument_list; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:tags; 126, identifier:append; 127, argument_list; 127, 128; 128, subscript; 128, 129; 128, 130; 129, string:' BbB'; 130, binary_operator:+; 130, 131; 130, 143; 131, subscript; 131, 132; 131, 135; 132, list:[0,1]; 132, 133; 132, 134; 133, integer:0; 134, integer:1; 135, call; 135, 136; 135, 137; 136, identifier:IDX; 137, argument_list; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:root; 141, identifier:has_explicit_builder; 142, argument_list; 143, subscript; 143, 144; 143, 147; 144, list:[0,2]; 144, 145; 144, 146; 145, integer:0; 146, integer:2; 147, call; 147, 148; 147, 149; 148, identifier:IDX; 149, argument_list; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:root; 153, identifier:has_builder; 154, argument_list; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:tags; 159, identifier:append; 160, argument_list; 160, 161; 161, subscript; 161, 162; 161, 163; 162, string:' S'; 163, call; 163, 164; 163, 165; 164, identifier:IDX; 165, argument_list; 165, 166; 166, attribute; 166, 167; 166, 168; 167, identifier:root; 168, identifier:side_effect; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:tags; 173, identifier:append; 174, argument_list; 174, 175; 175, subscript; 175, 176; 175, 177; 176, string:' P'; 177, call; 177, 178; 177, 179; 178, identifier:IDX; 179, argument_list; 179, 180; 180, attribute; 180, 181; 180, 182; 181, identifier:root; 182, identifier:precious; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:tags; 187, identifier:append; 188, argument_list; 188, 189; 189, subscript; 189, 190; 189, 191; 190, string:' A'; 191, call; 191, 192; 191, 193; 192, identifier:IDX; 193, argument_list; 193, 194; 194, attribute; 194, 195; 194, 196; 195, identifier:root; 196, identifier:always_build; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:tags; 201, identifier:append; 202, argument_list; 202, 203; 203, subscript; 203, 204; 203, 205; 204, string:' C'; 205, call; 205, 206; 205, 207; 206, identifier:IDX; 207, argument_list; 207, 208; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:root; 211, identifier:is_up_to_date; 212, argument_list; 213, expression_statement; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:tags; 217, identifier:append; 218, argument_list; 218, 219; 219, subscript; 219, 220; 219, 221; 220, string:' N'; 221, call; 221, 222; 221, 223; 222, identifier:IDX; 223, argument_list; 223, 224; 224, attribute; 224, 225; 224, 226; 225, identifier:root; 226, identifier:noclean; 227, expression_statement; 227, 228; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:tags; 231, identifier:append; 232, argument_list; 232, 233; 233, subscript; 233, 234; 233, 235; 234, string:' H'; 235, call; 235, 236; 235, 237; 236, identifier:IDX; 237, argument_list; 237, 238; 238, attribute; 238, 239; 238, 240; 239, identifier:root; 240, identifier:nocache; 241, expression_statement; 241, 242; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:tags; 245, identifier:append; 246, argument_list; 246, 247; 247, string:']'; 248, else_clause; 248, 249; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:tags; 253, list:[]; 254, function_definition; 254, 255; 254, 256; 254, 258; 255, function_name:MMM; 256, parameters; 256, 257; 257, identifier:m; 258, block; 258, 259; 259, return_statement; 259, 260; 260, subscript; 260, 261; 260, 264; 261, list:[" ","| "]; 261, 262; 261, 263; 262, string:" "; 263, string:"| "; 264, identifier:m; 265, expression_statement; 265, 266; 266, assignment; 266, 267; 266, 268; 267, identifier:margins; 268, call; 268, 269; 268, 270; 269, identifier:list; 270, argument_list; 270, 271; 271, call; 271, 272; 271, 273; 272, identifier:map; 273, argument_list; 273, 274; 273, 275; 274, identifier:MMM; 275, subscript; 275, 276; 275, 277; 276, identifier:margin; 277, slice; 277, 278; 277, 279; 278, colon; 279, unary_operator:-; 279, 280; 280, integer:1; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 284; 283, identifier:children; 284, call; 284, 285; 284, 286; 285, identifier:child_func; 286, argument_list; 286, 287; 287, identifier:root; 288, if_statement; 288, 289; 288, 296; 289, boolean_operator:and; 289, 290; 289, 295; 290, boolean_operator:and; 290, 291; 290, 292; 291, identifier:prune; 292, comparison_operator:in; 292, 293; 292, 294; 293, identifier:rname; 294, identifier:visited; 295, identifier:children; 296, block; 296, 297; 296, 320; 297, expression_statement; 297, 298; 298, call; 298, 299; 298, 304; 299, attribute; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:sys; 302, identifier:stdout; 303, identifier:write; 304, argument_list; 304, 305; 305, binary_operator:+; 305, 306; 305, 319; 306, call; 306, 307; 306, 310; 307, attribute; 307, 308; 307, 309; 308, string:''; 309, identifier:join; 310, argument_list; 310, 311; 311, binary_operator:+; 311, 312; 311, 315; 312, binary_operator:+; 312, 313; 312, 314; 313, identifier:tags; 314, identifier:margins; 315, list:['+-[', rname, ']']; 315, 316; 315, 317; 315, 318; 316, string:'+-['; 317, identifier:rname; 318, string:']'; 319, string:'\n'; 320, return_statement; 321, expression_statement; 321, 322; 322, call; 322, 323; 322, 328; 323, attribute; 323, 324; 323, 327; 324, attribute; 324, 325; 324, 326; 325, identifier:sys; 326, identifier:stdout; 327, identifier:write; 328, argument_list; 328, 329; 329, binary_operator:+; 329, 330; 329, 342; 330, call; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, string:''; 333, identifier:join; 334, argument_list; 334, 335; 335, binary_operator:+; 335, 336; 335, 339; 336, binary_operator:+; 336, 337; 336, 338; 337, identifier:tags; 338, identifier:margins; 339, list:['+-', rname]; 339, 340; 339, 341; 340, string:'+-'; 341, identifier:rname; 342, string:'\n'; 343, expression_statement; 343, 344; 344, assignment; 344, 345; 344, 348; 345, subscript; 345, 346; 345, 347; 346, identifier:visited; 347, identifier:rname; 348, integer:1; 349, if_statement; 349, 350; 349, 351; 350, identifier:children; 351, block; 351, 352; 351, 359; 351, 366; 351, 385; 351, 392; 351, 405; 352, expression_statement; 352, 353; 353, call; 353, 354; 353, 357; 354, attribute; 354, 355; 354, 356; 355, identifier:margin; 356, identifier:append; 357, argument_list; 357, 358; 358, integer:1; 359, expression_statement; 359, 360; 360, assignment; 360, 361; 360, 362; 361, identifier:idx; 362, call; 362, 363; 362, 364; 363, identifier:IDX; 364, argument_list; 364, 365; 365, identifier:showtags; 366, for_statement; 366, 367; 366, 368; 366, 374; 367, identifier:C; 368, subscript; 368, 369; 368, 370; 369, identifier:children; 370, slice; 370, 371; 370, 372; 371, colon; 372, unary_operator:-; 372, 373; 373, integer:1; 374, block; 374, 375; 375, expression_statement; 375, 376; 376, call; 376, 377; 376, 378; 377, identifier:print_tree; 378, argument_list; 378, 379; 378, 380; 378, 381; 378, 382; 378, 383; 378, 384; 379, identifier:C; 380, identifier:child_func; 381, identifier:prune; 382, identifier:idx; 383, identifier:margin; 384, identifier:visited; 385, expression_statement; 385, 386; 386, assignment; 386, 387; 386, 391; 387, subscript; 387, 388; 387, 389; 388, identifier:margin; 389, unary_operator:-; 389, 390; 390, integer:1; 391, integer:0; 392, expression_statement; 392, 393; 393, call; 393, 394; 393, 395; 394, identifier:print_tree; 395, argument_list; 395, 396; 395, 400; 395, 401; 395, 402; 395, 403; 395, 404; 396, subscript; 396, 397; 396, 398; 397, identifier:children; 398, unary_operator:-; 398, 399; 399, integer:1; 400, identifier:child_func; 401, identifier:prune; 402, identifier:idx; 403, identifier:margin; 404, identifier:visited; 405, expression_statement; 405, 406; 406, call; 406, 407; 406, 410; 407, attribute; 407, 408; 407, 409; 408, identifier:margin; 409, identifier:pop; 410, argument_list | def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None):
rname = str(root)
if visited is None:
visited = {}
if showtags:
if showtags == 2:
legend = (' E = exists\n' +
' R = exists in repository only\n' +
' b = implicit builder\n' +
' B = explicit builder\n' +
' S = side effect\n' +
' P = precious\n' +
' A = always build\n' +
' C = current\n' +
' N = no clean\n' +
' H = no cache\n' +
'\n')
sys.stdout.write(legend)
tags = ['[']
tags.append(' E'[IDX(root.exists())])
tags.append(' R'[IDX(root.rexists() and not root.exists())])
tags.append(' BbB'[[0,1][IDX(root.has_explicit_builder())] +
[0,2][IDX(root.has_builder())]])
tags.append(' S'[IDX(root.side_effect)])
tags.append(' P'[IDX(root.precious)])
tags.append(' A'[IDX(root.always_build)])
tags.append(' C'[IDX(root.is_up_to_date())])
tags.append(' N'[IDX(root.noclean)])
tags.append(' H'[IDX(root.nocache)])
tags.append(']')
else:
tags = []
def MMM(m):
return [" ","| "][m]
margins = list(map(MMM, margin[:-1]))
children = child_func(root)
if prune and rname in visited and children:
sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + '\n')
return
sys.stdout.write(''.join(tags + margins + ['+-', rname]) + '\n')
visited[rname] = 1
if children:
margin.append(1)
idx = IDX(showtags)
for C in children[:-1]:
print_tree(C, child_func, prune, idx, margin, visited)
margin[-1] = 0
print_tree(children[-1], child_func, prune, idx, margin, visited)
margin.pop() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:unique; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 5, 13; 5, 20; 5, 24; 5, 51; 5, 53; 5, 124; 5, 126; 5, 130; 5, 146; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:n; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_list; 11, 12; 12, identifier:s; 13, if_statement; 13, 14; 13, 17; 14, comparison_operator:==; 14, 15; 14, 16; 15, identifier:n; 16, integer:0; 17, block; 17, 18; 18, return_statement; 18, 19; 19, list:[]; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:u; 23, dictionary; 24, try_statement; 24, 25; 24, 36; 24, 40; 25, block; 25, 26; 26, for_statement; 26, 27; 26, 28; 26, 29; 27, identifier:x; 28, identifier:s; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 35; 32, subscript; 32, 33; 32, 34; 33, identifier:u; 34, identifier:x; 35, integer:1; 36, except_clause; 36, 37; 36, 38; 37, identifier:TypeError; 38, block; 38, 39; 39, pass_statement; 40, else_clause; 40, 41; 41, block; 41, 42; 42, return_statement; 42, 43; 43, call; 43, 44; 43, 45; 44, identifier:list; 45, argument_list; 45, 46; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:u; 49, identifier:keys; 50, argument_list; 51, delete_statement; 51, 52; 52, identifier:u; 53, try_statement; 53, 54; 53, 62; 53, 66; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:t; 58, call; 58, 59; 58, 60; 59, identifier:sorted; 60, argument_list; 60, 61; 61, identifier:s; 62, except_clause; 62, 63; 62, 64; 63, identifier:TypeError; 64, block; 64, 65; 65, pass_statement; 66, else_clause; 66, 67; 67, block; 67, 68; 67, 72; 67, 78; 67, 84; 67, 118; 68, assert_statement; 68, 69; 69, comparison_operator:>; 69, 70; 69, 71; 70, identifier:n; 71, integer:0; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:last; 75, subscript; 75, 76; 75, 77; 76, identifier:t; 77, integer:0; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:lasti; 81, assignment; 81, 82; 81, 83; 82, identifier:i; 83, integer:1; 84, while_statement; 84, 85; 84, 88; 85, comparison_operator:<; 85, 86; 85, 87; 86, identifier:i; 87, identifier:n; 88, block; 88, 89; 88, 112; 89, if_statement; 89, 90; 89, 95; 90, comparison_operator:!=; 90, 91; 90, 94; 91, subscript; 91, 92; 91, 93; 92, identifier:t; 93, identifier:i; 94, identifier:last; 95, block; 95, 96; 95, 106; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, subscript; 98, 99; 98, 100; 99, identifier:t; 100, identifier:lasti; 101, assignment; 101, 102; 101, 103; 102, identifier:last; 103, subscript; 103, 104; 103, 105; 104, identifier:t; 105, identifier:i; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:lasti; 109, binary_operator:+; 109, 110; 109, 111; 110, identifier:lasti; 111, integer:1; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:i; 115, binary_operator:+; 115, 116; 115, 117; 116, identifier:i; 117, integer:1; 118, return_statement; 118, 119; 119, subscript; 119, 120; 119, 121; 120, identifier:t; 121, slice; 121, 122; 121, 123; 122, colon; 123, identifier:lasti; 124, delete_statement; 124, 125; 125, identifier:t; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:u; 129, list:[]; 130, for_statement; 130, 131; 130, 132; 130, 133; 131, identifier:x; 132, identifier:s; 133, block; 133, 134; 134, if_statement; 134, 135; 134, 138; 135, comparison_operator:not; 135, 136; 135, 137; 136, identifier:x; 137, identifier:u; 138, block; 138, 139; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:u; 143, identifier:append; 144, argument_list; 144, 145; 145, identifier:x; 146, return_statement; 146, 147; 147, identifier:u | def unique(s):
n = len(s)
if n == 0:
return []
u = {}
try:
for x in s:
u[x] = 1
except TypeError:
pass
else:
return list(u.keys())
del u
try:
t = sorted(s)
except TypeError:
pass
else:
assert n > 0
last = t[0]
lasti = i = 1
while i < n:
if t[i] != last:
t[lasti] = last = t[i]
lasti = lasti + 1
i = i + 1
return t[:lasti]
del t
u = []
for x in s:
if x not in u:
u.append(x)
return u |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:setup_client; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:client_id; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:user_data; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:scan; 13, True; 14, default_parameter; 14, 15; 14, 16; 15, identifier:broadcast; 16, False; 17, block; 17, 18; 17, 34; 17, 51; 17, 75; 17, 88; 17, 107; 17, 116; 18, if_statement; 18, 19; 18, 22; 19, comparison_operator:is; 19, 20; 19, 21; 20, identifier:client_id; 21, None; 22, block; 22, 23; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:client_id; 26, call; 26, 27; 26, 28; 27, identifier:str; 28, argument_list; 28, 29; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:uuid; 32, identifier:uuid4; 33, argument_list; 34, if_statement; 34, 35; 34, 40; 35, comparison_operator:in; 35, 36; 35, 37; 36, identifier:client_id; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:_clients; 40, block; 40, 41; 41, raise_statement; 41, 42; 42, call; 42, 43; 42, 44; 43, identifier:ArgumentError; 44, argument_list; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, string:"Duplicate client_id: {}"; 48, identifier:format; 49, argument_list; 49, 50; 50, identifier:client_id; 51, function_definition; 51, 52; 51, 53; 51, 58; 52, function_name:_client_callback; 53, parameters; 53, 54; 53, 55; 53, 56; 53, 57; 54, identifier:conn_string; 55, identifier:_; 56, identifier:event_name; 57, identifier:event; 58, block; 58, 59; 58, 66; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:event_tuple; 62, tuple; 62, 63; 62, 64; 62, 65; 63, identifier:conn_string; 64, identifier:event_name; 65, identifier:event; 66, expression_statement; 66, 67; 67, await; 67, 68; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:_forward_client_event; 72, argument_list; 72, 73; 72, 74; 73, identifier:client_id; 74, identifier:event_tuple; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:client_monitor; 78, call; 78, 79; 78, 84; 79, attribute; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:adapter; 83, identifier:register_monitor; 84, argument_list; 84, 85; 84, 86; 84, 87; 85, list:[]; 86, list:[]; 87, identifier:_client_callback; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 95; 90, subscript; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:_clients; 94, identifier:client_id; 95, call; 95, 96; 95, 97; 96, identifier:dict; 97, argument_list; 97, 98; 97, 101; 97, 104; 98, keyword_argument; 98, 99; 98, 100; 99, identifier:user_data; 100, identifier:user_data; 101, keyword_argument; 101, 102; 101, 103; 102, identifier:connections; 103, dictionary; 104, keyword_argument; 104, 105; 104, 106; 105, identifier:monitor; 106, identifier:client_monitor; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:_adjust_global_events; 112, argument_list; 112, 113; 112, 114; 112, 115; 113, identifier:client_id; 114, identifier:scan; 115, identifier:broadcast; 116, return_statement; 116, 117; 117, identifier:client_id | def setup_client(self, client_id=None, user_data=None, scan=True, broadcast=False):
if client_id is None:
client_id = str(uuid.uuid4())
if client_id in self._clients:
raise ArgumentError("Duplicate client_id: {}".format(client_id))
async def _client_callback(conn_string, _, event_name, event):
event_tuple = (conn_string, event_name, event)
await self._forward_client_event(client_id, event_tuple)
client_monitor = self.adapter.register_monitor([], [], _client_callback)
self._clients[client_id] = dict(user_data=user_data, connections={},
monitor=client_monitor)
self._adjust_global_events(client_id, scan, broadcast)
return client_id |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_parse_conn_string; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:conn_string; 6, block; 6, 7; 6, 11; 6, 47; 6, 61; 6, 74; 6, 83; 6, 241; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:disconnection_required; 10, False; 11, if_statement; 11, 12; 11, 19; 12, boolean_operator:or; 12, 13; 12, 16; 13, comparison_operator:is; 13, 14; 13, 15; 14, identifier:conn_string; 15, None; 16, comparison_operator:not; 16, 17; 16, 18; 17, string:'device'; 18, identifier:conn_string; 19, block; 19, 20; 20, if_statement; 20, 21; 20, 34; 21, boolean_operator:and; 21, 22; 21, 27; 22, comparison_operator:is; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:_default_device_info; 26, None; 27, comparison_operator:!=; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:_device_info; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:_default_device_info; 34, block; 34, 35; 34, 39; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:disconnection_required; 38, True; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:_device_info; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:_default_device_info; 47, if_statement; 47, 48; 47, 58; 48, boolean_operator:or; 48, 49; 48, 52; 49, comparison_operator:is; 49, 50; 49, 51; 50, identifier:conn_string; 51, None; 52, comparison_operator:==; 52, 53; 52, 57; 53, call; 53, 54; 53, 55; 54, identifier:len; 55, argument_list; 55, 56; 56, identifier:conn_string; 57, integer:0; 58, block; 58, 59; 59, return_statement; 59, 60; 60, identifier:disconnection_required; 61, if_statement; 61, 62; 61, 65; 62, comparison_operator:in; 62, 63; 62, 64; 63, string:'@'; 64, identifier:conn_string; 65, block; 65, 66; 66, raise_statement; 66, 67; 67, call; 67, 68; 67, 69; 68, identifier:ArgumentError; 69, argument_list; 69, 70; 69, 71; 70, string:"Configuration files are not yet supported as part of a connection string argument"; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:conn_string; 73, identifier:conn_string; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:pairs; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:conn_string; 80, identifier:split; 81, argument_list; 81, 82; 82, string:';'; 83, for_statement; 83, 84; 83, 85; 83, 86; 84, identifier:pair; 85, identifier:pairs; 86, block; 86, 87; 86, 99; 86, 115; 86, 123; 86, 131; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 93; 89, pattern_list; 89, 90; 89, 91; 89, 92; 90, identifier:name; 91, identifier:_; 92, identifier:value; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:pair; 96, identifier:partition; 97, argument_list; 97, 98; 98, string:'='; 99, if_statement; 99, 100; 99, 113; 100, boolean_operator:or; 100, 101; 100, 107; 101, comparison_operator:==; 101, 102; 101, 106; 102, call; 102, 103; 102, 104; 103, identifier:len; 104, argument_list; 104, 105; 105, identifier:name; 106, integer:0; 107, comparison_operator:==; 107, 108; 107, 112; 108, call; 108, 109; 108, 110; 109, identifier:len; 110, argument_list; 110, 111; 111, identifier:value; 112, integer:0; 113, block; 113, 114; 114, continue_statement; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:name; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:name; 121, identifier:strip; 122, argument_list; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:value; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:value; 129, identifier:strip; 130, argument_list; 131, if_statement; 131, 132; 131, 135; 131, 199; 132, comparison_operator:==; 132, 133; 132, 134; 133, identifier:name; 134, string:'device'; 135, block; 135, 136; 135, 147; 136, if_statement; 136, 137; 136, 140; 137, comparison_operator:in; 137, 138; 137, 139; 138, identifier:value; 139, identifier:DEVICE_ALIASES; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:device_name; 144, subscript; 144, 145; 144, 146; 145, identifier:DEVICE_ALIASES; 146, identifier:value; 147, if_statement; 147, 148; 147, 151; 147, 178; 148, comparison_operator:in; 148, 149; 148, 150; 149, identifier:device_name; 150, identifier:KNOWN_DEVICES; 151, block; 151, 152; 151, 161; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:device_info; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:KNOWN_DEVICES; 158, identifier:get; 159, argument_list; 159, 160; 160, identifier:device_name; 161, if_statement; 161, 162; 161, 167; 162, comparison_operator:!=; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:self; 165, identifier:_device_info; 166, identifier:device_info; 167, block; 167, 168; 167, 174; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:self; 172, identifier:_device_info; 173, identifier:device_info; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:disconnection_required; 177, True; 178, else_clause; 178, 179; 179, block; 179, 180; 180, raise_statement; 180, 181; 181, call; 181, 182; 181, 183; 182, identifier:ArgumentError; 183, argument_list; 183, 184; 183, 185; 183, 188; 184, string:"Unknown device name or alias, please select from known_devices"; 185, keyword_argument; 185, 186; 185, 187; 186, identifier:device_name; 187, identifier:value; 188, keyword_argument; 188, 189; 188, 190; 189, identifier:known_devices; 190, list_comprehension; 190, 191; 190, 192; 191, identifier:x; 192, for_in_clause; 192, 193; 192, 194; 193, identifier:x; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:DEVICE_ALIASES; 197, identifier:keys; 198, argument_list; 199, elif_clause; 199, 200; 199, 203; 200, comparison_operator:==; 200, 201; 200, 202; 201, identifier:name; 202, string:'channel'; 203, block; 203, 204; 204, if_statement; 204, 205; 204, 210; 204, 234; 205, comparison_operator:is; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:self; 208, identifier:_mux_func; 209, None; 210, block; 210, 211; 211, if_statement; 211, 212; 211, 220; 212, comparison_operator:!=; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:self; 215, identifier:_channel; 216, call; 216, 217; 216, 218; 217, identifier:int; 218, argument_list; 218, 219; 219, identifier:value; 220, block; 220, 221; 220, 230; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:self; 225, identifier:_channel; 226, call; 226, 227; 226, 228; 227, identifier:int; 228, argument_list; 228, 229; 229, identifier:value; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:disconnection_required; 233, True; 234, else_clause; 234, 235; 235, block; 235, 236; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 239; 238, identifier:print; 239, argument_list; 239, 240; 240, string:"Warning: multiplexing architecture not selected, channel will not be set"; 241, return_statement; 241, 242; 242, identifier:disconnection_required | def _parse_conn_string(self, conn_string):
disconnection_required = False
if conn_string is None or 'device' not in conn_string:
if self._default_device_info is not None and self._device_info != self._default_device_info:
disconnection_required = True
self._device_info = self._default_device_info
if conn_string is None or len(conn_string) == 0:
return disconnection_required
if '@' in conn_string:
raise ArgumentError("Configuration files are not yet supported as part of a connection string argument",
conn_string=conn_string)
pairs = conn_string.split(';')
for pair in pairs:
name, _, value = pair.partition('=')
if len(name) == 0 or len(value) == 0:
continue
name = name.strip()
value = value.strip()
if name == 'device':
if value in DEVICE_ALIASES:
device_name = DEVICE_ALIASES[value]
if device_name in KNOWN_DEVICES:
device_info = KNOWN_DEVICES.get(device_name)
if self._device_info != device_info:
self._device_info = device_info
disconnection_required = True
else:
raise ArgumentError("Unknown device name or alias, please select from known_devices",
device_name=value, known_devices=[x for x in DEVICE_ALIASES.keys()])
elif name == 'channel':
if self._mux_func is not None:
if self._channel != int(value):
self._channel = int(value)
disconnection_required = True
else:
print("Warning: multiplexing architecture not selected, channel will not be set")
return disconnection_required |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:main; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:argv; 6, None; 7, block; 7, 8; 7, 23; 7, 29; 7, 40; 7, 62; 7, 68; 7, 97; 7, 106; 7, 133; 7, 145; 7, 157; 7, 161; 7, 169; 7, 276; 7, 284; 7, 290; 7, 307; 7, 317; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:argv; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:argv; 16, subscript; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:sys; 19, identifier:argv; 20, slice; 20, 21; 20, 22; 21, integer:1; 22, colon; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:parser; 26, call; 26, 27; 26, 28; 27, identifier:build_args; 28, argument_list; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:args; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:parser; 35, identifier:parse_args; 36, argument_list; 36, 37; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:args; 39, identifier:argv; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 45; 42, pattern_list; 42, 43; 42, 44; 43, identifier:recipe_name; 44, identifier:_ext; 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:splitext; 51, argument_list; 51, 52; 52, call; 52, 53; 52, 58; 53, attribute; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:os; 56, identifier:path; 57, identifier:basename; 58, argument_list; 58, 59; 59, attribute; 59, 60; 59, 61; 60, identifier:args; 61, identifier:recipe; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:rm; 65, call; 65, 66; 65, 67; 66, identifier:RecipeManager; 67, argument_list; 68, expression_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:rm; 72, identifier:add_recipe_folder; 73, argument_list; 73, 74; 73, 84; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:os; 78, identifier:path; 79, identifier:dirname; 80, argument_list; 80, 81; 81, attribute; 81, 82; 81, 83; 82, identifier:args; 83, identifier:recipe; 84, keyword_argument; 84, 85; 84, 86; 85, identifier:whitelist; 86, list:[os.path.basename(args.recipe)]; 86, 87; 87, call; 87, 88; 87, 93; 88, attribute; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:os; 91, identifier:path; 92, identifier:basename; 93, argument_list; 93, 94; 94, attribute; 94, 95; 94, 96; 95, identifier:args; 96, identifier:recipe; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:recipe; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:rm; 103, identifier:get_recipe; 104, argument_list; 104, 105; 105, identifier:recipe_name; 106, if_statement; 106, 107; 106, 112; 107, comparison_operator:is; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:args; 110, identifier:archive; 111, None; 112, block; 112, 113; 112, 122; 112, 131; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 116; 115, identifier:print; 116, argument_list; 116, 117; 117, binary_operator:%; 117, 118; 117, 119; 118, string:"Archiving recipe into %s"; 119, attribute; 119, 120; 119, 121; 120, identifier:args; 121, identifier:archive; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:recipe; 126, identifier:archive; 127, argument_list; 127, 128; 128, attribute; 128, 129; 128, 130; 129, identifier:args; 130, identifier:archive; 131, return_statement; 131, 132; 132, integer:0; 133, if_statement; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:args; 136, identifier:info; 137, block; 137, 138; 137, 143; 138, expression_statement; 138, 139; 139, call; 139, 140; 139, 141; 140, identifier:print; 141, argument_list; 141, 142; 142, identifier:recipe; 143, return_statement; 143, 144; 144, integer:0; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:variables; 148, call; 148, 149; 148, 150; 149, identifier:load_variables; 150, argument_list; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:args; 153, identifier:define; 154, attribute; 154, 155; 154, 156; 155, identifier:args; 156, identifier:config; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:success; 160, integer:0; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:start_time; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:time; 167, identifier:time; 168, argument_list; 169, if_statement; 169, 170; 169, 175; 169, 207; 170, comparison_operator:is; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:args; 173, identifier:loop; 174, None; 175, block; 175, 176; 176, try_statement; 176, 177; 176, 189; 177, block; 177, 178; 177, 185; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:recipe; 182, identifier:run; 183, argument_list; 183, 184; 184, identifier:variables; 185, expression_statement; 185, 186; 186, augmented_assignment:+=; 186, 187; 186, 188; 187, identifier:success; 188, integer:1; 189, except_clause; 189, 190; 189, 194; 190, as_pattern; 190, 191; 190, 192; 191, identifier:IOTileException; 192, as_pattern_target; 192, 193; 193, identifier:exc; 194, block; 194, 195; 194, 205; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 198; 197, identifier:print; 198, argument_list; 198, 199; 199, binary_operator:%; 199, 200; 199, 201; 200, string:"Error running recipe: %s"; 201, call; 201, 202; 201, 203; 202, identifier:str; 203, argument_list; 203, 204; 204, identifier:exc; 205, return_statement; 205, 206; 206, integer:1; 207, else_clause; 207, 208; 208, block; 208, 209; 209, while_statement; 209, 210; 209, 211; 210, True; 211, block; 211, 212; 211, 223; 211, 229; 211, 237; 211, 245; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:value; 215, call; 215, 216; 215, 217; 216, identifier:input; 217, argument_list; 217, 218; 218, binary_operator:%; 218, 219; 218, 220; 219, string:"Enter value for loop variable %s (return to stop): "; 220, attribute; 220, 221; 220, 222; 221, identifier:args; 222, identifier:loop; 223, if_statement; 223, 224; 223, 227; 224, comparison_operator:==; 224, 225; 224, 226; 225, identifier:value; 226, string:''; 227, block; 227, 228; 228, break_statement; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 232; 231, identifier:local_vars; 232, call; 232, 233; 232, 234; 233, identifier:dict; 234, argument_list; 234, 235; 235, dictionary_splat; 235, 236; 236, identifier:variables; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 244; 239, subscript; 239, 240; 239, 241; 240, identifier:local_vars; 241, attribute; 241, 242; 241, 243; 242, identifier:args; 243, identifier:loop; 244, identifier:value; 245, try_statement; 245, 246; 245, 258; 246, block; 246, 247; 246, 254; 247, expression_statement; 247, 248; 248, call; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:recipe; 251, identifier:run; 252, argument_list; 252, 253; 253, identifier:local_vars; 254, expression_statement; 254, 255; 255, augmented_assignment:+=; 255, 256; 255, 257; 256, identifier:success; 257, integer:1; 258, except_clause; 258, 259; 258, 263; 259, as_pattern; 259, 260; 259, 261; 260, identifier:IOTileException; 261, as_pattern_target; 261, 262; 262, identifier:exc; 263, block; 263, 264; 264, expression_statement; 264, 265; 265, call; 265, 266; 265, 267; 266, identifier:print; 267, argument_list; 267, 268; 268, binary_operator:%; 268, 269; 268, 270; 269, string:"--> ERROR processing loop variable %s: %s"; 270, tuple; 270, 271; 270, 272; 271, identifier:value; 272, call; 272, 273; 272, 274; 273, identifier:str; 274, argument_list; 274, 275; 275, identifier:exc; 276, expression_statement; 276, 277; 277, assignment; 277, 278; 277, 279; 278, identifier:end_time; 279, call; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:time; 282, identifier:time; 283, argument_list; 284, expression_statement; 284, 285; 285, assignment; 285, 286; 285, 287; 286, identifier:total_time; 287, binary_operator:-; 287, 288; 287, 289; 288, identifier:end_time; 289, identifier:start_time; 290, if_statement; 290, 291; 290, 294; 290, 299; 291, comparison_operator:==; 291, 292; 291, 293; 292, identifier:success; 293, integer:0; 294, block; 294, 295; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:per_time; 298, float:0.0; 299, else_clause; 299, 300; 300, block; 300, 301; 301, expression_statement; 301, 302; 302, assignment; 302, 303; 302, 304; 303, identifier:per_time; 304, binary_operator:/; 304, 305; 304, 306; 305, identifier:total_time; 306, identifier:success; 307, expression_statement; 307, 308; 308, call; 308, 309; 308, 310; 309, identifier:print; 310, argument_list; 310, 311; 311, binary_operator:%; 311, 312; 311, 313; 312, string:"Performed %d runs in %.1f seconds (%.1f seconds / run)"; 313, tuple; 313, 314; 313, 315; 313, 316; 314, identifier:success; 315, identifier:total_time; 316, identifier:per_time; 317, return_statement; 317, 318; 318, integer:0 | def main(argv=None):
if argv is None:
argv = sys.argv[1:]
parser = build_args()
args = parser.parse_args(args=argv)
recipe_name, _ext = os.path.splitext(os.path.basename(args.recipe))
rm = RecipeManager()
rm.add_recipe_folder(os.path.dirname(args.recipe), whitelist=[os.path.basename(args.recipe)])
recipe = rm.get_recipe(recipe_name)
if args.archive is not None:
print("Archiving recipe into %s" % args.archive)
recipe.archive(args.archive)
return 0
if args.info:
print(recipe)
return 0
variables = load_variables(args.define, args.config)
success = 0
start_time = time.time()
if args.loop is None:
try:
recipe.run(variables)
success += 1
except IOTileException as exc:
print("Error running recipe: %s" % str(exc))
return 1
else:
while True:
value = input("Enter value for loop variable %s (return to stop): " % args.loop)
if value == '':
break
local_vars = dict(**variables)
local_vars[args.loop] = value
try:
recipe.run(local_vars)
success += 1
except IOTileException as exc:
print("--> ERROR processing loop variable %s: %s" % (value, str(exc)))
end_time = time.time()
total_time = end_time - start_time
if success == 0:
per_time = 0.0
else:
per_time = total_time / success
print("Performed %d runs in %.1f seconds (%.1f seconds / run)" % (success, total_time, per_time))
return 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:assign_utc; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:reading_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:uptime; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:prefer; 11, string:"before"; 12, block; 12, 13; 12, 30; 12, 42; 12, 56; 12, 67; 12, 71; 12, 75; 12, 79; 12, 91; 12, 102; 12, 131; 12, 143; 12, 154; 12, 166; 12, 177; 13, if_statement; 13, 14; 13, 19; 14, comparison_operator:not; 14, 15; 14, 16; 15, identifier:prefer; 16, tuple; 16, 17; 16, 18; 17, string:"before"; 18, string:"after"; 19, block; 19, 20; 20, raise_statement; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:ArgumentError; 23, argument_list; 23, 24; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, string:"Invalid prefer parameter: {}, must be 'before' or 'after'"; 27, identifier:format; 28, argument_list; 28, 29; 29, identifier:prefer; 30, if_statement; 30, 31; 30, 39; 31, comparison_operator:==; 31, 32; 31, 38; 32, call; 32, 33; 32, 34; 33, identifier:len; 34, argument_list; 34, 35; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:_anchor_points; 38, integer:0; 39, block; 39, 40; 40, return_statement; 40, 41; 41, None; 42, if_statement; 42, 43; 42, 53; 43, comparison_operator:>; 43, 44; 43, 45; 44, identifier:reading_id; 45, attribute; 45, 46; 45, 52; 46, subscript; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:_anchor_points; 50, unary_operator:-; 50, 51; 51, integer:1; 52, identifier:reading_id; 53, block; 53, 54; 54, return_statement; 54, 55; 55, None; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:i; 59, call; 59, 60; 59, 65; 60, attribute; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:_anchor_points; 64, identifier:bisect_key_left; 65, argument_list; 65, 66; 66, identifier:reading_id; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:found_id; 70, False; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:crossed_break; 74, False; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:exact; 78, True; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:last; 82, call; 82, 83; 82, 90; 83, attribute; 83, 84; 83, 89; 84, subscript; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:_anchor_points; 88, identifier:i; 89, identifier:copy; 90, argument_list; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:is; 92, 93; 92, 94; 93, identifier:uptime; 94, None; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:last; 100, identifier:uptime; 101, identifier:uptime; 102, if_statement; 102, 103; 102, 108; 103, comparison_operator:==; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:last; 106, identifier:reading_id; 107, identifier:reading_id; 108, block; 108, 109; 108, 113; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:found_id; 112, True; 113, if_statement; 113, 114; 113, 119; 114, comparison_operator:is; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:last; 117, identifier:utc; 118, None; 119, block; 119, 120; 120, return_statement; 120, 121; 121, call; 121, 122; 121, 123; 122, identifier:UTCAssignment; 123, argument_list; 123, 124; 123, 125; 123, 128; 123, 129; 123, 130; 124, identifier:reading_id; 125, attribute; 125, 126; 125, 127; 126, identifier:last; 127, identifier:utc; 128, identifier:found_id; 129, identifier:exact; 130, identifier:crossed_break; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:left_assign; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:self; 137, identifier:_fix_left; 138, argument_list; 138, 139; 138, 140; 138, 141; 138, 142; 139, identifier:reading_id; 140, identifier:last; 141, identifier:i; 142, identifier:found_id; 143, if_statement; 143, 144; 143, 151; 144, boolean_operator:and; 144, 145; 144, 148; 145, comparison_operator:is; 145, 146; 145, 147; 146, identifier:left_assign; 147, None; 148, attribute; 148, 149; 148, 150; 149, identifier:left_assign; 150, identifier:exact; 151, block; 151, 152; 152, return_statement; 152, 153; 153, identifier:left_assign; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:right_assign; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:_fix_right; 161, argument_list; 161, 162; 161, 163; 161, 164; 161, 165; 162, identifier:reading_id; 163, identifier:last; 164, identifier:i; 165, identifier:found_id; 166, if_statement; 166, 167; 166, 174; 167, boolean_operator:and; 167, 168; 167, 171; 168, comparison_operator:is; 168, 169; 168, 170; 169, identifier:right_assign; 170, None; 171, attribute; 171, 172; 171, 173; 172, identifier:right_assign; 173, identifier:exact; 174, block; 174, 175; 175, return_statement; 175, 176; 176, identifier:right_assign; 177, return_statement; 177, 178; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:self; 181, identifier:_pick_best_fix; 182, argument_list; 182, 183; 182, 184; 182, 185; 183, identifier:left_assign; 184, identifier:right_assign; 185, identifier:prefer | def assign_utc(self, reading_id, uptime=None, prefer="before"):
if prefer not in ("before", "after"):
raise ArgumentError("Invalid prefer parameter: {}, must be 'before' or 'after'".format(prefer))
if len(self._anchor_points) == 0:
return None
if reading_id > self._anchor_points[-1].reading_id:
return None
i = self._anchor_points.bisect_key_left(reading_id)
found_id = False
crossed_break = False
exact = True
last = self._anchor_points[i].copy()
if uptime is not None:
last.uptime = uptime
if last.reading_id == reading_id:
found_id = True
if last.utc is not None:
return UTCAssignment(reading_id, last.utc, found_id, exact, crossed_break)
left_assign = self._fix_left(reading_id, last, i, found_id)
if left_assign is not None and left_assign.exact:
return left_assign
right_assign = self._fix_right(reading_id, last, i, found_id)
if right_assign is not None and right_assign.exact:
return right_assign
return self._pick_best_fix(left_assign, right_assign, prefer) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_text_contents; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, try_statement; 6, 7; 6, 19; 6, 28; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:self; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:disambiguate; 15, argument_list; 15, 16; 16, keyword_argument; 16, 17; 16, 18; 17, identifier:must_exist; 18, integer:1; 19, except_clause; 19, 20; 19, 25; 20, attribute; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:SCons; 23, identifier:Errors; 24, identifier:UserError; 25, block; 25, 26; 26, return_statement; 26, 27; 27, string:''; 28, else_clause; 28, 29; 29, block; 29, 30; 30, return_statement; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:get_text_contents; 35, argument_list | def get_text_contents(self):
try:
self = self.disambiguate(must_exist=1)
except SCons.Errors.UserError:
return ''
else:
return self.get_text_contents() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_lookup; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:p; 6, identifier:directory; 7, identifier:fsclass; 8, default_parameter; 8, 9; 8, 10; 9, identifier:create; 10, integer:1; 11, block; 11, 12; 11, 28; 11, 35; 11, 49; 11, 108; 11, 117; 11, 124; 11, 153; 11, 170; 11, 186; 11, 200; 11, 207; 11, 305; 11, 373; 12, if_statement; 12, 13; 12, 18; 13, call; 13, 14; 13, 15; 14, identifier:isinstance; 15, argument_list; 15, 16; 15, 17; 16, identifier:p; 17, identifier:Base; 18, block; 18, 19; 18, 26; 19, expression_statement; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:p; 23, identifier:must_be_same; 24, argument_list; 24, 25; 25, identifier:fsclass; 26, return_statement; 26, 27; 27, identifier:p; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:p; 31, call; 31, 32; 31, 33; 32, identifier:str; 33, argument_list; 33, 34; 34, identifier:p; 35, if_statement; 35, 36; 35, 38; 36, not_operator; 36, 37; 37, identifier:os_sep_is_slash; 38, block; 38, 39; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:p; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:p; 45, identifier:replace; 46, argument_list; 46, 47; 46, 48; 47, identifier:OS_SEP; 48, string:'/'; 49, if_statement; 49, 50; 49, 68; 49, 70; 49, 100; 50, comparison_operator:==; 50, 51; 50, 57; 50, 65; 51, subscript; 51, 52; 51, 53; 52, identifier:p; 53, slice; 53, 54; 53, 55; 53, 56; 54, integer:0; 55, colon; 56, integer:1; 57, ERROR; 57, 58; 57, 59; 57, 64; 58, identifier:p; 59, subscript; 59, 60; 59, 61; 60, identifier:p; 61, slice; 61, 62; 61, 63; 62, integer:1; 63, colon; 64, identifier:directory; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:Top; 68, ERROR; 68, 69; 69, identifier:do_splitdrive; 70, block; 70, 71; 70, 80; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 76; 73, pattern_list; 73, 74; 73, 75; 74, identifier:drive; 75, identifier:p; 76, call; 76, 77; 76, 78; 77, identifier:_my_splitdrive; 78, argument_list; 78, 79; 79, identifier:p; 80, if_statement; 80, 81; 80, 82; 80, 92; 81, identifier:drive; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:root; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:get_root; 90, argument_list; 90, 91; 91, identifier:drive; 92, else_clause; 92, 93; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:root; 97, attribute; 97, 98; 97, 99; 98, identifier:directory; 99, identifier:root; 100, else_clause; 100, 101; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:root; 105, attribute; 105, 106; 105, 107; 106, identifier:directory; 107, identifier:root; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:p; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:p; 114, identifier:strip; 115, argument_list; 115, 116; 116, string:'/'; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:needs_normpath; 120, call; 120, 121; 120, 122; 121, identifier:needs_normpath_match; 122, argument_list; 122, 123; 123, identifier:p; 124, if_statement; 124, 125; 124, 130; 124, 139; 125, comparison_operator:in; 125, 126; 125, 127; 126, identifier:p; 127, tuple; 127, 128; 127, 129; 128, string:''; 129, string:'.'; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:p; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:directory; 137, identifier:get_labspath; 138, argument_list; 139, else_clause; 139, 140; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:p; 144, binary_operator:+; 144, 145; 144, 152; 145, binary_operator:+; 145, 146; 145, 151; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:directory; 149, identifier:get_labspath; 150, argument_list; 151, string:'/'; 152, identifier:p; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 154, 158; 154, 164; 154, 166; 155, identifier:else; 156, ERROR; 156, 157; 157, identifier:if; 158, type; 158, 159; 159, constrained_type; 159, 160; 159, 162; 160, type; 160, 161; 161, identifier:do_splitdrive; 162, type; 162, 163; 163, identifier:drive; 164, ERROR; 164, 165; 165, identifier:p; 166, call; 166, 167; 166, 168; 167, identifier:_my_splitdrive; 168, argument_list; 168, 169; 169, identifier:p; 170, if_statement; 170, 171; 170, 175; 170, 180; 171, boolean_operator:and; 171, 172; 171, 173; 172, identifier:drive; 173, not_operator; 173, 174; 174, identifier:p; 175, block; 175, 176; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:p; 179, string:'/'; 180, else_clause; 180, 181; 181, block; 181, 182; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:drive; 185, string:''; 186, if_statement; 186, 187; 186, 190; 187, comparison_operator:!=; 187, 188; 187, 189; 188, identifier:p; 189, string:'/'; 190, block; 190, 191; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:p; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:p; 197, identifier:rstrip; 198, argument_list; 198, 199; 199, string:'/'; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:needs_normpath; 203, call; 203, 204; 203, 205; 204, identifier:needs_normpath_match; 205, argument_list; 205, 206; 206, identifier:p; 207, if_statement; 207, 208; 207, 216; 207, 226; 208, comparison_operator:==; 208, 209; 208, 215; 209, subscript; 209, 210; 209, 211; 210, identifier:p; 211, slice; 211, 212; 211, 213; 211, 214; 212, integer:0; 213, colon; 214, integer:1; 215, string:'/'; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:root; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:self; 223, identifier:get_root; 224, argument_list; 224, 225; 225, identifier:drive; 226, else_clause; 226, 227; 227, block; 227, 228; 227, 256; 227, 285; 228, if_statement; 228, 229; 228, 230; 228, 248; 229, identifier:directory; 230, block; 230, 231; 231, if_statement; 231, 232; 231, 238; 232, not_operator; 232, 233; 233, call; 233, 234; 233, 235; 234, identifier:isinstance; 235, argument_list; 235, 236; 235, 237; 236, identifier:directory; 237, identifier:Dir; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, assignment; 240, 241; 240, 242; 241, identifier:directory; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:self; 245, identifier:Dir; 246, argument_list; 246, 247; 247, identifier:directory; 248, else_clause; 248, 249; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:directory; 253, attribute; 253, 254; 253, 255; 254, identifier:self; 255, identifier:_cwd; 256, if_statement; 256, 257; 256, 262; 256, 271; 257, comparison_operator:in; 257, 258; 257, 259; 258, identifier:p; 259, tuple; 259, 260; 259, 261; 260, string:''; 261, string:'.'; 262, block; 262, 263; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:p; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:directory; 269, identifier:get_labspath; 270, argument_list; 271, else_clause; 271, 272; 272, block; 272, 273; 273, expression_statement; 273, 274; 274, assignment; 274, 275; 274, 276; 275, identifier:p; 276, binary_operator:+; 276, 277; 276, 284; 277, binary_operator:+; 277, 278; 277, 283; 278, call; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:directory; 281, identifier:get_labspath; 282, argument_list; 283, string:'/'; 284, identifier:p; 285, if_statement; 285, 286; 285, 287; 285, 297; 286, identifier:drive; 287, block; 287, 288; 288, expression_statement; 288, 289; 289, assignment; 289, 290; 289, 291; 290, identifier:root; 291, call; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:self; 294, identifier:get_root; 295, argument_list; 295, 296; 296, identifier:drive; 297, else_clause; 297, 298; 298, block; 298, 299; 299, expression_statement; 299, 300; 300, assignment; 300, 301; 300, 302; 301, identifier:root; 302, attribute; 302, 303; 302, 304; 303, identifier:directory; 304, identifier:root; 305, if_statement; 305, 306; 305, 309; 306, comparison_operator:is; 306, 307; 306, 308; 307, identifier:needs_normpath; 308, None; 309, block; 309, 310; 309, 323; 309, 327; 309, 362; 310, expression_statement; 310, 311; 311, assignment; 311, 312; 311, 313; 312, identifier:ins; 313, subscript; 313, 314; 313, 320; 314, call; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:p; 317, identifier:split; 318, argument_list; 318, 319; 319, string:'/'; 320, slice; 320, 321; 320, 322; 321, integer:1; 322, colon; 323, expression_statement; 323, 324; 324, assignment; 324, 325; 324, 326; 325, identifier:outs; 326, list:[]; 327, for_statement; 327, 328; 327, 329; 327, 330; 328, identifier:d; 329, identifier:ins; 330, block; 330, 331; 331, if_statement; 331, 332; 331, 335; 331, 348; 332, comparison_operator:==; 332, 333; 332, 334; 333, identifier:d; 334, string:'..'; 335, block; 335, 336; 336, try_statement; 336, 337; 336, 344; 337, block; 337, 338; 338, expression_statement; 338, 339; 339, call; 339, 340; 339, 343; 340, attribute; 340, 341; 340, 342; 341, identifier:outs; 342, identifier:pop; 343, argument_list; 344, except_clause; 344, 345; 344, 346; 345, identifier:IndexError; 346, block; 346, 347; 347, pass_statement; 348, elif_clause; 348, 349; 348, 354; 349, comparison_operator:not; 349, 350; 349, 351; 350, identifier:d; 351, tuple; 351, 352; 351, 353; 352, string:''; 353, string:'.'; 354, block; 354, 355; 355, expression_statement; 355, 356; 356, call; 356, 357; 356, 360; 357, attribute; 357, 358; 357, 359; 358, identifier:outs; 359, identifier:append; 360, argument_list; 360, 361; 361, identifier:d; 362, expression_statement; 362, 363; 363, assignment; 363, 364; 363, 365; 364, identifier:p; 365, binary_operator:+; 365, 366; 365, 367; 366, string:'/'; 367, call; 367, 368; 367, 371; 368, attribute; 368, 369; 368, 370; 369, string:'/'; 370, identifier:join; 371, argument_list; 371, 372; 372, identifier:outs; 373, return_statement; 373, 374; 374, call; 374, 375; 374, 378; 375, attribute; 375, 376; 375, 377; 376, identifier:root; 377, identifier:_lookup_abs; 378, argument_list; 378, 379; 378, 380; 378, 381; 379, identifier:p; 380, identifier:fsclass; 381, identifier:create | def _lookup(self, p, directory, fsclass, create=1):
if isinstance(p, Base):
p.must_be_same(fsclass)
return p
p = str(p)
if not os_sep_is_slash:
p = p.replace(OS_SEP, '/')
if p[0:1] == '
p = p[1:]
directory = self.Top
if do_splitdrive:
drive, p = _my_splitdrive(p)
if drive:
root = self.get_root(drive)
else:
root = directory.root
else:
root = directory.root
p = p.strip('/')
needs_normpath = needs_normpath_match(p)
if p in ('', '.'):
p = directory.get_labspath()
else:
p = directory.get_labspath() + '/' + p
else:
if do_splitdrive:
drive, p = _my_splitdrive(p)
if drive and not p:
p = '/'
else:
drive = ''
if p != '/':
p = p.rstrip('/')
needs_normpath = needs_normpath_match(p)
if p[0:1] == '/':
root = self.get_root(drive)
else:
if directory:
if not isinstance(directory, Dir):
directory = self.Dir(directory)
else:
directory = self._cwd
if p in ('', '.'):
p = directory.get_labspath()
else:
p = directory.get_labspath() + '/' + p
if drive:
root = self.get_root(drive)
else:
root = directory.root
if needs_normpath is not None:
ins = p.split('/')[1:]
outs = []
for d in ins:
if d == '..':
try:
outs.pop()
except IndexError:
pass
elif d not in ('', '.'):
outs.append(d)
p = '/' + '/'.join(outs)
return root._lookup_abs(p, fsclass, create) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:_glob1; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:pattern; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ondisk; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:source; 11, False; 12, default_parameter; 12, 13; 12, 14; 13, identifier:strings; 14, False; 15, block; 15, 16; 15, 24; 15, 43; 15, 49; 15, 53; 15, 222; 15, 229; 15, 250; 15, 260; 15, 265; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:search_dir_list; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:get_all_rdirs; 23, argument_list; 24, for_statement; 24, 25; 24, 26; 24, 31; 25, identifier:srcdir; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:srcdir_list; 30, argument_list; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:search_dir_list; 36, identifier:extend; 37, argument_list; 37, 38; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:srcdir; 41, identifier:get_all_rdirs; 42, argument_list; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:selfEntry; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:Entry; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:names; 52, list:[]; 53, for_statement; 53, 54; 53, 55; 53, 56; 54, identifier:dir; 55, identifier:search_dir_list; 56, block; 56, 57; 56, 81; 56, 88; 56, 101; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:node_names; 60, list_comprehension; 60, 61; 60, 64; 60, 75; 61, attribute; 61, 62; 61, 63; 62, identifier:v; 63, identifier:name; 64, for_in_clause; 64, 65; 64, 68; 65, pattern_list; 65, 66; 65, 67; 66, identifier:k; 67, identifier:v; 68, call; 68, 69; 68, 74; 69, attribute; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:dir; 72, identifier:entries; 73, identifier:items; 74, argument_list; 75, if_clause; 75, 76; 76, comparison_operator:not; 76, 77; 76, 78; 77, identifier:k; 78, tuple; 78, 79; 78, 80; 79, string:'.'; 80, string:'..'; 81, expression_statement; 81, 82; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:names; 85, identifier:extend; 86, argument_list; 86, 87; 87, identifier:node_names; 88, if_statement; 88, 89; 88, 91; 89, not_operator; 89, 90; 90, identifier:strings; 91, block; 91, 92; 92, for_statement; 92, 93; 92, 94; 92, 95; 93, identifier:name; 94, identifier:node_names; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:selfEntry; 99, argument_list; 99, 100; 100, identifier:name; 101, if_statement; 101, 102; 101, 103; 102, identifier:ondisk; 103, block; 103, 104; 103, 123; 103, 130; 104, try_statement; 104, 105; 104, 117; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:disk_names; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:os; 112, identifier:listdir; 113, argument_list; 113, 114; 114, attribute; 114, 115; 114, 116; 115, identifier:dir; 116, identifier:_abspath; 117, except_clause; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:os; 120, identifier:error; 121, block; 121, 122; 122, continue_statement; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:names; 127, identifier:extend; 128, argument_list; 128, 129; 129, identifier:disk_names; 130, if_statement; 130, 131; 130, 133; 131, not_operator; 131, 132; 132, identifier:strings; 133, block; 133, 134; 133, 155; 133, 165; 133, 171; 134, if_statement; 134, 135; 134, 140; 135, comparison_operator:!=; 135, 136; 135, 139; 136, subscript; 136, 137; 136, 138; 137, identifier:pattern; 138, integer:0; 139, string:'.'; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:disk_names; 144, list_comprehension; 144, 145; 144, 146; 144, 149; 145, identifier:x; 146, for_in_clause; 146, 147; 146, 148; 147, identifier:x; 148, identifier:disk_names; 149, if_clause; 149, 150; 150, comparison_operator:!=; 150, 151; 150, 154; 151, subscript; 151, 152; 151, 153; 152, identifier:x; 153, integer:0; 154, string:'.'; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:disk_names; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:fnmatch; 161, identifier:filter; 162, argument_list; 162, 163; 162, 164; 163, identifier:disk_names; 164, identifier:pattern; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:dirEntry; 168, attribute; 168, 169; 168, 170; 169, identifier:dir; 170, identifier:Entry; 171, for_statement; 171, 172; 171, 173; 171, 174; 172, identifier:name; 173, identifier:disk_names; 174, block; 174, 175; 174, 181; 174, 192; 174, 199; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:name; 178, binary_operator:+; 178, 179; 178, 180; 179, string:'./'; 180, identifier:name; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 184; 183, identifier:node; 184, call; 184, 185; 184, 191; 185, attribute; 185, 186; 185, 190; 186, call; 186, 187; 186, 188; 187, identifier:dirEntry; 188, argument_list; 188, 189; 189, identifier:name; 190, identifier:disambiguate; 191, argument_list; 192, expression_statement; 192, 193; 193, assignment; 193, 194; 193, 195; 194, identifier:n; 195, call; 195, 196; 195, 197; 196, identifier:selfEntry; 197, argument_list; 197, 198; 198, identifier:name; 199, if_statement; 199, 200; 199, 207; 200, comparison_operator:!=; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:n; 203, identifier:__class__; 204, attribute; 204, 205; 204, 206; 205, identifier:node; 206, identifier:__class__; 207, block; 207, 208; 207, 216; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:n; 212, identifier:__class__; 213, attribute; 213, 214; 213, 215; 214, identifier:node; 215, identifier:__class__; 216, expression_statement; 216, 217; 217, call; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:n; 220, identifier:_morph; 221, argument_list; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:names; 225, call; 225, 226; 225, 227; 226, identifier:set; 227, argument_list; 227, 228; 228, identifier:names; 229, if_statement; 229, 230; 229, 235; 230, comparison_operator:!=; 230, 231; 230, 234; 231, subscript; 231, 232; 231, 233; 232, identifier:pattern; 233, integer:0; 234, string:'.'; 235, block; 235, 236; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:names; 239, list_comprehension; 239, 240; 239, 241; 239, 244; 240, identifier:x; 241, for_in_clause; 241, 242; 241, 243; 242, identifier:x; 243, identifier:names; 244, if_clause; 244, 245; 245, comparison_operator:!=; 245, 246; 245, 249; 246, subscript; 246, 247; 246, 248; 247, identifier:x; 248, integer:0; 249, string:'.'; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:names; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:fnmatch; 256, identifier:filter; 257, argument_list; 257, 258; 257, 259; 258, identifier:names; 259, identifier:pattern; 260, if_statement; 260, 261; 260, 262; 261, identifier:strings; 262, block; 262, 263; 263, return_statement; 263, 264; 264, identifier:names; 265, return_statement; 265, 266; 266, list_comprehension; 266, 267; 266, 275; 267, subscript; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:self; 270, identifier:entries; 271, call; 271, 272; 271, 273; 272, identifier:_my_normcase; 273, argument_list; 273, 274; 274, identifier:n; 275, for_in_clause; 275, 276; 275, 277; 276, identifier:n; 277, identifier:names | def _glob1(self, pattern, ondisk=True, source=False, strings=False):
search_dir_list = self.get_all_rdirs()
for srcdir in self.srcdir_list():
search_dir_list.extend(srcdir.get_all_rdirs())
selfEntry = self.Entry
names = []
for dir in search_dir_list:
node_names = [ v.name for k, v in dir.entries.items()
if k not in ('.', '..') ]
names.extend(node_names)
if not strings:
for name in node_names: selfEntry(name)
if ondisk:
try:
disk_names = os.listdir(dir._abspath)
except os.error:
continue
names.extend(disk_names)
if not strings:
if pattern[0] != '.':
disk_names = [x for x in disk_names if x[0] != '.']
disk_names = fnmatch.filter(disk_names, pattern)
dirEntry = dir.Entry
for name in disk_names:
name = './' + name
node = dirEntry(name).disambiguate()
n = selfEntry(name)
if n.__class__ != node.__class__:
n.__class__ = node.__class__
n._morph()
names = set(names)
if pattern[0] != '.':
names = [x for x in names if x[0] != '.']
names = fnmatch.filter(names, pattern)
if strings:
return names
return [self.entries[_my_normcase(n)] for n in names] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:release_target_info; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 17; 7, parenthesized_expression; 7, 8; 8, boolean_operator:or; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:released_target_info; 12, attribute; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:SCons; 15, identifier:Node; 16, identifier:interactive; 17, block; 17, 18; 18, return_statement; 19, if_statement; 19, 20; 19, 28; 20, not_operator; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:hasattr; 23, argument_list; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:attributes; 27, string:'keep_targetinfo'; 28, block; 28, 29; 28, 38; 28, 44; 28, 50; 28, 56; 28, 66; 28, 72; 28, 87; 28, 102; 28, 117; 28, 132; 28, 147; 29, expression_statement; 29, 30; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:changed; 34, argument_list; 34, 35; 35, keyword_argument; 35, 36; 35, 37; 36, identifier:allowcache; 37, True; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:get_contents_sig; 43, argument_list; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:get_build_env; 49, argument_list; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:executor; 55, None; 56, expression_statement; 56, 57; 57, call; 57, 58; 57, 63; 58, attribute; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:_memo; 62, identifier:pop; 63, argument_list; 63, 64; 63, 65; 64, string:'rfile'; 65, None; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:prerequisites; 71, None; 72, if_statement; 72, 73; 72, 80; 73, not_operator; 73, 74; 74, call; 74, 75; 74, 76; 75, identifier:len; 76, argument_list; 76, 77; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:ignore_set; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:self; 85, identifier:ignore_set; 86, None; 87, if_statement; 87, 88; 87, 95; 88, not_operator; 88, 89; 89, call; 89, 90; 89, 91; 90, identifier:len; 91, argument_list; 91, 92; 92, attribute; 92, 93; 92, 94; 93, identifier:self; 94, identifier:implicit_set; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:self; 100, identifier:implicit_set; 101, None; 102, if_statement; 102, 103; 102, 110; 103, not_operator; 103, 104; 104, call; 104, 105; 104, 106; 105, identifier:len; 106, argument_list; 106, 107; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:depends_set; 110, block; 110, 111; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:self; 115, identifier:depends_set; 116, None; 117, if_statement; 117, 118; 117, 125; 118, not_operator; 118, 119; 119, call; 119, 120; 119, 121; 120, identifier:len; 121, argument_list; 121, 122; 122, attribute; 122, 123; 122, 124; 123, identifier:self; 124, identifier:ignore; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:self; 130, identifier:ignore; 131, None; 132, if_statement; 132, 133; 132, 140; 133, not_operator; 133, 134; 134, call; 134, 135; 134, 136; 135, identifier:len; 136, argument_list; 136, 137; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:depends; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:depends; 146, None; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:released_target_info; 152, True | def release_target_info(self):
if (self.released_target_info or SCons.Node.interactive):
return
if not hasattr(self.attributes, 'keep_targetinfo'):
self.changed(allowcache=True)
self.get_contents_sig()
self.get_build_env()
self.executor = None
self._memo.pop('rfile', None)
self.prerequisites = None
if not len(self.ignore_set):
self.ignore_set = None
if not len(self.implicit_set):
self.implicit_set = None
if not len(self.depends_set):
self.depends_set = None
if not len(self.ignore):
self.ignore = None
if not len(self.depends):
self.depends = None
self.released_target_info = True |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:find_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:filename; 6, identifier:paths; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, None; 10, block; 10, 11; 10, 21; 10, 58; 10, 104; 10, 117; 10, 142; 10, 146; 10, 193; 10, 199; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:memo_key; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:_find_file_key; 18, argument_list; 18, 19; 18, 20; 19, identifier:filename; 20, identifier:paths; 21, try_statement; 21, 22; 21, 31; 21, 46; 22, block; 22, 23; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:memo_dict; 26, subscript; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:_memo; 30, string:'find_file'; 31, except_clause; 31, 32; 31, 33; 32, identifier:KeyError; 33, block; 33, 34; 33, 38; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:memo_dict; 37, dictionary; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 45; 40, subscript; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:_memo; 44, string:'find_file'; 45, identifier:memo_dict; 46, else_clause; 46, 47; 47, block; 47, 48; 48, try_statement; 48, 49; 48, 54; 49, block; 49, 50; 50, return_statement; 50, 51; 51, subscript; 51, 52; 51, 53; 52, identifier:memo_dict; 53, identifier:memo_key; 54, except_clause; 54, 55; 54, 56; 55, identifier:KeyError; 56, block; 56, 57; 57, pass_statement; 58, if_statement; 58, 59; 58, 66; 59, boolean_operator:and; 59, 60; 59, 61; 60, identifier:verbose; 61, not_operator; 61, 62; 62, call; 62, 63; 62, 64; 63, identifier:callable; 64, argument_list; 64, 65; 65, identifier:verbose; 66, block; 66, 67; 66, 82; 66, 88; 67, if_statement; 67, 68; 67, 77; 68, not_operator; 68, 69; 69, call; 69, 70; 69, 75; 70, attribute; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:SCons; 73, identifier:Util; 74, identifier:is_String; 75, argument_list; 75, 76; 76, identifier:verbose; 77, block; 77, 78; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:verbose; 81, string:"find_file"; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:_verbose; 85, binary_operator:%; 85, 86; 85, 87; 86, string:u' %s: '; 87, identifier:verbose; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:verbose; 91, lambda; 91, 92; 91, 94; 92, lambda_parameters; 92, 93; 93, identifier:s; 94, call; 94, 95; 94, 100; 95, attribute; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:sys; 98, identifier:stdout; 99, identifier:write; 100, argument_list; 100, 101; 101, binary_operator:+; 101, 102; 101, 103; 102, identifier:_verbose; 103, identifier:s; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 109; 106, pattern_list; 106, 107; 106, 108; 107, identifier:filedir; 108, identifier:filename; 109, call; 109, 110; 109, 115; 110, attribute; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:os; 113, identifier:path; 114, identifier:split; 115, argument_list; 115, 116; 116, identifier:filename; 117, if_statement; 117, 118; 117, 119; 118, identifier:filedir; 119, block; 119, 120; 119, 126; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:self; 124, identifier:default_filedir; 125, identifier:filedir; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:paths; 129, list_comprehension; 129, 130; 129, 131; 129, 140; 130, identifier:_f; 131, for_in_clause; 131, 132; 131, 133; 132, identifier:_f; 133, call; 133, 134; 133, 135; 134, identifier:map; 135, argument_list; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:filedir_lookup; 139, identifier:paths; 140, if_clause; 140, 141; 141, identifier:_f; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:result; 145, None; 146, for_statement; 146, 147; 146, 148; 146, 149; 147, identifier:dir; 148, identifier:paths; 149, block; 149, 150; 149, 162; 149, 173; 150, if_statement; 150, 151; 150, 152; 151, identifier:verbose; 152, block; 152, 153; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 156; 155, identifier:verbose; 156, argument_list; 156, 157; 157, binary_operator:%; 157, 158; 157, 159; 158, string:"looking for '%s' in '%s' ...\n"; 159, tuple; 159, 160; 159, 161; 160, identifier:filename; 161, identifier:dir; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 167; 164, pattern_list; 164, 165; 164, 166; 165, identifier:node; 166, identifier:d; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:dir; 170, identifier:srcdir_find_file; 171, argument_list; 171, 172; 172, identifier:filename; 173, if_statement; 173, 174; 173, 175; 174, identifier:node; 175, block; 175, 176; 175, 188; 175, 192; 176, if_statement; 176, 177; 176, 178; 177, identifier:verbose; 178, block; 178, 179; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 182; 181, identifier:verbose; 182, argument_list; 182, 183; 183, binary_operator:%; 183, 184; 183, 185; 184, string:"... FOUND '%s' in '%s'\n"; 185, tuple; 185, 186; 185, 187; 186, identifier:filename; 187, identifier:d; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 191; 190, identifier:result; 191, identifier:node; 192, break_statement; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 198; 195, subscript; 195, 196; 195, 197; 196, identifier:memo_dict; 197, identifier:memo_key; 198, identifier:result; 199, return_statement; 199, 200; 200, identifier:result | def find_file(self, filename, paths, verbose=None):
memo_key = self._find_file_key(filename, paths)
try:
memo_dict = self._memo['find_file']
except KeyError:
memo_dict = {}
self._memo['find_file'] = memo_dict
else:
try:
return memo_dict[memo_key]
except KeyError:
pass
if verbose and not callable(verbose):
if not SCons.Util.is_String(verbose):
verbose = "find_file"
_verbose = u' %s: ' % verbose
verbose = lambda s: sys.stdout.write(_verbose + s)
filedir, filename = os.path.split(filename)
if filedir:
self.default_filedir = filedir
paths = [_f for _f in map(self.filedir_lookup, paths) if _f]
result = None
for dir in paths:
if verbose:
verbose("looking for '%s' in '%s' ...\n" % (filename, dir))
node, d = dir.srcdir_find_file(filename)
if node:
if verbose:
verbose("... FOUND '%s' in '%s'\n" % (filename, d))
result = node
break
memo_dict[memo_key] = result
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:build_report; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:device_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_size; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:device_uptime; 11, integer:0; 12, default_parameter; 12, 13; 12, 14; 13, identifier:report_id; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:auth_chain; 17, None; 18, block; 18, 19; 18, 37; 18, 53; 18, 69; 18, 262; 19, if_statement; 19, 20; 19, 31; 20, boolean_operator:or; 20, 21; 20, 26; 21, comparison_operator:is; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:walker; 25, None; 26, comparison_operator:is; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:index; 30, None; 31, block; 31, 32; 32, raise_statement; 32, 33; 33, call; 33, 34; 33, 35; 34, identifier:InternalError; 35, argument_list; 35, 36; 36, string:"You can only build a report with a DataStreamer if you create it with a SensorLog and a streamer index"; 37, if_statement; 37, 38; 37, 47; 38, boolean_operator:and; 38, 39; 38, 44; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:requires_signing; 43, argument_list; 44, comparison_operator:is; 44, 45; 44, 46; 45, identifier:auth_chain; 46, None; 47, block; 47, 48; 48, raise_statement; 48, 49; 49, call; 49, 50; 49, 51; 50, identifier:ArgumentError; 51, argument_list; 51, 52; 52, string:"You must pass an auth chain to sign this report."; 53, if_statement; 53, 54; 53, 63; 54, boolean_operator:and; 54, 55; 54, 60; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:requires_id; 59, argument_list; 60, comparison_operator:is; 60, 61; 60, 62; 61, identifier:report_id; 62, None; 63, block; 63, 64; 64, raise_statement; 64, 65; 65, call; 65, 66; 65, 67; 66, identifier:ArgumentError; 67, argument_list; 67, 68; 68, string:"You must pass a report_id to serialize this report"; 69, if_statement; 69, 70; 69, 75; 69, 135; 70, comparison_operator:==; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:format; 74, string:'individual'; 75, block; 75, 76; 75, 86; 75, 92; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:reading; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:walker; 84, identifier:pop; 85, argument_list; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:highest_id; 89, attribute; 89, 90; 89, 91; 90, identifier:reading; 91, identifier:reading_id; 92, if_statement; 92, 93; 92, 98; 92, 113; 93, comparison_operator:==; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:report_type; 97, string:'telegram'; 98, block; 98, 99; 99, return_statement; 99, 100; 100, call; 100, 101; 100, 102; 101, identifier:StreamerReport; 102, argument_list; 102, 103; 102, 111; 102, 112; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:IndividualReadingReport; 106, identifier:FromReadings; 107, argument_list; 107, 108; 107, 109; 108, identifier:device_id; 109, list:[reading]; 109, 110; 110, identifier:reading; 111, integer:1; 112, identifier:highest_id; 113, elif_clause; 113, 114; 113, 119; 114, comparison_operator:==; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:self; 117, identifier:report_type; 118, string:'broadcast'; 119, block; 119, 120; 120, return_statement; 120, 121; 121, call; 121, 122; 121, 123; 122, identifier:StreamerReport; 123, argument_list; 123, 124; 123, 133; 123, 134; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:BroadcastReport; 127, identifier:FromReadings; 128, argument_list; 128, 129; 128, 130; 128, 132; 129, identifier:device_id; 130, list:[reading]; 130, 131; 131, identifier:reading; 132, identifier:device_uptime; 133, integer:1; 134, identifier:highest_id; 135, elif_clause; 135, 136; 135, 141; 136, comparison_operator:==; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:format; 140, string:'hashedlist'; 141, block; 141, 142; 141, 153; 141, 166; 141, 170; 141, 174; 141, 226; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:max_readings; 145, binary_operator://; 145, 146; 145, 152; 146, parenthesized_expression; 146, 147; 147, binary_operator:-; 147, 148; 147, 151; 148, binary_operator:-; 148, 149; 148, 150; 149, identifier:max_size; 150, integer:20; 151, integer:24; 152, integer:16; 153, if_statement; 153, 154; 153, 157; 154, comparison_operator:<=; 154, 155; 154, 156; 155, identifier:max_readings; 156, integer:0; 157, block; 157, 158; 158, raise_statement; 158, 159; 159, call; 159, 160; 159, 161; 160, identifier:InternalError; 161, argument_list; 161, 162; 161, 163; 162, string:"max_size is too small to hold even a single reading"; 163, keyword_argument; 163, 164; 163, 165; 164, identifier:max_size; 165, identifier:max_size; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 169; 168, identifier:readings; 169, list:[]; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 173; 172, identifier:highest_id; 173, integer:0; 174, try_statement; 174, 175; 174, 214; 175, block; 175, 176; 176, while_statement; 176, 177; 176, 183; 177, comparison_operator:<; 177, 178; 177, 182; 178, call; 178, 179; 178, 180; 179, identifier:len; 180, argument_list; 180, 181; 181, identifier:readings; 182, identifier:max_readings; 183, block; 183, 184; 183, 194; 183, 201; 184, expression_statement; 184, 185; 185, assignment; 185, 186; 185, 187; 186, identifier:reading; 187, call; 187, 188; 187, 193; 188, attribute; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:self; 191, identifier:walker; 192, identifier:pop; 193, argument_list; 194, expression_statement; 194, 195; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:readings; 198, identifier:append; 199, argument_list; 199, 200; 200, identifier:reading; 201, if_statement; 201, 202; 201, 207; 202, comparison_operator:>; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:reading; 205, identifier:reading_id; 206, identifier:highest_id; 207, block; 207, 208; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 211; 210, identifier:highest_id; 211, attribute; 211, 212; 211, 213; 212, identifier:reading; 213, identifier:reading_id; 214, except_clause; 214, 215; 214, 216; 215, identifier:StreamEmptyError; 216, block; 216, 217; 217, if_statement; 217, 218; 217, 224; 218, comparison_operator:==; 218, 219; 218, 223; 219, call; 219, 220; 219, 221; 220, identifier:len; 221, argument_list; 221, 222; 222, identifier:readings; 223, integer:0; 224, block; 224, 225; 225, raise_statement; 226, return_statement; 226, 227; 227, call; 227, 228; 227, 229; 228, identifier:StreamerReport; 229, argument_list; 229, 230; 229, 257; 229, 261; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:SignedListReport; 233, identifier:FromReadings; 234, argument_list; 234, 235; 234, 236; 234, 237; 234, 240; 234, 249; 234, 254; 235, identifier:device_id; 236, identifier:readings; 237, keyword_argument; 237, 238; 237, 239; 238, identifier:report_id; 239, identifier:report_id; 240, keyword_argument; 240, 241; 240, 242; 241, identifier:selector; 242, call; 242, 243; 242, 248; 243, attribute; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:self; 246, identifier:selector; 247, identifier:encode; 248, argument_list; 249, keyword_argument; 249, 250; 249, 251; 250, identifier:streamer; 251, attribute; 251, 252; 251, 253; 252, identifier:self; 253, identifier:index; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:sent_timestamp; 256, identifier:device_uptime; 257, call; 257, 258; 257, 259; 258, identifier:len; 259, argument_list; 259, 260; 260, identifier:readings; 261, identifier:highest_id; 262, raise_statement; 262, 263; 263, call; 263, 264; 263, 265; 264, identifier:InternalError; 265, argument_list; 265, 266; 265, 267; 265, 272; 266, string:"Streamer report format or type is not supported currently"; 267, keyword_argument; 267, 268; 267, 269; 268, identifier:report_format; 269, attribute; 269, 270; 269, 271; 270, identifier:self; 271, identifier:format; 272, keyword_argument; 272, 273; 272, 274; 273, identifier:report_type; 274, attribute; 274, 275; 274, 276; 275, identifier:self; 276, identifier:report_type | def build_report(self, device_id, max_size=None, device_uptime=0, report_id=None, auth_chain=None):
if self.walker is None or self.index is None:
raise InternalError("You can only build a report with a DataStreamer if you create it with a SensorLog and a streamer index")
if self.requires_signing() and auth_chain is None:
raise ArgumentError("You must pass an auth chain to sign this report.")
if self.requires_id() and report_id is None:
raise ArgumentError("You must pass a report_id to serialize this report")
if self.format == 'individual':
reading = self.walker.pop()
highest_id = reading.reading_id
if self.report_type == 'telegram':
return StreamerReport(IndividualReadingReport.FromReadings(device_id, [reading]), 1, highest_id)
elif self.report_type == 'broadcast':
return StreamerReport(BroadcastReport.FromReadings(device_id, [reading], device_uptime), 1, highest_id)
elif self.format == 'hashedlist':
max_readings = (max_size - 20 - 24) // 16
if max_readings <= 0:
raise InternalError("max_size is too small to hold even a single reading", max_size=max_size)
readings = []
highest_id = 0
try:
while len(readings) < max_readings:
reading = self.walker.pop()
readings.append(reading)
if reading.reading_id > highest_id:
highest_id = reading.reading_id
except StreamEmptyError:
if len(readings) == 0:
raise
return StreamerReport(SignedListReport.FromReadings(device_id, readings, report_id=report_id, selector=self.selector.encode(),
streamer=self.index, sent_timestamp=device_uptime), len(readings), highest_id)
raise InternalError("Streamer report format or type is not supported currently", report_format=self.format, report_type=self.report_type) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:scan; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wait; 7, None; 8, block; 8, 9; 8, 21; 8, 33; 8, 37; 8, 47; 8, 58; 8, 80; 8, 89; 8, 99; 8, 105; 8, 111; 8, 175; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:min_scan; 12, call; 12, 13; 12, 18; 13, attribute; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:adapter; 17, identifier:get_config; 18, argument_list; 18, 19; 18, 20; 19, string:'minimum_scan_time'; 20, float:0.0; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:probe_required; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:adapter; 29, identifier:get_config; 30, argument_list; 30, 31; 30, 32; 31, string:'probe_required'; 32, False; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:wait_time; 36, None; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:elapsed; 40, binary_operator:-; 40, 41; 40, 44; 41, call; 41, 42; 41, 43; 42, identifier:monotonic; 43, argument_list; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:_start_time; 47, if_statement; 47, 48; 47, 51; 48, comparison_operator:<; 48, 49; 48, 50; 49, identifier:elapsed; 50, identifier:min_scan; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:wait_time; 55, binary_operator:-; 55, 56; 55, 57; 56, identifier:min_scan; 57, identifier:elapsed; 58, if_statement; 58, 59; 58, 60; 59, identifier:probe_required; 60, block; 60, 61; 60, 76; 61, expression_statement; 61, 62; 62, call; 62, 63; 62, 68; 63, attribute; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:_loop; 67, identifier:run_coroutine; 68, argument_list; 68, 69; 69, call; 69, 70; 69, 75; 70, attribute; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:adapter; 74, identifier:probe; 75, argument_list; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:wait_time; 79, identifier:min_scan; 80, if_statement; 80, 81; 80, 84; 81, comparison_operator:is; 81, 82; 81, 83; 82, identifier:wait; 83, None; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:wait_time; 88, identifier:wait; 89, if_statement; 89, 90; 89, 93; 90, comparison_operator:is; 90, 91; 90, 92; 91, identifier:wait_time; 92, None; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, call; 95, 96; 95, 97; 96, identifier:sleep; 97, argument_list; 97, 98; 98, identifier:wait_time; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:to_remove; 102, call; 102, 103; 102, 104; 103, identifier:set; 104, argument_list; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:now; 108, call; 108, 109; 108, 110; 109, identifier:monotonic; 110, argument_list; 111, with_statement; 111, 112; 111, 117; 112, with_clause; 112, 113; 113, with_item; 113, 114; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:_scan_lock; 117, block; 117, 118; 117, 144; 117, 154; 118, for_statement; 118, 119; 118, 122; 118, 129; 119, pattern_list; 119, 120; 119, 121; 120, identifier:name; 121, identifier:value; 122, call; 122, 123; 122, 128; 123, attribute; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:_scanned_devices; 127, identifier:items; 128, argument_list; 129, block; 129, 130; 130, if_statement; 130, 131; 130, 136; 131, comparison_operator:<; 131, 132; 131, 135; 132, subscript; 132, 133; 132, 134; 133, identifier:value; 134, string:'expiration_time'; 135, identifier:now; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:to_remove; 141, identifier:add; 142, argument_list; 142, 143; 143, identifier:name; 144, for_statement; 144, 145; 144, 146; 144, 147; 145, identifier:name; 146, identifier:to_remove; 147, block; 147, 148; 148, delete_statement; 148, 149; 149, subscript; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:self; 152, identifier:_scanned_devices; 153, identifier:name; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:devices; 157, call; 157, 158; 157, 159; 158, identifier:sorted; 159, argument_list; 159, 160; 159, 167; 160, call; 160, 161; 160, 166; 161, attribute; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:self; 164, identifier:_scanned_devices; 165, identifier:values; 166, argument_list; 167, keyword_argument; 167, 168; 167, 169; 168, identifier:key; 169, lambda; 169, 170; 169, 172; 170, lambda_parameters; 170, 171; 171, identifier:x; 172, subscript; 172, 173; 172, 174; 173, identifier:x; 174, string:'uuid'; 175, return_statement; 175, 176; 176, identifier:devices | def scan(self, wait=None):
min_scan = self.adapter.get_config('minimum_scan_time', 0.0)
probe_required = self.adapter.get_config('probe_required', False)
wait_time = None
elapsed = monotonic() - self._start_time
if elapsed < min_scan:
wait_time = min_scan - elapsed
if probe_required:
self._loop.run_coroutine(self.adapter.probe())
wait_time = min_scan
if wait is not None:
wait_time = wait
if wait_time is not None:
sleep(wait_time)
to_remove = set()
now = monotonic()
with self._scan_lock:
for name, value in self._scanned_devices.items():
if value['expiration_time'] < now:
to_remove.add(name)
for name in to_remove:
del self._scanned_devices[name]
devices = sorted(self._scanned_devices.values(), key=lambda x: x['uuid'])
return devices |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:send_rpc; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:address; 6, identifier:rpc_id; 7, identifier:call_payload; 8, default_parameter; 8, 9; 8, 10; 9, identifier:timeout; 10, float:3.0; 11, block; 11, 12; 11, 23; 11, 32; 11, 37; 11, 41; 11, 45; 11, 56; 11, 81; 11, 131; 11, 155; 11, 166; 12, if_statement; 12, 13; 12, 17; 13, not_operator; 13, 14; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:connected; 17, block; 17, 18; 18, raise_statement; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:HardwareError; 21, argument_list; 21, 22; 22, string:"Cannot send an RPC if we are not in a connected state"; 23, if_statement; 23, 24; 23, 27; 24, comparison_operator:is; 24, 25; 24, 26; 25, identifier:timeout; 26, None; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:timeout; 31, float:3.0; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:status; 35, unary_operator:-; 35, 36; 36, integer:1; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:payload; 40, string:b''; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:recording; 44, None; 45, if_statement; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:connection_interrupted; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:_try_reconnect; 55, argument_list; 56, if_statement; 56, 57; 56, 62; 57, comparison_operator:is; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:_record; 61, None; 62, block; 62, 63; 62, 75; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:recording; 66, call; 66, 67; 66, 68; 67, identifier:_RecordedRPC; 68, argument_list; 68, 69; 68, 72; 68, 73; 68, 74; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:connection_string; 72, identifier:address; 73, identifier:rpc_id; 74, identifier:call_payload; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:recording; 79, identifier:start; 80, argument_list; 81, try_statement; 81, 82; 81, 115; 82, block; 82, 83; 82, 105; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:payload; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:_loop; 91, identifier:run_coroutine; 92, argument_list; 92, 93; 93, call; 93, 94; 93, 99; 94, attribute; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:adapter; 98, identifier:send_rpc; 99, argument_list; 99, 100; 99, 101; 99, 102; 99, 103; 99, 104; 100, integer:0; 101, identifier:address; 102, identifier:rpc_id; 103, identifier:call_payload; 104, identifier:timeout; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 110; 107, pattern_list; 107, 108; 107, 109; 108, identifier:status; 109, identifier:payload; 110, call; 110, 111; 110, 112; 111, identifier:pack_rpc_response; 112, argument_list; 112, 113; 112, 114; 113, identifier:payload; 114, None; 115, except_clause; 115, 116; 115, 120; 116, as_pattern; 116, 117; 116, 118; 117, identifier:VALID_RPC_EXCEPTIONS; 118, as_pattern_target; 118, 119; 119, identifier:exc; 120, block; 120, 121; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 126; 123, pattern_list; 123, 124; 123, 125; 124, identifier:status; 125, identifier:payload; 126, call; 126, 127; 126, 128; 127, identifier:pack_rpc_response; 128, argument_list; 128, 129; 128, 130; 129, identifier:payload; 130, identifier:exc; 131, if_statement; 131, 132; 131, 137; 132, comparison_operator:is; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:_record; 136, None; 137, block; 137, 138; 137, 146; 138, expression_statement; 138, 139; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:recording; 142, identifier:finish; 143, argument_list; 143, 144; 143, 145; 144, identifier:status; 145, identifier:payload; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 153; 148, attribute; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:_recording; 152, identifier:append; 153, argument_list; 153, 154; 154, identifier:recording; 155, if_statement; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:self; 158, identifier:connection_interrupted; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:self; 164, identifier:_try_reconnect; 165, argument_list; 166, return_statement; 166, 167; 167, call; 167, 168; 167, 169; 168, identifier:unpack_rpc_response; 169, argument_list; 169, 170; 169, 171; 169, 172; 169, 173; 170, identifier:status; 171, identifier:payload; 172, identifier:rpc_id; 173, identifier:address | def send_rpc(self, address, rpc_id, call_payload, timeout=3.0):
if not self.connected:
raise HardwareError("Cannot send an RPC if we are not in a connected state")
if timeout is None:
timeout = 3.0
status = -1
payload = b''
recording = None
if self.connection_interrupted:
self._try_reconnect()
if self._record is not None:
recording = _RecordedRPC(self.connection_string, address, rpc_id, call_payload)
recording.start()
try:
payload = self._loop.run_coroutine(self.adapter.send_rpc(0, address, rpc_id, call_payload, timeout))
status, payload = pack_rpc_response(payload, None)
except VALID_RPC_EXCEPTIONS as exc:
status, payload = pack_rpc_response(payload, exc)
if self._record is not None:
recording.finish(status, payload)
self._recording.append(recording)
if self.connection_interrupted:
self._try_reconnect()
return unpack_rpc_response(status, payload, rpc_id, address) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:__xml_scan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:node; 5, identifier:env; 6, identifier:path; 7, identifier:arg; 8, block; 8, 9; 8, 25; 8, 49; 8, 62; 8, 241; 8, 250; 8, 259; 8, 275; 8, 285; 8, 289; 8, 332; 8, 338; 8, 344; 8, 350; 9, if_statement; 9, 10; 9, 22; 10, not_operator; 10, 11; 11, call; 11, 12; 11, 17; 12, attribute; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:os; 15, identifier:path; 16, identifier:isfile; 17, argument_list; 17, 18; 18, call; 18, 19; 18, 20; 19, identifier:str; 20, argument_list; 20, 21; 21, identifier:node; 22, block; 22, 23; 23, return_statement; 23, 24; 24, list:[]; 25, if_statement; 25, 26; 25, 33; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:env; 29, identifier:get; 30, argument_list; 30, 31; 30, 32; 31, string:'DOCBOOK_SCANENT'; 32, string:''; 33, block; 33, 34; 33, 42; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:contents; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:node; 40, identifier:get_text_contents; 41, argument_list; 42, return_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:sentity_re; 46, identifier:findall; 47, argument_list; 47, 48; 48, identifier:contents; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:xsl_file; 52, call; 52, 53; 52, 58; 53, attribute; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:os; 56, identifier:path; 57, identifier:join; 58, argument_list; 58, 59; 58, 60; 58, 61; 59, identifier:scriptpath; 60, string:'utils'; 61, string:'xmldepend.xsl'; 62, if_statement; 62, 63; 62, 67; 63, boolean_operator:or; 63, 64; 63, 66; 64, not_operator; 64, 65; 65, identifier:has_libxml2; 66, identifier:prefer_xsltproc; 67, block; 67, 68; 68, if_statement; 68, 69; 68, 73; 68, 146; 69, boolean_operator:and; 69, 70; 69, 71; 70, identifier:has_lxml; 71, not_operator; 71, 72; 72, identifier:prefer_xsltproc; 73, block; 73, 74; 73, 79; 73, 88; 73, 100; 73, 109; 73, 144; 74, import_from_statement; 74, 75; 74, 77; 75, dotted_name; 75, 76; 76, identifier:lxml; 77, dotted_name; 77, 78; 78, identifier:etree; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:xsl_tree; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:etree; 85, identifier:parse; 86, argument_list; 86, 87; 87, identifier:xsl_file; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:doc; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:etree; 94, identifier:parse; 95, argument_list; 95, 96; 96, call; 96, 97; 96, 98; 97, identifier:str; 98, argument_list; 98, 99; 99, identifier:node; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:result; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:doc; 106, identifier:xslt; 107, argument_list; 107, 108; 108, identifier:xsl_tree; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:depfiles; 112, list_comprehension; 112, 113; 112, 118; 112, 128; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:x; 116, identifier:strip; 117, argument_list; 118, for_in_clause; 118, 119; 118, 120; 119, identifier:x; 120, call; 120, 121; 120, 127; 121, attribute; 121, 122; 121, 126; 122, call; 122, 123; 122, 124; 123, identifier:str; 124, argument_list; 124, 125; 125, identifier:result; 126, identifier:splitlines; 127, argument_list; 128, if_clause; 128, 129; 129, boolean_operator:and; 129, 130; 129, 137; 130, comparison_operator:!=; 130, 131; 130, 136; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:x; 134, identifier:strip; 135, argument_list; 136, string:""; 137, not_operator; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:x; 141, identifier:startswith; 142, argument_list; 142, 143; 143, string:"<?xml "; 144, return_statement; 144, 145; 145, identifier:depfiles; 146, else_clause; 146, 147; 147, block; 147, 148; 147, 157; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:xsltproc; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:env; 154, identifier:subst; 155, argument_list; 155, 156; 156, string:"$DOCBOOK_XSLTPROC"; 157, if_statement; 157, 158; 157, 166; 157, 224; 158, boolean_operator:and; 158, 159; 158, 160; 159, identifier:xsltproc; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:xsltproc; 163, identifier:endswith; 164, argument_list; 164, 165; 165, string:'xsltproc'; 166, block; 166, 167; 166, 187; 166, 222; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:result; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:env; 173, identifier:backtick; 174, argument_list; 174, 175; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, string:' '; 178, identifier:join; 179, argument_list; 179, 180; 180, list:[xsltproc, xsl_file, str(node)]; 180, 181; 180, 182; 180, 183; 181, identifier:xsltproc; 182, identifier:xsl_file; 183, call; 183, 184; 183, 185; 184, identifier:str; 185, argument_list; 185, 186; 186, identifier:node; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 190; 189, identifier:depfiles; 190, list_comprehension; 190, 191; 190, 196; 190, 206; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:x; 194, identifier:strip; 195, argument_list; 196, for_in_clause; 196, 197; 196, 198; 197, identifier:x; 198, call; 198, 199; 198, 205; 199, attribute; 199, 200; 199, 204; 200, call; 200, 201; 200, 202; 201, identifier:str; 202, argument_list; 202, 203; 203, identifier:result; 204, identifier:splitlines; 205, argument_list; 206, if_clause; 206, 207; 207, boolean_operator:and; 207, 208; 207, 215; 208, comparison_operator:!=; 208, 209; 208, 214; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:x; 212, identifier:strip; 213, argument_list; 214, string:""; 215, not_operator; 215, 216; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:x; 219, identifier:startswith; 220, argument_list; 220, 221; 221, string:"<?xml "; 222, return_statement; 222, 223; 223, identifier:depfiles; 224, else_clause; 224, 225; 225, block; 225, 226; 225, 234; 226, expression_statement; 226, 227; 227, assignment; 227, 228; 227, 229; 228, identifier:contents; 229, call; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:node; 232, identifier:get_text_contents; 233, argument_list; 234, return_statement; 234, 235; 235, call; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:include_re; 238, identifier:findall; 239, argument_list; 239, 240; 240, identifier:contents; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:styledoc; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:libxml2; 247, identifier:parseFile; 248, argument_list; 248, 249; 249, identifier:xsl_file; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:style; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:libxslt; 256, identifier:parseStylesheetDoc; 257, argument_list; 257, 258; 258, identifier:styledoc; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 262; 261, identifier:doc; 262, call; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, identifier:libxml2; 265, identifier:readFile; 266, argument_list; 266, 267; 266, 271; 266, 272; 267, call; 267, 268; 267, 269; 268, identifier:str; 269, argument_list; 269, 270; 270, identifier:node; 271, None; 272, attribute; 272, 273; 272, 274; 273, identifier:libxml2; 274, identifier:XML_PARSE_NOENT; 275, expression_statement; 275, 276; 276, assignment; 276, 277; 276, 278; 277, identifier:result; 278, call; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:style; 281, identifier:applyStylesheet; 282, argument_list; 282, 283; 282, 284; 283, identifier:doc; 284, None; 285, expression_statement; 285, 286; 286, assignment; 286, 287; 286, 288; 287, identifier:depfiles; 288, list:[]; 289, for_statement; 289, 290; 289, 291; 289, 299; 290, identifier:x; 291, call; 291, 292; 291, 298; 292, attribute; 292, 293; 292, 297; 293, call; 293, 294; 293, 295; 294, identifier:str; 295, argument_list; 295, 296; 296, identifier:result; 297, identifier:splitlines; 298, argument_list; 299, block; 299, 300; 300, if_statement; 300, 301; 300, 316; 301, boolean_operator:and; 301, 302; 301, 309; 302, comparison_operator:!=; 302, 303; 302, 308; 303, call; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, identifier:x; 306, identifier:strip; 307, argument_list; 308, string:""; 309, not_operator; 309, 310; 310, call; 310, 311; 310, 314; 311, attribute; 311, 312; 311, 313; 312, identifier:x; 313, identifier:startswith; 314, argument_list; 314, 315; 315, string:"<?xml "; 316, block; 316, 317; 317, expression_statement; 317, 318; 318, call; 318, 319; 318, 322; 319, attribute; 319, 320; 319, 321; 320, identifier:depfiles; 321, identifier:extend; 322, argument_list; 322, 323; 323, call; 323, 324; 323, 331; 324, attribute; 324, 325; 324, 330; 325, call; 325, 326; 325, 329; 326, attribute; 326, 327; 326, 328; 327, identifier:x; 328, identifier:strip; 329, argument_list; 330, identifier:split; 331, argument_list; 332, expression_statement; 332, 333; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:style; 336, identifier:freeStylesheet; 337, argument_list; 338, expression_statement; 338, 339; 339, call; 339, 340; 339, 343; 340, attribute; 340, 341; 340, 342; 341, identifier:doc; 342, identifier:freeDoc; 343, argument_list; 344, expression_statement; 344, 345; 345, call; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:result; 348, identifier:freeDoc; 349, argument_list; 350, return_statement; 350, 351; 351, identifier:depfiles | def __xml_scan(node, env, path, arg):
if not os.path.isfile(str(node)):
return []
if env.get('DOCBOOK_SCANENT',''):
contents = node.get_text_contents()
return sentity_re.findall(contents)
xsl_file = os.path.join(scriptpath,'utils','xmldepend.xsl')
if not has_libxml2 or prefer_xsltproc:
if has_lxml and not prefer_xsltproc:
from lxml import etree
xsl_tree = etree.parse(xsl_file)
doc = etree.parse(str(node))
result = doc.xslt(xsl_tree)
depfiles = [x.strip() for x in str(result).splitlines() if x.strip() != "" and not x.startswith("<?xml ")]
return depfiles
else:
xsltproc = env.subst("$DOCBOOK_XSLTPROC")
if xsltproc and xsltproc.endswith('xsltproc'):
result = env.backtick(' '.join([xsltproc, xsl_file, str(node)]))
depfiles = [x.strip() for x in str(result).splitlines() if x.strip() != "" and not x.startswith("<?xml ")]
return depfiles
else:
contents = node.get_text_contents()
return include_re.findall(contents)
styledoc = libxml2.parseFile(xsl_file)
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.readFile(str(node), None, libxml2.XML_PARSE_NOENT)
result = style.applyStylesheet(doc, None)
depfiles = []
for x in str(result).splitlines():
if x.strip() != "" and not x.startswith("<?xml "):
depfiles.extend(x.strip().split())
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()
return depfiles |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:DocbookMan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 11; 4, identifier:env; 5, identifier:target; 6, default_parameter; 6, 7; 6, 8; 7, identifier:source; 8, None; 9, list_splat_pattern; 9, 10; 10, identifier:args; 11, dictionary_splat_pattern; 11, 12; 12, identifier:kw; 13, block; 13, 14; 13, 24; 13, 34; 13, 43; 13, 47; 13, 366; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 19; 16, pattern_list; 16, 17; 16, 18; 17, identifier:target; 18, identifier:source; 19, call; 19, 20; 19, 21; 20, identifier:__extend_targets_sources; 21, argument_list; 21, 22; 21, 23; 22, identifier:target; 23, identifier:source; 24, expression_statement; 24, 25; 25, call; 25, 26; 25, 27; 26, identifier:__init_xsl_stylesheet; 27, argument_list; 27, 28; 27, 29; 27, 30; 27, 31; 28, identifier:kw; 29, identifier:env; 30, string:'$DOCBOOK_DEFAULT_XSL_MAN'; 31, list:['manpages','docbook.xsl']; 31, 32; 31, 33; 32, string:'manpages'; 33, string:'docbook.xsl'; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:__builder; 37, call; 37, 38; 37, 39; 38, identifier:__select_builder; 39, argument_list; 39, 40; 39, 41; 39, 42; 40, identifier:__lxml_builder; 41, identifier:__libxml2_builder; 42, identifier:__xsltproc_builder; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:result; 46, list:[]; 47, for_statement; 47, 48; 47, 51; 47, 56; 48, pattern_list; 48, 49; 48, 50; 49, identifier:t; 50, identifier:s; 51, call; 51, 52; 51, 53; 52, identifier:zip; 53, argument_list; 53, 54; 53, 55; 54, identifier:target; 55, identifier:source; 56, block; 56, 57; 56, 61; 56, 65; 56, 76; 56, 310; 56, 323; 56, 335; 56, 344; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:volnum; 60, string:"1"; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:outfiles; 64, list:[]; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:srcfile; 68, call; 68, 69; 68, 70; 69, identifier:__ensure_suffix; 70, argument_list; 70, 71; 70, 75; 71, call; 71, 72; 71, 73; 72, identifier:str; 73, argument_list; 73, 74; 74, identifier:s; 75, string:'.xml'; 76, if_statement; 76, 77; 76, 85; 76, 301; 77, call; 77, 78; 77, 83; 78, attribute; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:os; 81, identifier:path; 82, identifier:isfile; 83, argument_list; 83, 84; 84, identifier:srcfile; 85, block; 85, 86; 85, 244; 86, try_statement; 86, 87; 86, 170; 87, block; 87, 88; 87, 93; 87, 113; 87, 138; 88, import_statement; 88, 89; 89, dotted_name; 89, 90; 89, 91; 89, 92; 90, identifier:xml; 91, identifier:dom; 92, identifier:minidom; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:dom; 96, call; 96, 97; 96, 104; 97, attribute; 97, 98; 97, 103; 98, attribute; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:xml; 101, identifier:dom; 102, identifier:minidom; 103, identifier:parse; 104, argument_list; 104, 105; 105, call; 105, 106; 105, 107; 106, identifier:__ensure_suffix; 107, argument_list; 107, 108; 107, 112; 108, call; 108, 109; 108, 110; 109, identifier:str; 110, argument_list; 110, 111; 111, identifier:s; 112, string:'.xml'; 113, for_statement; 113, 114; 113, 115; 113, 121; 114, identifier:node; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:dom; 118, identifier:getElementsByTagName; 119, argument_list; 119, 120; 120, string:'refmeta'; 121, block; 121, 122; 122, for_statement; 122, 123; 122, 124; 122, 130; 123, identifier:vol; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:node; 127, identifier:getElementsByTagName; 128, argument_list; 128, 129; 129, string:'manvolnum'; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:volnum; 134, call; 134, 135; 134, 136; 135, identifier:__get_xml_text; 136, argument_list; 136, 137; 137, identifier:vol; 138, for_statement; 138, 139; 138, 140; 138, 146; 139, identifier:node; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:dom; 143, identifier:getElementsByTagName; 144, argument_list; 144, 145; 145, string:'refnamediv'; 146, block; 146, 147; 147, for_statement; 147, 148; 147, 149; 147, 155; 148, identifier:ref; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:node; 152, identifier:getElementsByTagName; 153, argument_list; 153, 154; 154, string:'refname'; 155, block; 155, 156; 156, expression_statement; 156, 157; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:outfiles; 160, identifier:append; 161, argument_list; 161, 162; 162, binary_operator:+; 162, 163; 162, 169; 163, binary_operator:+; 163, 164; 163, 168; 164, call; 164, 165; 164, 166; 165, identifier:__get_xml_text; 166, argument_list; 166, 167; 167, identifier:ref; 168, string:'.'; 169, identifier:volnum; 170, except_clause; 170, 171; 171, block; 171, 172; 171, 187; 171, 195; 171, 201; 171, 219; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:f; 175, call; 175, 176; 175, 177; 176, identifier:open; 177, argument_list; 177, 178; 177, 186; 178, call; 178, 179; 178, 180; 179, identifier:__ensure_suffix; 180, argument_list; 180, 181; 180, 185; 181, call; 181, 182; 181, 183; 182, identifier:str; 183, argument_list; 183, 184; 184, identifier:s; 185, string:'.xml'; 186, string:'r'; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 190; 189, identifier:content; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:f; 193, identifier:read; 194, argument_list; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:f; 199, identifier:close; 200, argument_list; 201, for_statement; 201, 202; 201, 203; 201, 209; 202, identifier:m; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:re_manvolnum; 206, identifier:finditer; 207, argument_list; 207, 208; 208, identifier:content; 209, block; 209, 210; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:volnum; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:m; 216, identifier:group; 217, argument_list; 217, 218; 218, integer:1; 219, for_statement; 219, 220; 219, 221; 219, 227; 220, identifier:m; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:re_refname; 224, identifier:finditer; 225, argument_list; 225, 226; 226, identifier:content; 227, block; 227, 228; 228, expression_statement; 228, 229; 229, call; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:outfiles; 232, identifier:append; 233, argument_list; 233, 234; 234, binary_operator:+; 234, 235; 234, 243; 235, binary_operator:+; 235, 236; 235, 242; 236, call; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:m; 239, identifier:group; 240, argument_list; 240, 241; 241, integer:1; 242, string:'.'; 243, identifier:volnum; 244, if_statement; 244, 245; 244, 247; 245, not_operator; 245, 246; 246, identifier:outfiles; 247, block; 247, 248; 247, 255; 248, expression_statement; 248, 249; 249, assignment; 249, 250; 249, 251; 250, identifier:spath; 251, call; 251, 252; 251, 253; 252, identifier:str; 253, argument_list; 253, 254; 254, identifier:s; 255, if_statement; 255, 256; 255, 263; 255, 275; 256, not_operator; 256, 257; 257, call; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:spath; 260, identifier:endswith; 261, argument_list; 261, 262; 262, string:'.xml'; 263, block; 263, 264; 264, expression_statement; 264, 265; 265, call; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:outfiles; 268, identifier:append; 269, argument_list; 269, 270; 270, binary_operator:+; 270, 271; 270, 274; 271, binary_operator:+; 271, 272; 271, 273; 272, identifier:spath; 273, string:'.'; 274, identifier:volnum; 275, else_clause; 275, 276; 276, block; 276, 277; 276, 290; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 282; 279, pattern_list; 279, 280; 279, 281; 280, identifier:stem; 281, identifier:ext; 282, call; 282, 283; 282, 288; 283, attribute; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:os; 286, identifier:path; 287, identifier:splitext; 288, argument_list; 288, 289; 289, identifier:spath; 290, expression_statement; 290, 291; 291, call; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:outfiles; 294, identifier:append; 295, argument_list; 295, 296; 296, binary_operator:+; 296, 297; 296, 300; 297, binary_operator:+; 297, 298; 297, 299; 298, identifier:stem; 299, string:'.'; 300, identifier:volnum; 301, else_clause; 301, 302; 302, block; 302, 303; 303, expression_statement; 303, 304; 304, call; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:outfiles; 307, identifier:append; 308, argument_list; 308, 309; 309, identifier:t; 310, expression_statement; 310, 311; 311, call; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:__builder; 314, identifier:__call__; 315, argument_list; 315, 316; 315, 317; 315, 320; 315, 321; 316, identifier:env; 317, subscript; 317, 318; 317, 319; 318, identifier:outfiles; 319, integer:0; 320, identifier:s; 321, dictionary_splat; 321, 322; 322, identifier:kw; 323, expression_statement; 323, 324; 324, call; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:env; 327, identifier:Depends; 328, argument_list; 328, 329; 328, 332; 329, subscript; 329, 330; 329, 331; 330, identifier:outfiles; 331, integer:0; 332, subscript; 332, 333; 332, 334; 333, identifier:kw; 334, string:'DOCBOOK_XSL'; 335, expression_statement; 335, 336; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:result; 339, identifier:append; 340, argument_list; 340, 341; 341, subscript; 341, 342; 341, 343; 342, identifier:outfiles; 343, integer:0; 344, if_statement; 344, 345; 344, 351; 345, comparison_operator:>; 345, 346; 345, 350; 346, call; 346, 347; 346, 348; 347, identifier:len; 348, argument_list; 348, 349; 349, identifier:outfiles; 350, integer:1; 351, block; 351, 352; 352, expression_statement; 352, 353; 353, call; 353, 354; 353, 357; 354, attribute; 354, 355; 354, 356; 355, identifier:env; 356, identifier:Clean; 357, argument_list; 357, 358; 357, 361; 358, subscript; 358, 359; 358, 360; 359, identifier:outfiles; 360, integer:0; 361, subscript; 361, 362; 361, 363; 362, identifier:outfiles; 363, slice; 363, 364; 363, 365; 364, integer:1; 365, colon; 366, return_statement; 366, 367; 367, identifier:result | def DocbookMan(env, target, source=None, *args, **kw):
target, source = __extend_targets_sources(target, source)
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_MAN', ['manpages','docbook.xsl'])
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
result = []
for t,s in zip(target,source):
volnum = "1"
outfiles = []
srcfile = __ensure_suffix(str(s),'.xml')
if os.path.isfile(srcfile):
try:
import xml.dom.minidom
dom = xml.dom.minidom.parse(__ensure_suffix(str(s),'.xml'))
for node in dom.getElementsByTagName('refmeta'):
for vol in node.getElementsByTagName('manvolnum'):
volnum = __get_xml_text(vol)
for node in dom.getElementsByTagName('refnamediv'):
for ref in node.getElementsByTagName('refname'):
outfiles.append(__get_xml_text(ref)+'.'+volnum)
except:
f = open(__ensure_suffix(str(s),'.xml'), 'r')
content = f.read()
f.close()
for m in re_manvolnum.finditer(content):
volnum = m.group(1)
for m in re_refname.finditer(content):
outfiles.append(m.group(1)+'.'+volnum)
if not outfiles:
spath = str(s)
if not spath.endswith('.xml'):
outfiles.append(spath+'.'+volnum)
else:
stem, ext = os.path.splitext(spath)
outfiles.append(stem+'.'+volnum)
else:
outfiles.append(t)
__builder.__call__(env, outfiles[0], s, **kw)
env.Depends(outfiles[0], kw['DOCBOOK_XSL'])
result.append(outfiles[0])
if len(outfiles) > 1:
env.Clean(outfiles[0], outfiles[1:])
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:Builder; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:kw; 6, block; 6, 7; 6, 11; 6, 133; 6, 223; 6, 231; 6, 245; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:composite; 10, None; 11, if_statement; 11, 12; 11, 15; 11, 46; 12, comparison_operator:in; 12, 13; 12, 14; 13, string:'generator'; 14, identifier:kw; 15, block; 15, 16; 15, 26; 15, 42; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:in; 17, 18; 17, 19; 18, string:'action'; 19, identifier:kw; 20, block; 20, 21; 21, raise_statement; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:UserError; 24, argument_list; 24, 25; 25, string:"You must not specify both an action and a generator."; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 31; 28, subscript; 28, 29; 28, 30; 29, identifier:kw; 30, string:'action'; 31, call; 31, 32; 31, 37; 32, attribute; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:SCons; 35, identifier:Action; 36, identifier:CommandGeneratorAction; 37, argument_list; 37, 38; 37, 41; 38, subscript; 38, 39; 38, 40; 39, identifier:kw; 40, string:'generator'; 41, dictionary; 42, delete_statement; 42, 43; 43, subscript; 43, 44; 43, 45; 44, identifier:kw; 45, string:'generator'; 46, elif_clause; 46, 47; 46, 50; 47, comparison_operator:in; 47, 48; 47, 49; 48, string:'action'; 49, identifier:kw; 50, block; 50, 51; 50, 61; 50, 70; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:source_ext_match; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:kw; 57, identifier:get; 58, argument_list; 58, 59; 58, 60; 59, string:'source_ext_match'; 60, integer:1; 61, if_statement; 61, 62; 61, 65; 62, comparison_operator:in; 62, 63; 62, 64; 63, string:'source_ext_match'; 64, identifier:kw; 65, block; 65, 66; 66, delete_statement; 66, 67; 67, subscript; 67, 68; 67, 69; 68, identifier:kw; 69, string:'source_ext_match'; 70, if_statement; 70, 71; 70, 81; 70, 116; 71, call; 71, 72; 71, 77; 72, attribute; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:SCons; 75, identifier:Util; 76, identifier:is_Dict; 77, argument_list; 77, 78; 78, subscript; 78, 79; 78, 80; 79, identifier:kw; 80, string:'action'; 81, block; 81, 82; 81, 92; 81, 106; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:composite; 85, call; 85, 86; 85, 87; 86, identifier:DictCmdGenerator; 87, argument_list; 87, 88; 87, 91; 88, subscript; 88, 89; 88, 90; 89, identifier:kw; 90, string:'action'; 91, identifier:source_ext_match; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, subscript; 94, 95; 94, 96; 95, identifier:kw; 96, string:'action'; 97, call; 97, 98; 97, 103; 98, attribute; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:SCons; 101, identifier:Action; 102, identifier:CommandGeneratorAction; 103, argument_list; 103, 104; 103, 105; 104, identifier:composite; 105, dictionary; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 111; 108, subscript; 108, 109; 108, 110; 109, identifier:kw; 110, string:'src_suffix'; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:composite; 114, identifier:src_suffixes; 115, argument_list; 116, else_clause; 116, 117; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:kw; 122, string:'action'; 123, call; 123, 124; 123, 129; 124, attribute; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:SCons; 127, identifier:Action; 128, identifier:Action; 129, argument_list; 129, 130; 130, subscript; 130, 131; 130, 132; 131, identifier:kw; 132, string:'action'; 133, if_statement; 133, 134; 133, 137; 134, comparison_operator:in; 134, 135; 134, 136; 135, string:'emitter'; 136, identifier:kw; 137, block; 137, 138; 137, 144; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:emitter; 141, subscript; 141, 142; 141, 143; 142, identifier:kw; 143, string:'emitter'; 144, if_statement; 144, 145; 144, 153; 144, 185; 144, 204; 145, call; 145, 146; 145, 151; 146, attribute; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:SCons; 149, identifier:Util; 150, identifier:is_String; 151, argument_list; 151, 152; 152, identifier:emitter; 153, block; 153, 154; 153, 165; 153, 176; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:var; 157, call; 157, 158; 157, 163; 158, attribute; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:SCons; 161, identifier:Util; 162, identifier:get_environment_var; 163, argument_list; 163, 164; 164, identifier:emitter; 165, if_statement; 165, 166; 165, 168; 166, not_operator; 166, 167; 167, identifier:var; 168, block; 168, 169; 169, raise_statement; 169, 170; 170, call; 170, 171; 170, 172; 171, identifier:UserError; 172, argument_list; 172, 173; 173, binary_operator:%; 173, 174; 173, 175; 174, string:"Supplied emitter '%s' does not appear to refer to an Environment variable"; 175, identifier:emitter; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 181; 178, subscript; 178, 179; 178, 180; 179, identifier:kw; 180, string:'emitter'; 181, call; 181, 182; 181, 183; 182, identifier:EmitterProxy; 183, argument_list; 183, 184; 184, identifier:var; 185, elif_clause; 185, 186; 185, 194; 186, call; 186, 187; 186, 192; 187, attribute; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:SCons; 190, identifier:Util; 191, identifier:is_Dict; 192, argument_list; 192, 193; 193, identifier:emitter; 194, block; 194, 195; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 200; 197, subscript; 197, 198; 197, 199; 198, identifier:kw; 199, string:'emitter'; 200, call; 200, 201; 200, 202; 201, identifier:DictEmitter; 202, argument_list; 202, 203; 203, identifier:emitter; 204, elif_clause; 204, 205; 204, 213; 205, call; 205, 206; 205, 211; 206, attribute; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:SCons; 209, identifier:Util; 210, identifier:is_List; 211, argument_list; 211, 212; 212, identifier:emitter; 213, block; 213, 214; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 219; 216, subscript; 216, 217; 216, 218; 217, identifier:kw; 218, string:'emitter'; 219, call; 219, 220; 219, 221; 220, identifier:ListEmitter; 221, argument_list; 221, 222; 222, identifier:emitter; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:result; 226, call; 226, 227; 226, 228; 227, identifier:BuilderBase; 228, argument_list; 228, 229; 229, dictionary_splat; 229, 230; 230, identifier:kw; 231, if_statement; 231, 232; 231, 236; 232, not_operator; 232, 233; 233, comparison_operator:is; 233, 234; 233, 235; 234, identifier:composite; 235, None; 236, block; 236, 237; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:result; 240, call; 240, 241; 240, 242; 241, identifier:CompositeBuilder; 242, argument_list; 242, 243; 242, 244; 243, identifier:result; 244, identifier:composite; 245, return_statement; 245, 246; 246, identifier:result | def Builder(**kw):
composite = None
if 'generator' in kw:
if 'action' in kw:
raise UserError("You must not specify both an action and a generator.")
kw['action'] = SCons.Action.CommandGeneratorAction(kw['generator'], {})
del kw['generator']
elif 'action' in kw:
source_ext_match = kw.get('source_ext_match', 1)
if 'source_ext_match' in kw:
del kw['source_ext_match']
if SCons.Util.is_Dict(kw['action']):
composite = DictCmdGenerator(kw['action'], source_ext_match)
kw['action'] = SCons.Action.CommandGeneratorAction(composite, {})
kw['src_suffix'] = composite.src_suffixes()
else:
kw['action'] = SCons.Action.Action(kw['action'])
if 'emitter' in kw:
emitter = kw['emitter']
if SCons.Util.is_String(emitter):
var = SCons.Util.get_environment_var(emitter)
if not var:
raise UserError("Supplied emitter '%s' does not appear to refer to an Environment variable" % emitter)
kw['emitter'] = EmitterProxy(var)
elif SCons.Util.is_Dict(emitter):
kw['emitter'] = DictEmitter(emitter)
elif SCons.Util.is_List(emitter):
kw['emitter'] = ListEmitter(emitter)
result = BuilderBase(**kw)
if not composite is None:
result = CompositeBuilder(result, composite)
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_node_errors; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:builder; 5, identifier:env; 6, identifier:tlist; 7, identifier:slist; 8, block; 8, 9; 8, 325; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, identifier:t; 11, identifier:tlist; 12, block; 12, 13; 12, 25; 13, if_statement; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:t; 16, identifier:side_effect; 17, block; 17, 18; 18, raise_statement; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:UserError; 21, argument_list; 21, 22; 22, binary_operator:%; 22, 23; 22, 24; 23, string:"Multiple ways to build the same target were specified for: %s"; 24, identifier:t; 25, if_statement; 25, 26; 25, 31; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:t; 29, identifier:has_explicit_builder; 30, argument_list; 31, block; 31, 32; 31, 201; 32, if_statement; 32, 33; 32, 86; 33, parenthesized_expression; 33, 34; 34, boolean_operator:and; 34, 35; 34, 48; 35, boolean_operator:and; 35, 36; 35, 42; 36, not_operator; 36, 37; 37, comparison_operator:is; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:t; 40, identifier:env; 41, None; 42, not_operator; 42, 43; 43, comparison_operator:is; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:t; 46, identifier:env; 47, identifier:env; 48, not_operator; 48, 49; 49, parenthesized_expression; 49, 50; 50, boolean_operator:and; 50, 51; 50, 82; 51, boolean_operator:and; 51, 52; 51, 67; 52, comparison_operator:is; 52, 53; 52, 61; 53, call; 53, 54; 53, 55; 54, identifier:getattr; 55, argument_list; 55, 56; 55, 59; 55, 60; 56, attribute; 56, 57; 56, 58; 57, identifier:t; 58, identifier:env; 59, string:'__subject'; 60, integer:0; 61, call; 61, 62; 61, 63; 62, identifier:getattr; 63, argument_list; 63, 64; 63, 65; 63, 66; 64, identifier:env; 65, string:'__subject'; 66, integer:1; 67, comparison_operator:==; 67, 68; 67, 76; 68, call; 68, 69; 68, 70; 69, identifier:getattr; 70, argument_list; 70, 71; 70, 74; 70, 75; 71, attribute; 71, 72; 71, 73; 72, identifier:t; 73, identifier:env; 74, string:'overrides'; 75, integer:0; 76, call; 76, 77; 76, 78; 77, identifier:getattr; 78, argument_list; 78, 79; 78, 80; 78, 81; 79, identifier:env; 80, string:'overrides'; 81, integer:1; 82, not_operator; 82, 83; 83, attribute; 83, 84; 83, 85; 84, identifier:builder; 85, identifier:multi; 86, block; 86, 87; 86, 95; 86, 112; 86, 125; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:action; 90, attribute; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:t; 93, identifier:builder; 94, identifier:action; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:t_contents; 98, call; 98, 99; 98, 106; 99, attribute; 99, 100; 99, 105; 100, attribute; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:t; 103, identifier:builder; 104, identifier:action; 105, identifier:get_contents; 106, argument_list; 106, 107; 106, 108; 106, 109; 107, identifier:tlist; 108, identifier:slist; 109, attribute; 109, 110; 109, 111; 110, identifier:t; 111, identifier:env; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:contents; 115, call; 115, 116; 115, 121; 116, attribute; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:builder; 119, identifier:action; 120, identifier:get_contents; 121, argument_list; 121, 122; 121, 123; 121, 124; 122, identifier:tlist; 123, identifier:slist; 124, identifier:env; 125, if_statement; 125, 126; 125, 129; 125, 161; 126, comparison_operator:==; 126, 127; 126, 128; 127, identifier:t_contents; 128, identifier:contents; 129, block; 129, 130; 129, 147; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:msg; 133, binary_operator:%; 133, 134; 133, 135; 134, string:"Two different environments were specified for target %s,\n\tbut they appear to have the same action: %s"; 135, tuple; 135, 136; 135, 137; 136, identifier:t; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:action; 140, identifier:genstring; 141, argument_list; 141, 142; 141, 143; 141, 144; 142, identifier:tlist; 143, identifier:slist; 144, attribute; 144, 145; 144, 146; 145, identifier:t; 146, identifier:env; 147, expression_statement; 147, 148; 148, call; 148, 149; 148, 154; 149, attribute; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:SCons; 152, identifier:Warnings; 153, identifier:warn; 154, argument_list; 154, 155; 154, 160; 155, attribute; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:SCons; 158, identifier:Warnings; 159, identifier:DuplicateEnvironmentWarning; 160, identifier:msg; 161, else_clause; 161, 162; 162, block; 162, 163; 162, 196; 163, try_statement; 163, 164; 163, 184; 164, block; 164, 165; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:msg; 168, binary_operator:%; 168, 169; 168, 170; 169, string:"Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)"; 170, tuple; 170, 171; 170, 172; 170, 178; 171, identifier:t; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:t_contents; 175, identifier:decode; 176, argument_list; 176, 177; 177, string:'utf-8'; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:contents; 181, identifier:decode; 182, argument_list; 182, 183; 183, string:'utf-8'; 184, except_clause; 184, 185; 184, 189; 185, as_pattern; 185, 186; 185, 187; 186, identifier:UnicodeDecodeError; 187, as_pattern_target; 187, 188; 188, identifier:e; 189, block; 189, 190; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:msg; 193, binary_operator:%; 193, 194; 193, 195; 194, string:"Two environments with different actions were specified for the same target: %s"; 195, identifier:t; 196, raise_statement; 196, 197; 197, call; 197, 198; 197, 199; 198, identifier:UserError; 199, argument_list; 199, 200; 200, identifier:msg; 201, if_statement; 201, 202; 201, 205; 201, 288; 202, attribute; 202, 203; 202, 204; 203, identifier:builder; 204, identifier:multi; 205, block; 205, 206; 205, 239; 206, if_statement; 206, 207; 206, 212; 207, comparison_operator:!=; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:t; 210, identifier:builder; 211, identifier:builder; 212, block; 212, 213; 212, 234; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 216; 215, identifier:msg; 216, binary_operator:%; 216, 217; 216, 218; 217, string:"Two different builders (%s and %s) were specified for the same target: %s"; 218, tuple; 218, 219; 218, 227; 218, 233; 219, call; 219, 220; 219, 225; 220, attribute; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:t; 223, identifier:builder; 224, identifier:get_name; 225, argument_list; 225, 226; 226, identifier:env; 227, call; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:builder; 230, identifier:get_name; 231, argument_list; 231, 232; 232, identifier:env; 233, identifier:t; 234, raise_statement; 234, 235; 235, call; 235, 236; 235, 237; 236, identifier:UserError; 237, argument_list; 237, 238; 238, identifier:msg; 239, if_statement; 239, 240; 239, 251; 240, comparison_operator:!=; 240, 241; 240, 250; 241, call; 241, 242; 241, 249; 242, attribute; 242, 243; 242, 248; 243, call; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:t; 246, identifier:get_executor; 247, argument_list; 248, identifier:get_all_targets; 249, argument_list; 250, identifier:tlist; 251, block; 251, 252; 251, 283; 252, expression_statement; 252, 253; 253, assignment; 253, 254; 253, 255; 254, identifier:msg; 255, binary_operator:%; 255, 256; 255, 257; 256, string:"Two different target lists have a target in common: %s (from %s and from %s)"; 257, tuple; 257, 258; 257, 259; 257, 275; 258, identifier:t; 259, call; 259, 260; 259, 261; 260, identifier:list; 261, argument_list; 261, 262; 262, call; 262, 263; 262, 264; 263, identifier:map; 264, argument_list; 264, 265; 264, 266; 265, identifier:str; 266, call; 266, 267; 266, 274; 267, attribute; 267, 268; 267, 273; 268, call; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:t; 271, identifier:get_executor; 272, argument_list; 273, identifier:get_all_targets; 274, argument_list; 275, call; 275, 276; 275, 277; 276, identifier:list; 277, argument_list; 277, 278; 278, call; 278, 279; 278, 280; 279, identifier:map; 280, argument_list; 280, 281; 280, 282; 281, identifier:str; 282, identifier:tlist; 283, raise_statement; 283, 284; 284, call; 284, 285; 284, 286; 285, identifier:UserError; 286, argument_list; 286, 287; 287, identifier:msg; 288, elif_clause; 288, 289; 288, 294; 289, comparison_operator:!=; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:t; 292, identifier:sources; 293, identifier:slist; 294, block; 294, 295; 294, 320; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:msg; 298, binary_operator:%; 298, 299; 298, 300; 299, string:"Multiple ways to build the same target were specified for: %s (from %s and from %s)"; 300, tuple; 300, 301; 300, 302; 300, 312; 301, identifier:t; 302, call; 302, 303; 302, 304; 303, identifier:list; 304, argument_list; 304, 305; 305, call; 305, 306; 305, 307; 306, identifier:map; 307, argument_list; 307, 308; 307, 309; 308, identifier:str; 309, attribute; 309, 310; 309, 311; 310, identifier:t; 311, identifier:sources; 312, call; 312, 313; 312, 314; 313, identifier:list; 314, argument_list; 314, 315; 315, call; 315, 316; 315, 317; 316, identifier:map; 317, argument_list; 317, 318; 317, 319; 318, identifier:str; 319, identifier:slist; 320, raise_statement; 320, 321; 321, call; 321, 322; 321, 323; 322, identifier:UserError; 323, argument_list; 323, 324; 324, identifier:msg; 325, if_statement; 325, 326; 325, 329; 326, attribute; 326, 327; 326, 328; 327, identifier:builder; 328, identifier:single_source; 329, block; 329, 330; 330, if_statement; 330, 331; 330, 337; 331, comparison_operator:>; 331, 332; 331, 336; 332, call; 332, 333; 332, 334; 333, identifier:len; 334, argument_list; 334, 335; 335, identifier:slist; 336, integer:1; 337, block; 337, 338; 338, raise_statement; 338, 339; 339, call; 339, 340; 339, 341; 340, identifier:UserError; 341, argument_list; 341, 342; 342, binary_operator:%; 342, 343; 342, 344; 343, string:"More than one source given for single-source builder: targets=%s sources=%s"; 344, tuple; 344, 345; 344, 353; 345, call; 345, 346; 345, 347; 346, identifier:list; 347, argument_list; 347, 348; 348, call; 348, 349; 348, 350; 349, identifier:map; 350, argument_list; 350, 351; 350, 352; 351, identifier:str; 352, identifier:tlist; 353, call; 353, 354; 353, 355; 354, identifier:list; 355, argument_list; 355, 356; 356, call; 356, 357; 356, 358; 357, identifier:map; 358, argument_list; 358, 359; 358, 360; 359, identifier:str; 360, identifier:slist | def _node_errors(builder, env, tlist, slist):
for t in tlist:
if t.side_effect:
raise UserError("Multiple ways to build the same target were specified for: %s" % t)
if t.has_explicit_builder():
if (not t.env is None and not t.env is env and
not (getattr(t.env, '__subject', 0) is getattr(env, '__subject', 1) and
getattr(t.env, 'overrides', 0) == getattr(env, 'overrides', 1) and
not builder.multi)):
action = t.builder.action
t_contents = t.builder.action.get_contents(tlist, slist, t.env)
contents = builder.action.get_contents(tlist, slist, env)
if t_contents == contents:
msg = "Two different environments were specified for target %s,\n\tbut they appear to have the same action: %s" % (t, action.genstring(tlist, slist, t.env))
SCons.Warnings.warn(SCons.Warnings.DuplicateEnvironmentWarning, msg)
else:
try:
msg = "Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)" % (t,t_contents.decode('utf-8'),contents.decode('utf-8'))
except UnicodeDecodeError as e:
msg = "Two environments with different actions were specified for the same target: %s"%t
raise UserError(msg)
if builder.multi:
if t.builder != builder:
msg = "Two different builders (%s and %s) were specified for the same target: %s" % (t.builder.get_name(env), builder.get_name(env), t)
raise UserError(msg)
if t.get_executor().get_all_targets() != tlist:
msg = "Two different target lists have a target in common: %s (from %s and from %s)" % (t, list(map(str, t.get_executor().get_all_targets())), list(map(str, tlist)))
raise UserError(msg)
elif t.sources != slist:
msg = "Multiple ways to build the same target were specified for: %s (from %s and from %s)" % (t, list(map(str, t.sources)), list(map(str, slist)))
raise UserError(msg)
if builder.single_source:
if len(slist) > 1:
raise UserError("More than one source given for single-source builder: targets=%s sources=%s" % (list(map(str,tlist)), list(map(str,slist)))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_order_pases; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:passes; 6, block; 6, 7; 6, 14; 6, 18; 6, 91; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:passes; 10, call; 10, 11; 10, 12; 11, identifier:set; 12, argument_list; 12, 13; 13, identifier:passes; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:pass_deps; 17, dictionary; 18, for_statement; 18, 19; 18, 20; 18, 21; 19, identifier:opt; 20, identifier:passes; 21, block; 21, 22; 21, 33; 21, 46; 21, 59; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 28; 24, pattern_list; 24, 25; 24, 26; 24, 27; 25, identifier:_; 26, identifier:before; 27, identifier:after; 28, subscript; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:_known_passes; 32, identifier:opt; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:not; 34, 35; 34, 36; 35, identifier:opt; 36, identifier:pass_deps; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 43; 40, subscript; 40, 41; 40, 42; 41, identifier:pass_deps; 42, identifier:opt; 43, call; 43, 44; 43, 45; 44, identifier:set; 45, argument_list; 46, for_statement; 46, 47; 46, 48; 46, 49; 47, identifier:after_pass; 48, identifier:after; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, call; 51, 52; 51, 57; 52, attribute; 52, 53; 52, 56; 53, subscript; 53, 54; 53, 55; 54, identifier:pass_deps; 55, identifier:opt; 56, identifier:add; 57, argument_list; 57, 58; 58, identifier:after_pass; 59, for_statement; 59, 60; 59, 61; 59, 62; 60, identifier:other; 61, identifier:before; 62, block; 62, 63; 62, 69; 62, 82; 63, if_statement; 63, 64; 63, 67; 64, comparison_operator:not; 64, 65; 64, 66; 65, identifier:other; 66, identifier:passes; 67, block; 67, 68; 68, continue_statement; 69, if_statement; 69, 70; 69, 73; 70, comparison_operator:not; 70, 71; 70, 72; 71, identifier:other; 72, identifier:pass_deps; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 79; 76, subscript; 76, 77; 76, 78; 77, identifier:pass_deps; 78, identifier:other; 79, call; 79, 80; 79, 81; 80, identifier:set; 81, argument_list; 82, expression_statement; 82, 83; 83, call; 83, 84; 83, 89; 84, attribute; 84, 85; 84, 88; 85, subscript; 85, 86; 85, 87; 86, identifier:pass_deps; 87, identifier:other; 88, identifier:add; 89, argument_list; 89, 90; 90, identifier:opt; 91, return_statement; 91, 92; 92, call; 92, 93; 92, 94; 93, identifier:toposort_flatten; 94, argument_list; 94, 95; 95, identifier:pass_deps | def _order_pases(self, passes):
passes = set(passes)
pass_deps = {}
for opt in passes:
_, before, after = self._known_passes[opt]
if opt not in pass_deps:
pass_deps[opt] = set()
for after_pass in after:
pass_deps[opt].add(after_pass)
for other in before:
if other not in passes:
continue
if other not in pass_deps:
pass_deps[other] = set()
pass_deps[other].add(opt)
return toposort_flatten(pass_deps) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 34; 5, 40; 5, 66; 5, 78; 5, 84; 5, 90; 6, global_statement; 6, 7; 7, identifier:print_prepare; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:T; 11, attribute; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:tm; 15, identifier:trace; 16, if_statement; 16, 17; 16, 18; 17, identifier:T; 18, block; 18, 19; 19, expression_statement; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:T; 23, identifier:write; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:trace_message; 29, argument_list; 29, 30; 29, 31; 30, string:u'Task.prepare()'; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:node; 34, expression_statement; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:exception_raise; 39, argument_list; 40, if_statement; 40, 41; 40, 46; 41, attribute; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:tm; 45, identifier:message; 46, block; 46, 47; 46, 58; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:display; 52, argument_list; 52, 53; 53, attribute; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:self; 56, identifier:tm; 57, identifier:message; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 65; 60, attribute; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:tm; 64, identifier:message; 65, None; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:executor; 69, call; 69, 70; 69, 77; 70, attribute; 70, 71; 70, 76; 71, subscript; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:targets; 75, integer:0; 76, identifier:get_executor; 77, argument_list; 78, if_statement; 78, 79; 78, 82; 79, comparison_operator:is; 79, 80; 79, 81; 80, identifier:executor; 81, None; 82, block; 82, 83; 83, return_statement; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:executor; 88, identifier:prepare; 89, argument_list; 90, for_statement; 90, 91; 90, 92; 90, 97; 91, identifier:t; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:executor; 95, identifier:get_action_targets; 96, argument_list; 97, block; 97, 98; 97, 121; 97, 127; 98, if_statement; 98, 99; 98, 100; 99, identifier:print_prepare; 100, block; 100, 101; 100, 108; 101, expression_statement; 101, 102; 102, call; 102, 103; 102, 104; 103, identifier:print; 104, argument_list; 104, 105; 105, binary_operator:%; 105, 106; 105, 107; 106, string:"Preparing target %s..."; 107, identifier:t; 108, for_statement; 108, 109; 108, 110; 108, 113; 109, identifier:s; 110, attribute; 110, 111; 110, 112; 111, identifier:t; 112, identifier:side_effects; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:print; 117, argument_list; 117, 118; 118, binary_operator:%; 118, 119; 118, 120; 119, string:"...with side-effect %s..."; 120, identifier:s; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:t; 125, identifier:prepare; 126, argument_list; 127, for_statement; 127, 128; 127, 129; 127, 132; 128, identifier:s; 129, attribute; 129, 130; 129, 131; 130, identifier:t; 131, identifier:side_effects; 132, block; 132, 133; 132, 143; 133, if_statement; 133, 134; 133, 135; 134, identifier:print_prepare; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, call; 137, 138; 137, 139; 138, identifier:print; 139, argument_list; 139, 140; 140, binary_operator:%; 140, 141; 140, 142; 141, string:"...Preparing side-effect %s..."; 142, identifier:s; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:s; 147, identifier:prepare; 148, argument_list | def prepare(self):
global print_prepare
T = self.tm.trace
if T: T.write(self.trace_message(u'Task.prepare()', self.node))
self.exception_raise()
if self.tm.message:
self.display(self.tm.message)
self.tm.message = None
executor = self.targets[0].get_executor()
if executor is None:
return
executor.prepare()
for t in executor.get_action_targets():
if print_prepare:
print("Preparing target %s..."%t)
for s in t.side_effects:
print("...with side-effect %s..."%s)
t.prepare()
for s in t.side_effects:
if print_prepare:
print("...Preparing side-effect %s..."%s)
s.prepare() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:make_ready_current; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 34; 5, 40; 5, 44; 5, 128; 6, global_statement; 6, 7; 7, identifier:print_prepare; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:T; 11, attribute; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:tm; 15, identifier:trace; 16, if_statement; 16, 17; 16, 18; 17, identifier:T; 18, block; 18, 19; 19, expression_statement; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:T; 23, identifier:write; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:trace_message; 29, argument_list; 29, 30; 29, 31; 30, string:u'Task.make_ready_current()'; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:node; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:out_of_date; 39, list:[]; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:needs_executing; 43, False; 44, for_statement; 44, 45; 44, 46; 44, 49; 45, identifier:t; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:targets; 49, block; 49, 50; 49, 111; 50, try_statement; 50, 51; 50, 84; 51, block; 51, 52; 51, 62; 52, expression_statement; 52, 53; 53, call; 53, 54; 53, 61; 54, attribute; 54, 55; 54, 60; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:t; 58, identifier:disambiguate; 59, argument_list; 60, identifier:make_ready; 61, argument_list; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:is_up_to_date; 65, boolean_operator:or; 65, 66; 65, 72; 65, 73; 66, not_operator; 66, 67; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:t; 70, identifier:has_builder; 71, argument_list; 72, line_continuation:\; 73, parenthesized_expression; 73, 74; 74, boolean_operator:and; 74, 75; 74, 79; 75, not_operator; 75, 76; 76, attribute; 76, 77; 76, 78; 77, identifier:t; 78, identifier:always_build; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:t; 82, identifier:is_up_to_date; 83, argument_list; 84, except_clause; 84, 85; 84, 89; 85, as_pattern; 85, 86; 85, 87; 86, identifier:EnvironmentError; 87, as_pattern_target; 87, 88; 88, identifier:e; 89, block; 89, 90; 90, raise_statement; 90, 91; 91, call; 91, 92; 91, 97; 92, attribute; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:SCons; 95, identifier:Errors; 96, identifier:BuildError; 97, argument_list; 97, 98; 97, 101; 97, 106; 98, keyword_argument; 98, 99; 98, 100; 99, identifier:node; 100, identifier:t; 101, keyword_argument; 101, 102; 101, 103; 102, identifier:errstr; 103, attribute; 103, 104; 103, 105; 104, identifier:e; 105, identifier:strerror; 106, keyword_argument; 106, 107; 106, 108; 107, identifier:filename; 108, attribute; 108, 109; 108, 110; 109, identifier:e; 110, identifier:filename; 111, if_statement; 111, 112; 111, 114; 112, not_operator; 112, 113; 113, identifier:is_up_to_date; 114, block; 114, 115; 114, 124; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 122; 117, attribute; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:self; 120, identifier:out_of_date; 121, identifier:append; 122, argument_list; 122, 123; 123, identifier:t; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:needs_executing; 127, True; 128, if_statement; 128, 129; 128, 130; 128, 161; 129, identifier:needs_executing; 130, block; 130, 131; 131, for_statement; 131, 132; 131, 133; 131, 136; 132, identifier:t; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:targets; 136, block; 136, 137; 136, 144; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:t; 141, identifier:set_state; 142, argument_list; 142, 143; 143, identifier:NODE_EXECUTING; 144, for_statement; 144, 145; 144, 146; 144, 149; 145, identifier:s; 146, attribute; 146, 147; 146, 148; 147, identifier:t; 148, identifier:side_effects; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 159; 152, attribute; 152, 153; 152, 158; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:s; 156, identifier:disambiguate; 157, argument_list; 158, identifier:set_state; 159, argument_list; 159, 160; 160, identifier:NODE_EXECUTING; 161, else_clause; 161, 162; 162, block; 162, 163; 163, for_statement; 163, 164; 163, 165; 163, 168; 164, identifier:t; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:targets; 168, block; 168, 169; 168, 175; 168, 182; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:t; 173, identifier:visited; 174, argument_list; 175, expression_statement; 175, 176; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:t; 179, identifier:set_state; 180, argument_list; 180, 181; 181, identifier:NODE_UP_TO_DATE; 182, if_statement; 182, 183; 182, 201; 183, parenthesized_expression; 183, 184; 184, boolean_operator:and; 184, 185; 184, 187; 185, not_operator; 185, 186; 186, identifier:print_prepare; 187, parenthesized_expression; 187, 188; 188, boolean_operator:or; 188, 189; 188, 195; 189, not_operator; 189, 190; 190, call; 190, 191; 190, 192; 191, identifier:hasattr; 192, argument_list; 192, 193; 192, 194; 193, identifier:self; 194, string:'options'; 195, not_operator; 195, 196; 196, attribute; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:self; 199, identifier:options; 200, identifier:debug_includes; 201, block; 201, 202; 202, expression_statement; 202, 203; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:t; 206, identifier:release_target_info; 207, argument_list | def make_ready_current(self):
global print_prepare
T = self.tm.trace
if T: T.write(self.trace_message(u'Task.make_ready_current()',
self.node))
self.out_of_date = []
needs_executing = False
for t in self.targets:
try:
t.disambiguate().make_ready()
is_up_to_date = not t.has_builder() or \
(not t.always_build and t.is_up_to_date())
except EnvironmentError as e:
raise SCons.Errors.BuildError(node=t, errstr=e.strerror, filename=e.filename)
if not is_up_to_date:
self.out_of_date.append(t)
needs_executing = True
if needs_executing:
for t in self.targets:
t.set_state(NODE_EXECUTING)
for s in t.side_effects:
s.disambiguate().set_state(NODE_EXECUTING)
else:
for t in self.targets:
t.visited()
t.set_state(NODE_UP_TO_DATE)
if (not print_prepare and
(not hasattr(self, 'options') or not self.options.debug_includes)):
t.release_target_info() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:postprocess; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 32; 5, 41; 5, 49; 5, 53; 5, 106; 5, 183; 5, 238; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:T; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:tm; 13, identifier:trace; 14, if_statement; 14, 15; 14, 16; 15, identifier:T; 16, block; 16, 17; 17, expression_statement; 17, 18; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:T; 21, identifier:write; 22, argument_list; 22, 23; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:trace_message; 27, argument_list; 27, 28; 27, 29; 28, string:u'Task.postprocess()'; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:node; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:targets; 35, call; 35, 36; 35, 37; 36, identifier:set; 37, argument_list; 37, 38; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:targets; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:pending_children; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:tm; 48, identifier:pending_children; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:parents; 52, dictionary; 53, for_statement; 53, 54; 53, 55; 53, 56; 54, identifier:t; 55, identifier:targets; 56, block; 56, 57; 56, 86; 57, if_statement; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:t; 60, identifier:waiting_parents; 61, block; 61, 62; 61, 79; 62, if_statement; 62, 63; 62, 64; 63, identifier:T; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:T; 69, identifier:write; 70, argument_list; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:trace_message; 75, argument_list; 75, 76; 75, 77; 75, 78; 76, string:u'Task.postprocess()'; 77, identifier:t; 78, string:'removing'; 79, expression_statement; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:pending_children; 83, identifier:discard; 84, argument_list; 84, 85; 85, identifier:t; 86, for_statement; 86, 87; 86, 88; 86, 91; 87, identifier:p; 88, attribute; 88, 89; 88, 90; 89, identifier:t; 90, identifier:waiting_parents; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, subscript; 94, 95; 94, 96; 95, identifier:parents; 96, identifier:p; 97, binary_operator:+; 97, 98; 97, 105; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:parents; 101, identifier:get; 102, argument_list; 102, 103; 102, 104; 103, identifier:p; 104, integer:0; 105, integer:1; 106, for_statement; 106, 107; 106, 108; 106, 109; 107, identifier:t; 108, identifier:targets; 109, block; 109, 110; 110, if_statement; 110, 111; 110, 116; 111, comparison_operator:is; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:t; 114, identifier:side_effects; 115, None; 116, block; 116, 117; 117, for_statement; 117, 118; 117, 119; 117, 122; 118, identifier:s; 119, attribute; 119, 120; 119, 121; 120, identifier:t; 121, identifier:side_effects; 122, block; 122, 123; 122, 159; 123, if_statement; 123, 124; 123, 131; 124, comparison_operator:==; 124, 125; 124, 130; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:s; 128, identifier:get_state; 129, argument_list; 130, identifier:NODE_EXECUTING; 131, block; 131, 132; 131, 139; 132, expression_statement; 132, 133; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:s; 136, identifier:set_state; 137, argument_list; 137, 138; 138, identifier:NODE_NO_STATE; 139, for_statement; 139, 140; 139, 141; 139, 144; 140, identifier:p; 141, attribute; 141, 142; 141, 143; 142, identifier:s; 143, identifier:waiting_parents; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:parents; 149, identifier:p; 150, binary_operator:+; 150, 151; 150, 158; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:parents; 154, identifier:get; 155, argument_list; 155, 156; 155, 157; 156, identifier:p; 157, integer:0; 158, integer:1; 159, for_statement; 159, 160; 159, 161; 159, 164; 160, identifier:p; 161, attribute; 161, 162; 161, 163; 162, identifier:s; 163, identifier:waiting_s_e; 164, block; 164, 165; 165, if_statement; 165, 166; 165, 171; 166, comparison_operator:==; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:p; 169, identifier:ref_count; 170, integer:0; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 181; 174, attribute; 174, 175; 174, 180; 175, attribute; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:self; 178, identifier:tm; 179, identifier:candidates; 180, identifier:append; 181, argument_list; 181, 182; 182, identifier:p; 183, for_statement; 183, 184; 183, 187; 183, 192; 184, pattern_list; 184, 185; 184, 186; 185, identifier:p; 186, identifier:subtract; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:parents; 190, identifier:items; 191, argument_list; 192, block; 192, 193; 192, 203; 192, 220; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:p; 197, identifier:ref_count; 198, binary_operator:-; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:p; 201, identifier:ref_count; 202, identifier:subtract; 203, if_statement; 203, 204; 203, 205; 204, identifier:T; 205, block; 205, 206; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:T; 210, identifier:write; 211, argument_list; 211, 212; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:self; 215, identifier:trace_message; 216, argument_list; 216, 217; 216, 218; 216, 219; 217, string:u'Task.postprocess()'; 218, identifier:p; 219, string:'adjusted parent ref count'; 220, if_statement; 220, 221; 220, 226; 221, comparison_operator:==; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:p; 224, identifier:ref_count; 225, integer:0; 226, block; 226, 227; 227, expression_statement; 227, 228; 228, call; 228, 229; 228, 236; 229, attribute; 229, 230; 229, 235; 230, attribute; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:self; 233, identifier:tm; 234, identifier:candidates; 235, identifier:append; 236, argument_list; 236, 237; 237, identifier:p; 238, for_statement; 238, 239; 238, 240; 238, 241; 239, identifier:t; 240, identifier:targets; 241, block; 241, 242; 242, expression_statement; 242, 243; 243, call; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:t; 246, identifier:postprocess; 247, argument_list | def postprocess(self):
T = self.tm.trace
if T: T.write(self.trace_message(u'Task.postprocess()', self.node))
targets = set(self.targets)
pending_children = self.tm.pending_children
parents = {}
for t in targets:
if t.waiting_parents:
if T: T.write(self.trace_message(u'Task.postprocess()',
t,
'removing'))
pending_children.discard(t)
for p in t.waiting_parents:
parents[p] = parents.get(p, 0) + 1
for t in targets:
if t.side_effects is not None:
for s in t.side_effects:
if s.get_state() == NODE_EXECUTING:
s.set_state(NODE_NO_STATE)
for p in s.waiting_parents:
parents[p] = parents.get(p, 0) + 1
for p in s.waiting_s_e:
if p.ref_count == 0:
self.tm.candidates.append(p)
for p, subtract in parents.items():
p.ref_count = p.ref_count - subtract
if T: T.write(self.trace_message(u'Task.postprocess()',
p,
'adjusted parent ref count'))
if p.ref_count == 0:
self.tm.candidates.append(p)
for t in targets:
t.postprocess() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:update_dependency; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:tile; 6, identifier:depinfo; 7, default_parameter; 7, 8; 7, 9; 8, identifier:destdir; 9, None; 10, block; 10, 11; 10, 34; 10, 38; 10, 42; 10, 60; 10, 205; 10, 210; 11, if_statement; 11, 12; 11, 15; 12, comparison_operator:is; 12, 13; 12, 14; 13, identifier:destdir; 14, None; 15, block; 15, 16; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:destdir; 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, 29; 25, 30; 25, 31; 26, attribute; 26, 27; 26, 28; 27, identifier:tile; 28, identifier:folder; 29, string:'build'; 30, string:'deps'; 31, subscript; 31, 32; 31, 33; 32, identifier:depinfo; 33, string:'unique_id'; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:has_version; 37, False; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:had_version; 41, False; 42, if_statement; 42, 43; 42, 51; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:os; 47, identifier:path; 48, identifier:exists; 49, argument_list; 49, 50; 50, identifier:destdir; 51, block; 51, 52; 51, 56; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:has_version; 55, True; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:had_version; 59, True; 60, for_statement; 60, 61; 60, 64; 60, 67; 61, pattern_list; 61, 62; 61, 63; 62, identifier:priority; 63, identifier:rule; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:rules; 67, block; 67, 68; 67, 79; 67, 88; 67, 128; 67, 138; 67, 154; 67, 161; 67, 177; 67, 190; 67, 198; 67, 203; 68, if_statement; 68, 69; 68, 77; 69, not_operator; 69, 70; 70, call; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:_check_rule; 74, argument_list; 74, 75; 74, 76; 75, identifier:rule; 76, identifier:depinfo; 77, block; 77, 78; 78, continue_statement; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:resolver; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:self; 85, identifier:_find_resolver; 86, argument_list; 86, 87; 87, identifier:rule; 88, if_statement; 88, 89; 88, 90; 89, identifier:has_version; 90, block; 90, 91; 90, 98; 90, 109; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:deptile; 94, call; 94, 95; 94, 96; 95, identifier:IOTile; 96, argument_list; 96, 97; 97, identifier:destdir; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:depstatus; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:_check_dep; 105, argument_list; 105, 106; 105, 107; 105, 108; 106, identifier:depinfo; 107, identifier:deptile; 108, identifier:resolver; 109, if_statement; 109, 110; 109, 113; 109, 125; 110, comparison_operator:is; 110, 111; 110, 112; 111, identifier:depstatus; 112, False; 113, block; 113, 114; 113, 121; 114, expression_statement; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:shutil; 118, identifier:rmtree; 119, argument_list; 119, 120; 120, identifier:destdir; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:has_version; 124, False; 125, else_clause; 125, 126; 126, block; 126, 127; 127, continue_statement; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:result; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:resolver; 134, identifier:resolve; 135, argument_list; 135, 136; 135, 137; 136, identifier:depinfo; 137, identifier:destdir; 138, if_statement; 138, 139; 138, 151; 139, boolean_operator:and; 139, 140; 139, 144; 140, not_operator; 140, 141; 141, subscript; 141, 142; 141, 143; 142, identifier:result; 143, string:'found'; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:result; 147, identifier:get; 148, argument_list; 148, 149; 148, 150; 149, string:'stop'; 150, False; 151, block; 151, 152; 152, return_statement; 152, 153; 153, string:'not found'; 154, if_statement; 154, 155; 154, 159; 155, not_operator; 155, 156; 156, subscript; 156, 157; 156, 158; 157, identifier:result; 158, string:'found'; 159, block; 159, 160; 160, continue_statement; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:settings; 164, dictionary; 164, 165; 164, 172; 165, pair; 165, 166; 165, 167; 166, string:'resolver'; 167, attribute; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:resolver; 170, identifier:__class__; 171, identifier:__name__; 172, pair; 172, 173; 172, 174; 173, string:'factory_args'; 174, subscript; 174, 175; 174, 176; 175, identifier:rule; 176, integer:2; 177, if_statement; 177, 178; 177, 181; 178, comparison_operator:in; 178, 179; 178, 180; 179, string:'settings'; 180, identifier:result; 181, block; 181, 182; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 187; 184, subscript; 184, 185; 184, 186; 185, identifier:settings; 186, string:'settings'; 187, subscript; 187, 188; 187, 189; 188, identifier:result; 189, string:'settings'; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:self; 194, identifier:_save_depsettings; 195, argument_list; 195, 196; 195, 197; 196, identifier:destdir; 197, identifier:settings; 198, if_statement; 198, 199; 198, 200; 199, identifier:had_version; 200, block; 200, 201; 201, return_statement; 201, 202; 202, string:"updated"; 203, return_statement; 203, 204; 204, string:"installed"; 205, if_statement; 205, 206; 205, 207; 206, identifier:has_version; 207, block; 207, 208; 208, return_statement; 208, 209; 209, string:"already installed"; 210, return_statement; 210, 211; 211, string:"not found" | def update_dependency(self, tile, depinfo, destdir=None):
if destdir is None:
destdir = os.path.join(tile.folder, 'build', 'deps', depinfo['unique_id'])
has_version = False
had_version = False
if os.path.exists(destdir):
has_version = True
had_version = True
for priority, rule in self.rules:
if not self._check_rule(rule, depinfo):
continue
resolver = self._find_resolver(rule)
if has_version:
deptile = IOTile(destdir)
depstatus = self._check_dep(depinfo, deptile, resolver)
if depstatus is False:
shutil.rmtree(destdir)
has_version = False
else:
continue
result = resolver.resolve(depinfo, destdir)
if not result['found'] and result.get('stop', False):
return 'not found'
if not result['found']:
continue
settings = {
'resolver': resolver.__class__.__name__,
'factory_args': rule[2]
}
if 'settings' in result:
settings['settings'] = result['settings']
self._save_depsettings(destdir, settings)
if had_version:
return "updated"
return "installed"
if has_version:
return "already installed"
return "not found" |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:stop; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 24; 5, 82; 5, 86; 5, 102; 5, 116; 5, 129; 5, 133; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:stopped; 10, block; 10, 11; 11, return_statement; 12, expression_statement; 12, 13; 13, call; 13, 14; 13, 19; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:_logger; 18, identifier:debug; 19, argument_list; 19, 20; 19, 21; 20, string:"Stopping task %s"; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:name; 24, if_statement; 24, 25; 24, 30; 24, 67; 25, comparison_operator:is; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:_finalizer; 29, None; 30, block; 30, 31; 31, try_statement; 31, 32; 31, 53; 32, block; 32, 33; 32, 42; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:result; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:_finalizer; 40, argument_list; 40, 41; 41, identifier:self; 42, if_statement; 42, 43; 42, 49; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:inspect; 46, identifier:isawaitable; 47, argument_list; 47, 48; 48, identifier:result; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, await; 51, 52; 52, identifier:result; 53, except_clause; 53, 54; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, call; 56, 57; 56, 62; 57, attribute; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:_logger; 61, identifier:exception; 62, argument_list; 62, 63; 62, 64; 63, string:"Error running finalizer for task %s"; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:name; 67, elif_clause; 67, 68; 67, 73; 68, comparison_operator:is; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:task; 72, None; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 81; 76, attribute; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:task; 80, identifier:cancel; 81, argument_list; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:tasks; 85, list:[]; 86, if_statement; 86, 87; 86, 92; 87, comparison_operator:is; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:task; 91, None; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:tasks; 97, identifier:append; 98, argument_list; 98, 99; 99, attribute; 99, 100; 99, 101; 100, identifier:self; 101, identifier:task; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:tasks; 106, identifier:extend; 107, generator_expression; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:x; 110, identifier:task; 111, for_in_clause; 111, 112; 111, 113; 112, identifier:x; 113, attribute; 113, 114; 113, 115; 114, identifier:self; 115, identifier:subtasks; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:finished; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:asyncio; 122, identifier:gather; 123, argument_list; 123, 124; 123, 126; 124, list_splat; 124, 125; 125, identifier:tasks; 126, keyword_argument; 126, 127; 126, 128; 127, identifier:return_exceptions; 128, True; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:outcomes; 132, list:[]; 133, try_statement; 133, 134; 133, 150; 133, 173; 134, block; 134, 135; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:outcomes; 138, await; 138, 139; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:asyncio; 142, identifier:wait_for; 143, argument_list; 143, 144; 143, 145; 144, identifier:finished; 145, keyword_argument; 145, 146; 145, 147; 146, identifier:timeout; 147, attribute; 147, 148; 147, 149; 148, identifier:self; 149, identifier:_stop_timeout; 150, except_clause; 150, 151; 150, 157; 151, as_pattern; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:asyncio; 154, identifier:TimeoutError; 155, as_pattern_target; 155, 156; 156, identifier:err; 157, block; 157, 158; 157, 171; 158, try_statement; 158, 159; 158, 165; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:outcomes; 163, await; 163, 164; 164, identifier:finished; 165, except_clause; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:asyncio; 168, identifier:CancelledError; 169, block; 169, 170; 170, pass_statement; 171, raise_statement; 171, 172; 172, identifier:err; 173, finally_clause; 173, 174; 174, block; 174, 175; 174, 181; 174, 210; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:self; 179, identifier:stopped; 180, True; 181, for_statement; 181, 182; 181, 183; 181, 184; 182, identifier:outcome; 183, identifier:outcomes; 184, block; 184, 185; 185, if_statement; 185, 186; 185, 200; 186, boolean_operator:and; 186, 187; 186, 192; 187, call; 187, 188; 187, 189; 188, identifier:isinstance; 189, argument_list; 189, 190; 189, 191; 190, identifier:outcome; 191, identifier:Exception; 192, not_operator; 192, 193; 193, call; 193, 194; 193, 195; 194, identifier:isinstance; 195, argument_list; 195, 196; 195, 197; 196, identifier:outcome; 197, attribute; 197, 198; 197, 199; 198, identifier:asyncio; 199, identifier:CancelledError; 200, block; 200, 201; 201, expression_statement; 201, 202; 202, call; 202, 203; 202, 208; 203, attribute; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:self; 206, identifier:_logger; 207, identifier:error; 208, argument_list; 208, 209; 209, identifier:outcome; 210, if_statement; 210, 211; 210, 218; 211, comparison_operator:in; 211, 212; 211, 213; 212, identifier:self; 213, attribute; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:self; 216, identifier:_loop; 217, identifier:tasks; 218, block; 218, 219; 219, expression_statement; 219, 220; 220, call; 220, 221; 220, 228; 221, attribute; 221, 222; 221, 227; 222, attribute; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:self; 225, identifier:_loop; 226, identifier:tasks; 227, identifier:remove; 228, argument_list; 228, 229; 229, identifier:self | async def stop(self):
if self.stopped:
return
self._logger.debug("Stopping task %s", self.name)
if self._finalizer is not None:
try:
result = self._finalizer(self)
if inspect.isawaitable(result):
await result
except:
self._logger.exception("Error running finalizer for task %s",
self.name)
elif self.task is not None:
self.task.cancel()
tasks = []
if self.task is not None:
tasks.append(self.task)
tasks.extend(x.task for x in self.subtasks)
finished = asyncio.gather(*tasks, return_exceptions=True)
outcomes = []
try:
outcomes = await asyncio.wait_for(finished, timeout=self._stop_timeout)
except asyncio.TimeoutError as err:
try:
outcomes = await finished
except asyncio.CancelledError:
pass
raise err
finally:
self.stopped = True
for outcome in outcomes:
if isinstance(outcome, Exception) and not isinstance(outcome, asyncio.CancelledError):
self._logger.error(outcome)
if self in self._loop.tasks:
self._loop.tasks.remove(self) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:link_cloud; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:username; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:password; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:device_id; 13, None; 14, block; 14, 15; 14, 21; 14, 30; 14, 46; 14, 64; 14, 73; 14, 87; 14, 98; 14, 108; 14, 118; 14, 128; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:reg; 18, call; 18, 19; 18, 20; 19, identifier:ComponentRegistry; 20, argument_list; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:domain; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:get; 28, argument_list; 28, 29; 29, string:'cloud:server'; 30, if_statement; 30, 31; 30, 34; 31, comparison_operator:is; 31, 32; 31, 33; 32, identifier:username; 33, None; 34, block; 34, 35; 34, 39; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:prompt_str; 38, string:"Please enter your IOTile.cloud email: "; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:username; 42, call; 42, 43; 42, 44; 43, identifier:input; 44, argument_list; 44, 45; 45, identifier:prompt_str; 46, if_statement; 46, 47; 46, 50; 47, comparison_operator:is; 47, 48; 47, 49; 48, identifier:password; 49, None; 50, block; 50, 51; 50, 55; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:prompt_str; 54, string:"Please enter your IOTile.cloud password: "; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:password; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:getpass; 61, identifier:getpass; 62, argument_list; 62, 63; 63, identifier:prompt_str; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:cloud; 67, call; 67, 68; 67, 69; 68, identifier:Api; 69, argument_list; 69, 70; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:domain; 72, identifier:domain; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:ok_resp; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:cloud; 79, identifier:login; 80, argument_list; 80, 81; 80, 84; 81, keyword_argument; 81, 82; 81, 83; 82, identifier:email; 83, identifier:username; 84, keyword_argument; 84, 85; 84, 86; 85, identifier:password; 86, identifier:password; 87, if_statement; 87, 88; 87, 90; 88, not_operator; 88, 89; 89, identifier:ok_resp; 90, block; 90, 91; 91, raise_statement; 91, 92; 92, call; 92, 93; 92, 94; 93, identifier:ArgumentError; 94, argument_list; 94, 95; 95, binary_operator:%; 95, 96; 95, 97; 96, string:"Could not login to iotile.cloud as user %s"; 97, identifier:username; 98, expression_statement; 98, 99; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:reg; 102, identifier:set_config; 103, argument_list; 103, 104; 103, 105; 104, string:'arch:cloud_user'; 105, attribute; 105, 106; 105, 107; 106, identifier:cloud; 107, identifier:username; 108, expression_statement; 108, 109; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:reg; 112, identifier:set_config; 113, argument_list; 113, 114; 113, 115; 114, string:'arch:cloud_token'; 115, attribute; 115, 116; 115, 117; 116, identifier:cloud; 117, identifier:token; 118, expression_statement; 118, 119; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:reg; 122, identifier:set_config; 123, argument_list; 123, 124; 123, 125; 124, string:'arch:cloud_token_type'; 125, attribute; 125, 126; 125, 127; 126, identifier:cloud; 127, identifier:token_type; 128, if_statement; 128, 129; 128, 132; 129, comparison_operator:is; 129, 130; 129, 131; 130, identifier:device_id; 131, None; 132, block; 132, 133; 132, 139; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:cloud; 136, call; 136, 137; 136, 138; 137, identifier:IOTileCloud; 138, argument_list; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:cloud; 143, identifier:impersonate_device; 144, argument_list; 144, 145; 145, identifier:device_id | def link_cloud(self, username=None, password=None, device_id=None):
reg = ComponentRegistry()
domain = self.get('cloud:server')
if username is None:
prompt_str = "Please enter your IOTile.cloud email: "
username = input(prompt_str)
if password is None:
prompt_str = "Please enter your IOTile.cloud password: "
password = getpass.getpass(prompt_str)
cloud = Api(domain=domain)
ok_resp = cloud.login(email=username, password=password)
if not ok_resp:
raise ArgumentError("Could not login to iotile.cloud as user %s" % username)
reg.set_config('arch:cloud_user', cloud.username)
reg.set_config('arch:cloud_token', cloud.token)
reg.set_config('arch:cloud_token_type', cloud.token_type)
if device_id is not None:
cloud = IOTileCloud()
cloud.impersonate_device(device_id) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:main; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:argv; 6, None; 7, block; 7, 8; 7, 23; 7, 297; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:argv; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:argv; 16, subscript; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:sys; 19, identifier:argv; 20, slice; 20, 21; 20, 22; 21, integer:1; 22, colon; 23, try_statement; 23, 24; 23, 282; 24, block; 24, 25; 24, 29; 24, 35; 24, 46; 24, 52; 24, 58; 24, 67; 24, 74; 24, 98; 24, 104; 24, 111; 24, 124; 24, 149; 24, 174; 24, 201; 24, 214; 24, 220; 24, 233; 24, 264; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:executor; 28, None; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:parser; 32, call; 32, 33; 32, 34; 33, identifier:build_args; 34, argument_list; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:args; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:parser; 41, identifier:parse_args; 42, argument_list; 42, 43; 43, keyword_argument; 43, 44; 43, 45; 44, identifier:args; 45, identifier:argv; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:model; 49, call; 49, 50; 49, 51; 50, identifier:DeviceModel; 51, argument_list; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:parser; 55, call; 55, 56; 55, 57; 56, identifier:SensorGraphFileParser; 57, argument_list; 58, expression_statement; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:parser; 62, identifier:parse_file; 63, argument_list; 63, 64; 64, attribute; 64, 65; 64, 66; 65, identifier:args; 66, identifier:sensor_graph; 67, expression_statement; 67, 68; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:parser; 71, identifier:compile; 72, argument_list; 72, 73; 73, identifier:model; 74, if_statement; 74, 75; 74, 79; 75, not_operator; 75, 76; 76, attribute; 76, 77; 76, 78; 77, identifier:args; 78, identifier:disable_optimizer; 79, block; 79, 80; 79, 86; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:opt; 83, call; 83, 84; 83, 85; 84, identifier:SensorGraphOptimizer; 85, argument_list; 86, expression_statement; 86, 87; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:opt; 90, identifier:optimize; 91, argument_list; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:parser; 94, identifier:sensor_graph; 95, keyword_argument; 95, 96; 95, 97; 96, identifier:model; 97, identifier:model; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:graph; 101, attribute; 101, 102; 101, 103; 102, identifier:parser; 103, identifier:sensor_graph; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:sim; 107, call; 107, 108; 107, 109; 108, identifier:SensorGraphSimulator; 109, argument_list; 109, 110; 110, identifier:graph; 111, for_statement; 111, 112; 111, 113; 111, 116; 112, identifier:stop; 113, attribute; 113, 114; 113, 115; 114, identifier:args; 115, identifier:stop; 116, block; 116, 117; 117, expression_statement; 117, 118; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:sim; 121, identifier:stop_condition; 122, argument_list; 122, 123; 123, identifier:stop; 124, for_statement; 124, 125; 124, 126; 124, 129; 125, identifier:watch; 126, attribute; 126, 127; 126, 128; 127, identifier:args; 128, identifier:watch; 129, block; 129, 130; 129, 139; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:watch_sel; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:DataStreamSelector; 136, identifier:FromString; 137, argument_list; 137, 138; 138, identifier:watch; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 146; 141, attribute; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:graph; 144, identifier:sensor_log; 145, identifier:watch; 146, argument_list; 146, 147; 146, 148; 147, identifier:watch_sel; 148, identifier:watch_printer; 149, if_statement; 149, 150; 149, 155; 150, comparison_operator:is; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:args; 153, identifier:semihost_device; 154, None; 155, block; 155, 156; 155, 168; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:executor; 159, call; 159, 160; 159, 161; 160, identifier:SemihostedRPCExecutor; 161, argument_list; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:args; 164, identifier:port; 165, attribute; 165, 166; 165, 167; 166, identifier:args; 167, identifier:semihost_device; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:sim; 172, identifier:rpc_executor; 173, identifier:executor; 174, for_statement; 174, 175; 174, 176; 174, 179; 175, identifier:mock; 176, attribute; 176, 177; 176, 178; 177, identifier:args; 178, identifier:mock_rpc; 179, block; 179, 180; 179, 190; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 186; 182, pattern_list; 182, 183; 182, 184; 182, 185; 183, identifier:slot; 184, identifier:rpc_id; 185, identifier:value; 186, call; 186, 187; 186, 188; 187, identifier:process_mock_rpc; 188, argument_list; 188, 189; 189, identifier:mock; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 197; 192, attribute; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:sim; 195, identifier:rpc_executor; 196, identifier:mock; 197, argument_list; 197, 198; 197, 199; 197, 200; 198, identifier:slot; 199, identifier:rpc_id; 200, identifier:value; 201, for_statement; 201, 202; 201, 203; 201, 206; 202, identifier:stim; 203, attribute; 203, 204; 203, 205; 204, identifier:args; 205, identifier:stimulus; 206, block; 206, 207; 207, expression_statement; 207, 208; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:sim; 211, identifier:stimulus; 212, argument_list; 212, 213; 213, identifier:stim; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:graph; 218, identifier:load_constants; 219, argument_list; 220, if_statement; 220, 221; 220, 226; 221, comparison_operator:is; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:args; 224, identifier:trace; 225, None; 226, block; 226, 227; 227, expression_statement; 227, 228; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:sim; 231, identifier:record_trace; 232, argument_list; 233, try_statement; 233, 234; 233, 260; 234, block; 234, 235; 234, 248; 235, if_statement; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:args; 238, identifier:connected; 239, block; 239, 240; 240, expression_statement; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:sim; 244, identifier:step; 245, argument_list; 245, 246; 245, 247; 246, identifier:user_connected; 247, integer:8; 248, expression_statement; 248, 249; 249, call; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:sim; 252, identifier:run; 253, argument_list; 253, 254; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:accelerated; 256, not_operator; 256, 257; 257, attribute; 257, 258; 257, 259; 258, identifier:args; 259, identifier:realtime; 260, except_clause; 260, 261; 260, 262; 261, identifier:KeyboardInterrupt; 262, block; 262, 263; 263, pass_statement; 264, if_statement; 264, 265; 264, 270; 265, comparison_operator:is; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:args; 268, identifier:trace; 269, None; 270, block; 270, 271; 271, expression_statement; 271, 272; 272, call; 272, 273; 272, 278; 273, attribute; 273, 274; 273, 277; 274, attribute; 274, 275; 274, 276; 275, identifier:sim; 276, identifier:trace; 277, identifier:save; 278, argument_list; 278, 279; 279, attribute; 279, 280; 279, 281; 280, identifier:args; 281, identifier:trace; 282, finally_clause; 282, 283; 283, block; 283, 284; 284, if_statement; 284, 285; 284, 288; 285, comparison_operator:is; 285, 286; 285, 287; 286, identifier:executor; 287, None; 288, block; 288, 289; 289, expression_statement; 289, 290; 290, call; 290, 291; 290, 296; 291, attribute; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:executor; 294, identifier:hw; 295, identifier:close; 296, argument_list; 297, return_statement; 297, 298; 298, integer:0 | def main(argv=None):
if argv is None:
argv = sys.argv[1:]
try:
executor = None
parser = build_args()
args = parser.parse_args(args=argv)
model = DeviceModel()
parser = SensorGraphFileParser()
parser.parse_file(args.sensor_graph)
parser.compile(model)
if not args.disable_optimizer:
opt = SensorGraphOptimizer()
opt.optimize(parser.sensor_graph, model=model)
graph = parser.sensor_graph
sim = SensorGraphSimulator(graph)
for stop in args.stop:
sim.stop_condition(stop)
for watch in args.watch:
watch_sel = DataStreamSelector.FromString(watch)
graph.sensor_log.watch(watch_sel, watch_printer)
if args.semihost_device is not None:
executor = SemihostedRPCExecutor(args.port, args.semihost_device)
sim.rpc_executor = executor
for mock in args.mock_rpc:
slot, rpc_id, value = process_mock_rpc(mock)
sim.rpc_executor.mock(slot, rpc_id, value)
for stim in args.stimulus:
sim.stimulus(stim)
graph.load_constants()
if args.trace is not None:
sim.record_trace()
try:
if args.connected:
sim.step(user_connected, 8)
sim.run(accelerated=not args.realtime)
except KeyboardInterrupt:
pass
if args.trace is not None:
sim.trace.save(args.trace)
finally:
if executor is not None:
executor.hw.close()
return 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_update_pot_file; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:target; 5, identifier:source; 6, identifier:env; 7, block; 7, 8; 7, 11; 7, 14; 7, 18; 7, 27; 7, 37; 7, 45; 7, 53; 7, 64; 7, 81; 7, 91; 7, 166; 7, 183; 7, 193; 7, 200; 7, 205; 7, 211; 7, 312; 8, import_statement; 8, 9; 9, dotted_name; 9, 10; 10, identifier:re; 11, import_statement; 11, 12; 12, dotted_name; 12, 13; 13, identifier:os; 14, import_statement; 14, 15; 15, dotted_name; 15, 16; 15, 17; 16, identifier:SCons; 17, identifier:Action; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:nop; 21, lambda; 21, 22; 21, 26; 22, lambda_parameters; 22, 23; 22, 24; 22, 25; 23, identifier:target; 24, identifier:source; 25, identifier:env; 26, integer:0; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:save_cwd; 30, call; 30, 31; 30, 36; 31, attribute; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:env; 34, identifier:fs; 35, identifier:getcwd; 36, argument_list; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:save_os_cwd; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:os; 43, identifier:getcwd; 44, argument_list; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:chdir; 48, attribute; 48, 49; 48, 52; 49, subscript; 49, 50; 49, 51; 50, identifier:target; 51, integer:0; 52, identifier:dir; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:chdir_str; 56, call; 56, 57; 56, 58; 57, identifier:repr; 58, argument_list; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:chdir; 62, identifier:get_abspath; 63, argument_list; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:env; 68, identifier:Execute; 69, argument_list; 69, 70; 70, call; 70, 71; 70, 76; 71, attribute; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:SCons; 74, identifier:Action; 75, identifier:Action; 76, argument_list; 76, 77; 76, 78; 77, identifier:nop; 78, binary_operator:+; 78, 79; 78, 80; 79, string:"Entering "; 80, identifier:chdir_str; 81, expression_statement; 81, 82; 82, call; 82, 83; 82, 88; 83, attribute; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:env; 86, identifier:fs; 87, identifier:chdir; 88, argument_list; 88, 89; 88, 90; 89, identifier:chdir; 90, integer:1; 91, try_statement; 91, 92; 91, 129; 92, block; 92, 93; 92, 101; 92, 117; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:cmd; 96, call; 96, 97; 96, 98; 97, identifier:_CmdRunner; 98, argument_list; 98, 99; 98, 100; 99, string:'$XGETTEXTCOM'; 100, string:'$XGETTEXTCOMSTR'; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:action; 104, call; 104, 105; 104, 110; 105, attribute; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:SCons; 108, identifier:Action; 109, identifier:Action; 110, argument_list; 110, 111; 110, 112; 111, identifier:cmd; 112, keyword_argument; 112, 113; 112, 114; 113, identifier:strfunction; 114, attribute; 114, 115; 114, 116; 115, identifier:cmd; 116, identifier:strfunction; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:status; 120, call; 120, 121; 120, 122; 121, identifier:action; 122, argument_list; 122, 123; 122, 127; 122, 128; 123, list:[target[0]]; 123, 124; 124, subscript; 124, 125; 124, 126; 125, identifier:target; 126, integer:0; 127, identifier:source; 128, identifier:env; 129, except_clause; 129, 130; 130, block; 130, 131; 130, 148; 130, 158; 130, 165; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:env; 135, identifier:Execute; 136, argument_list; 136, 137; 137, call; 137, 138; 137, 143; 138, attribute; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:SCons; 141, identifier:Action; 142, identifier:Action; 143, argument_list; 143, 144; 143, 145; 144, identifier:nop; 145, binary_operator:+; 145, 146; 145, 147; 146, string:"Leaving "; 147, identifier:chdir_str; 148, expression_statement; 148, 149; 149, call; 149, 150; 149, 155; 150, attribute; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:env; 153, identifier:fs; 154, identifier:chdir; 155, argument_list; 155, 156; 155, 157; 156, identifier:save_cwd; 157, integer:0; 158, expression_statement; 158, 159; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:os; 162, identifier:chdir; 163, argument_list; 163, 164; 164, identifier:save_os_cwd; 165, raise_statement; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:env; 170, identifier:Execute; 171, argument_list; 171, 172; 172, call; 172, 173; 172, 178; 173, attribute; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:SCons; 176, identifier:Action; 177, identifier:Action; 178, argument_list; 178, 179; 178, 180; 179, identifier:nop; 180, binary_operator:+; 180, 181; 180, 182; 181, string:"Leaving "; 182, identifier:chdir_str; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 190; 185, attribute; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:env; 188, identifier:fs; 189, identifier:chdir; 190, argument_list; 190, 191; 190, 192; 191, identifier:save_cwd; 192, integer:0; 193, expression_statement; 193, 194; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:os; 197, identifier:chdir; 198, argument_list; 198, 199; 199, identifier:save_os_cwd; 200, if_statement; 200, 201; 200, 202; 201, identifier:status; 202, block; 202, 203; 203, return_statement; 203, 204; 204, identifier:status; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:new_content; 208, attribute; 208, 209; 208, 210; 209, identifier:cmd; 210, identifier:out; 211, if_statement; 211, 212; 211, 214; 211, 223; 212, not_operator; 212, 213; 213, identifier:new_content; 214, block; 214, 215; 214, 219; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:needs_update; 218, False; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 222; 221, identifier:explain; 222, string:"no internationalized messages encountered"; 223, else_clause; 223, 224; 224, block; 224, 225; 225, if_statement; 225, 226; 225, 233; 225, 302; 226, call; 226, 227; 226, 232; 227, attribute; 227, 228; 227, 231; 228, subscript; 228, 229; 228, 230; 229, identifier:target; 230, integer:0; 231, identifier:exists; 232, argument_list; 233, block; 233, 234; 233, 244; 233, 256; 233, 267; 233, 278; 234, expression_statement; 234, 235; 235, assignment; 235, 236; 235, 237; 236, identifier:old_content; 237, call; 237, 238; 237, 243; 238, attribute; 238, 239; 238, 242; 239, subscript; 239, 240; 239, 241; 240, identifier:target; 241, integer:0; 242, identifier:get_text_contents; 243, argument_list; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 247; 246, identifier:re_cdate; 247, call; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:re; 250, identifier:compile; 251, argument_list; 251, 252; 251, 253; 252, string:r'^"POT-Creation-Date: .*"$[\r\n]?'; 253, attribute; 253, 254; 253, 255; 254, identifier:re; 255, identifier:M; 256, expression_statement; 256, 257; 257, assignment; 257, 258; 257, 259; 258, identifier:old_content_nocdate; 259, call; 259, 260; 259, 263; 260, attribute; 260, 261; 260, 262; 261, identifier:re; 262, identifier:sub; 263, argument_list; 263, 264; 263, 265; 263, 266; 264, identifier:re_cdate; 265, string:""; 266, identifier:old_content; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:new_content_nocdate; 270, call; 270, 271; 270, 274; 271, attribute; 271, 272; 271, 273; 272, identifier:re; 273, identifier:sub; 274, argument_list; 274, 275; 274, 276; 274, 277; 275, identifier:re_cdate; 276, string:""; 277, identifier:new_content; 278, if_statement; 278, 279; 278, 283; 278, 292; 279, parenthesized_expression; 279, 280; 280, comparison_operator:==; 280, 281; 280, 282; 281, identifier:old_content_nocdate; 282, identifier:new_content_nocdate; 283, block; 283, 284; 283, 288; 284, expression_statement; 284, 285; 285, assignment; 285, 286; 285, 287; 286, identifier:needs_update; 287, False; 288, expression_statement; 288, 289; 289, assignment; 289, 290; 289, 291; 290, identifier:explain; 291, string:"messages in file found to be up-to-date"; 292, else_clause; 292, 293; 293, block; 293, 294; 293, 298; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 297; 296, identifier:needs_update; 297, True; 298, expression_statement; 298, 299; 299, assignment; 299, 300; 299, 301; 300, identifier:explain; 301, string:"messages in file were outdated"; 302, else_clause; 302, 303; 303, block; 303, 304; 303, 308; 304, expression_statement; 304, 305; 305, assignment; 305, 306; 305, 307; 306, identifier:needs_update; 307, True; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:explain; 311, string:"new file"; 312, if_statement; 312, 313; 312, 314; 312, 378; 313, identifier:needs_update; 314, block; 314, 315; 314, 335; 314, 350; 314, 363; 314, 370; 314, 376; 315, expression_statement; 315, 316; 316, assignment; 316, 317; 316, 318; 317, identifier:msg; 318, binary_operator:+; 318, 319; 318, 334; 319, binary_operator:+; 319, 320; 319, 333; 320, binary_operator:+; 320, 321; 320, 332; 321, binary_operator:+; 321, 322; 321, 323; 322, string:"Writing "; 323, call; 323, 324; 323, 325; 324, identifier:repr; 325, argument_list; 325, 326; 326, call; 326, 327; 326, 328; 327, identifier:str; 328, argument_list; 328, 329; 329, subscript; 329, 330; 329, 331; 330, identifier:target; 331, integer:0; 332, string:" ("; 333, identifier:explain; 334, string:")"; 335, expression_statement; 335, 336; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:env; 339, identifier:Execute; 340, argument_list; 340, 341; 341, call; 341, 342; 341, 347; 342, attribute; 342, 343; 342, 346; 343, attribute; 343, 344; 343, 345; 344, identifier:SCons; 345, identifier:Action; 346, identifier:Action; 347, argument_list; 347, 348; 347, 349; 348, identifier:nop; 349, identifier:msg; 350, expression_statement; 350, 351; 351, assignment; 351, 352; 351, 353; 352, identifier:f; 353, call; 353, 354; 353, 355; 354, identifier:open; 355, argument_list; 355, 356; 355, 362; 356, call; 356, 357; 356, 358; 357, identifier:str; 358, argument_list; 358, 359; 359, subscript; 359, 360; 359, 361; 360, identifier:target; 361, integer:0; 362, string:"w"; 363, expression_statement; 363, 364; 364, call; 364, 365; 364, 368; 365, attribute; 365, 366; 365, 367; 366, identifier:f; 367, identifier:write; 368, argument_list; 368, 369; 369, identifier:new_content; 370, expression_statement; 370, 371; 371, call; 371, 372; 371, 375; 372, attribute; 372, 373; 372, 374; 373, identifier:f; 374, identifier:close; 375, argument_list; 376, return_statement; 376, 377; 377, integer:0; 378, else_clause; 378, 379; 379, block; 379, 380; 379, 400; 379, 415; 380, expression_statement; 380, 381; 381, assignment; 381, 382; 381, 383; 382, identifier:msg; 383, binary_operator:+; 383, 384; 383, 399; 384, binary_operator:+; 384, 385; 384, 398; 385, binary_operator:+; 385, 386; 385, 397; 386, binary_operator:+; 386, 387; 386, 388; 387, string:"Not writing "; 388, call; 388, 389; 388, 390; 389, identifier:repr; 390, argument_list; 390, 391; 391, call; 391, 392; 391, 393; 392, identifier:str; 393, argument_list; 393, 394; 394, subscript; 394, 395; 394, 396; 395, identifier:target; 396, integer:0; 397, string:" ("; 398, identifier:explain; 399, string:")"; 400, expression_statement; 400, 401; 401, call; 401, 402; 401, 405; 402, attribute; 402, 403; 402, 404; 403, identifier:env; 404, identifier:Execute; 405, argument_list; 405, 406; 406, call; 406, 407; 406, 412; 407, attribute; 407, 408; 407, 411; 408, attribute; 408, 409; 408, 410; 409, identifier:SCons; 410, identifier:Action; 411, identifier:Action; 412, argument_list; 412, 413; 412, 414; 413, identifier:nop; 414, identifier:msg; 415, return_statement; 415, 416; 416, integer:0 | def _update_pot_file(target, source, env):
import re
import os
import SCons.Action
nop = lambda target, source, env: 0
save_cwd = env.fs.getcwd()
save_os_cwd = os.getcwd()
chdir = target[0].dir
chdir_str = repr(chdir.get_abspath())
env.Execute(SCons.Action.Action(nop, "Entering " + chdir_str))
env.fs.chdir(chdir, 1)
try:
cmd = _CmdRunner('$XGETTEXTCOM', '$XGETTEXTCOMSTR')
action = SCons.Action.Action(cmd, strfunction=cmd.strfunction)
status = action([target[0]], source, env)
except:
env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str))
env.fs.chdir(save_cwd, 0)
os.chdir(save_os_cwd)
raise
env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str))
env.fs.chdir(save_cwd, 0)
os.chdir(save_os_cwd)
if status: return status
new_content = cmd.out
if not new_content:
needs_update = False
explain = "no internationalized messages encountered"
else:
if target[0].exists():
old_content = target[0].get_text_contents()
re_cdate = re.compile(r'^"POT-Creation-Date: .*"$[\r\n]?', re.M)
old_content_nocdate = re.sub(re_cdate, "", old_content)
new_content_nocdate = re.sub(re_cdate, "", new_content)
if (old_content_nocdate == new_content_nocdate):
needs_update = False
explain = "messages in file found to be up-to-date"
else:
needs_update = True
explain = "messages in file were outdated"
else:
needs_update = True
explain = "new file"
if needs_update:
msg = "Writing " + repr(str(target[0])) + " (" + explain + ")"
env.Execute(SCons.Action.Action(nop, msg))
f = open(str(target[0]), "w")
f.write(new_content)
f.close()
return 0
else:
msg = "Not writing " + repr(str(target[0])) + " (" + explain + ")"
env.Execute(SCons.Action.Action(nop, msg))
return 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.