sequence
stringlengths 492
15.9k
| code
stringlengths 75
8.58k
|
---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:now; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 31; 5, 54; 5, 64; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:now; 9, None; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:d; 13, call; 13, 14; 13, 19; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:datetime; 17, identifier:datetime; 18, identifier:now; 19, argument_list; 19, 20; 20, keyword_argument; 20, 21; 20, 22; 21, identifier:tz; 22, attribute; 22, 23; 22, 30; 23, attribute; 23, 24; 23, 29; 24, subscript; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:days; 28, integer:0; 29, identifier:date; 30, identifier:tzinfo; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:for_total_seconds; 34, binary_operator:-; 34, 35; 34, 36; 34, 37; 35, identifier:d; 36, line_continuation:\; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:d; 40, identifier:replace; 41, argument_list; 41, 42; 41, 45; 41, 48; 41, 51; 42, keyword_argument; 42, 43; 42, 44; 43, identifier:hour; 44, integer:0; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:minute; 47, integer:0; 48, keyword_argument; 48, 49; 48, 50; 49, identifier:second; 50, integer:0; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:microsecond; 53, integer:0; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:msm; 57, binary_operator:/; 57, 58; 57, 63; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:for_total_seconds; 61, identifier:total_seconds; 62, argument_list; 63, integer:60; 64, if_statement; 64, 65; 64, 84; 64, 109; 64, 149; 65, comparison_operator:==; 65, 66; 65, 78; 66, call; 66, 67; 66, 76; 67, attribute; 67, 68; 67, 75; 68, attribute; 68, 69; 68, 74; 69, subscript; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:days; 73, integer:0; 74, identifier:date; 75, identifier:strftime; 76, argument_list; 76, 77; 77, string:"%Y-%m-%dZ"; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:d; 81, identifier:strftime; 82, argument_list; 82, 83; 83, string:"%Y-%m-%dZ"; 84, block; 84, 85; 84, 107; 85, for_statement; 85, 86; 85, 87; 85, 94; 86, identifier:timestep; 87, attribute; 87, 88; 87, 93; 88, subscript; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:days; 92, integer:0; 93, identifier:timesteps; 94, block; 94, 95; 94, 103; 95, if_statement; 95, 96; 95, 101; 96, comparison_operator:>; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:timestep; 99, identifier:name; 100, identifier:msm; 101, block; 101, 102; 102, break_statement; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:now; 106, identifier:timestep; 107, return_statement; 107, 108; 108, identifier:now; 109, elif_clause; 109, 110; 109, 133; 110, comparison_operator:<; 110, 111; 110, 132; 111, call; 111, 112; 111, 131; 112, attribute; 112, 113; 112, 130; 113, call; 113, 114; 113, 115; 114, identifier:abs; 115, argument_list; 115, 116; 116, binary_operator:-; 116, 117; 116, 129; 117, attribute; 117, 118; 117, 128; 118, subscript; 118, 119; 118, 126; 119, attribute; 119, 120; 119, 125; 120, subscript; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:self; 123, identifier:days; 124, integer:0; 125, identifier:timesteps; 126, unary_operator:-; 126, 127; 127, integer:1; 128, identifier:date; 129, identifier:d; 130, identifier:total_seconds; 131, argument_list; 132, integer:14400; 133, block; 133, 134; 133, 147; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:timestep_to_return; 137, subscript; 137, 138; 137, 145; 138, attribute; 138, 139; 138, 144; 139, subscript; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:days; 143, integer:0; 144, identifier:timesteps; 145, unary_operator:-; 145, 146; 146, integer:1; 147, return_statement; 147, 148; 148, identifier:timestep_to_return; 149, else_clause; 149, 150; 150, block; 150, 151; 151, return_statement; 151, 152; 152, False | def now(self):
now = None
d = datetime.datetime.now(tz=self.days[0].date.tzinfo)
for_total_seconds = d - \
d.replace(hour=0, minute=0, second=0, microsecond=0)
msm = for_total_seconds.total_seconds() / 60
if self.days[0].date.strftime("%Y-%m-%dZ") == d.strftime("%Y-%m-%dZ"):
for timestep in self.days[0].timesteps:
if timestep.name > msm:
break
now = timestep
return now
elif abs(self.days[0].timesteps[-1].date - d).total_seconds() < 14400:
timestep_to_return = self.days[0].timesteps[-1]
return timestep_to_return
else:
return False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:from_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:d; 6, block; 6, 7; 6, 13; 6, 17; 6, 23; 6, 107; 6, 189; 6, 202; 6, 210; 6, 221; 6, 227; 6, 242; 6, 247; 6, 253; 6, 268; 6, 273; 6, 280; 6, 287; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:main_memory; 10, call; 10, 11; 10, 12; 11, identifier:MainMemory; 12, argument_list; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:caches; 16, dictionary; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:referred_caches; 20, call; 20, 21; 20, 22; 21, identifier:set; 22, argument_list; 23, for_statement; 23, 24; 23, 27; 23, 32; 24, pattern_list; 24, 25; 24, 26; 25, identifier:name; 26, identifier:conf; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:d; 30, identifier:items; 31, argument_list; 32, block; 32, 33; 32, 65; 32, 79; 32, 93; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 38; 35, subscript; 35, 36; 35, 37; 36, identifier:caches; 37, identifier:name; 38, call; 38, 39; 38, 40; 39, identifier:Cache; 40, argument_list; 40, 41; 40, 44; 41, keyword_argument; 41, 42; 41, 43; 42, identifier:name; 43, identifier:name; 44, dictionary_splat; 44, 45; 45, dictionary_comprehension; 45, 46; 45, 49; 45, 58; 46, pair; 46, 47; 46, 48; 47, identifier:k; 48, identifier:v; 49, for_in_clause; 49, 50; 49, 53; 50, pattern_list; 50, 51; 50, 52; 51, identifier:k; 52, identifier:v; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:conf; 56, identifier:items; 57, argument_list; 58, if_clause; 58, 59; 59, comparison_operator:not; 59, 60; 59, 61; 60, identifier:k; 61, list:['store_to', 'load_from', 'victims_to']; 61, 62; 61, 63; 61, 64; 62, string:'store_to'; 63, string:'load_from'; 64, string:'victims_to'; 65, if_statement; 65, 66; 65, 69; 66, comparison_operator:in; 66, 67; 66, 68; 67, string:'store_to'; 68, identifier:conf; 69, block; 69, 70; 70, expression_statement; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:referred_caches; 74, identifier:add; 75, argument_list; 75, 76; 76, subscript; 76, 77; 76, 78; 77, identifier:conf; 78, string:'store_to'; 79, if_statement; 79, 80; 79, 83; 80, comparison_operator:in; 80, 81; 80, 82; 81, string:'load_from'; 82, identifier:conf; 83, block; 83, 84; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:referred_caches; 88, identifier:add; 89, argument_list; 89, 90; 90, subscript; 90, 91; 90, 92; 91, identifier:conf; 92, string:'load_from'; 93, if_statement; 93, 94; 93, 97; 94, comparison_operator:in; 94, 95; 94, 96; 95, string:'victims_to'; 96, identifier:conf; 97, block; 97, 98; 98, expression_statement; 98, 99; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:referred_caches; 102, identifier:add; 103, argument_list; 103, 104; 104, subscript; 104, 105; 104, 106; 105, identifier:conf; 106, string:'victims_to'; 107, for_statement; 107, 108; 107, 111; 107, 116; 108, pattern_list; 108, 109; 108, 110; 109, identifier:name; 110, identifier:conf; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:d; 114, identifier:items; 115, argument_list; 116, block; 116, 117; 116, 141; 116, 165; 117, if_statement; 117, 118; 117, 127; 118, boolean_operator:and; 118, 119; 118, 122; 119, comparison_operator:in; 119, 120; 119, 121; 120, string:'store_to'; 121, identifier:conf; 122, comparison_operator:is; 122, 123; 122, 126; 123, subscript; 123, 124; 123, 125; 124, identifier:conf; 125, string:'store_to'; 126, None; 127, block; 127, 128; 128, expression_statement; 128, 129; 129, call; 129, 130; 129, 135; 130, attribute; 130, 131; 130, 134; 131, subscript; 131, 132; 131, 133; 132, identifier:caches; 133, identifier:name; 134, identifier:set_store_to; 135, argument_list; 135, 136; 136, subscript; 136, 137; 136, 138; 137, identifier:caches; 138, subscript; 138, 139; 138, 140; 139, identifier:conf; 140, string:'store_to'; 141, if_statement; 141, 142; 141, 151; 142, boolean_operator:and; 142, 143; 142, 146; 143, comparison_operator:in; 143, 144; 143, 145; 144, string:'load_from'; 145, identifier:conf; 146, comparison_operator:is; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:conf; 149, string:'load_from'; 150, None; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, call; 153, 154; 153, 159; 154, attribute; 154, 155; 154, 158; 155, subscript; 155, 156; 155, 157; 156, identifier:caches; 157, identifier:name; 158, identifier:set_load_from; 159, argument_list; 159, 160; 160, subscript; 160, 161; 160, 162; 161, identifier:caches; 162, subscript; 162, 163; 162, 164; 163, identifier:conf; 164, string:'load_from'; 165, if_statement; 165, 166; 165, 175; 166, boolean_operator:and; 166, 167; 166, 170; 167, comparison_operator:in; 167, 168; 167, 169; 168, string:'victims_to'; 169, identifier:conf; 170, comparison_operator:is; 170, 171; 170, 174; 171, subscript; 171, 172; 171, 173; 172, identifier:conf; 173, string:'victims_to'; 174, None; 175, block; 175, 176; 176, expression_statement; 176, 177; 177, call; 177, 178; 177, 183; 178, attribute; 178, 179; 178, 182; 179, subscript; 179, 180; 179, 181; 180, identifier:caches; 181, identifier:name; 182, identifier:set_victims_to; 183, argument_list; 183, 184; 184, subscript; 184, 185; 184, 186; 185, identifier:caches; 186, subscript; 186, 187; 186, 188; 187, identifier:conf; 188, string:'victims_to'; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:first_level; 192, binary_operator:-; 192, 193; 192, 201; 193, call; 193, 194; 193, 195; 194, identifier:set; 195, argument_list; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:d; 199, identifier:keys; 200, argument_list; 201, identifier:referred_caches; 202, assert_statement; 202, 203; 202, 209; 203, comparison_operator:==; 203, 204; 203, 208; 204, call; 204, 205; 204, 206; 205, identifier:len; 206, argument_list; 206, 207; 207, identifier:first_level; 208, integer:1; 209, string:"Unable to find first cache level."; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:first_level; 213, subscript; 213, 214; 213, 215; 214, identifier:caches; 215, subscript; 215, 216; 215, 220; 216, call; 216, 217; 216, 218; 217, identifier:list; 218, argument_list; 218, 219; 219, identifier:first_level; 220, integer:0; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:last_level_load; 224, assignment; 224, 225; 224, 226; 225, identifier:c; 226, identifier:first_level; 227, while_statement; 227, 228; 227, 231; 228, comparison_operator:is; 228, 229; 228, 230; 229, identifier:c; 230, None; 231, block; 231, 232; 231, 236; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:last_level_load; 235, identifier:c; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:c; 239, attribute; 239, 240; 239, 241; 240, identifier:c; 241, identifier:load_from; 242, assert_statement; 242, 243; 242, 246; 243, comparison_operator:is; 243, 244; 243, 245; 244, identifier:last_level_load; 245, None; 246, string:"Unable to find last cache level."; 247, expression_statement; 247, 248; 248, assignment; 248, 249; 248, 250; 249, identifier:last_level_store; 250, assignment; 250, 251; 250, 252; 251, identifier:c; 252, identifier:first_level; 253, while_statement; 253, 254; 253, 257; 254, comparison_operator:is; 254, 255; 254, 256; 255, identifier:c; 256, None; 257, block; 257, 258; 257, 262; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:last_level_store; 261, identifier:c; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 265; 264, identifier:c; 265, attribute; 265, 266; 265, 267; 266, identifier:c; 267, identifier:store_to; 268, assert_statement; 268, 269; 268, 272; 269, comparison_operator:is; 269, 270; 269, 271; 270, identifier:last_level_store; 271, None; 272, string:"Unable to find last cache level."; 273, expression_statement; 273, 274; 274, call; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:main_memory; 277, identifier:load_to; 278, argument_list; 278, 279; 279, identifier:last_level_load; 280, expression_statement; 280, 281; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:main_memory; 284, identifier:store_from; 285, argument_list; 285, 286; 286, identifier:last_level_store; 287, return_statement; 287, 288; 288, expression_list; 288, 289; 288, 294; 288, 295; 289, call; 289, 290; 289, 291; 290, identifier:cls; 291, argument_list; 291, 292; 291, 293; 292, identifier:first_level; 293, identifier:main_memory; 294, identifier:caches; 295, identifier:main_memory | def from_dict(cls, d):
main_memory = MainMemory()
caches = {}
referred_caches = set()
for name, conf in d.items():
caches[name] = Cache(name=name,
**{k: v for k, v in conf.items()
if k not in ['store_to', 'load_from', 'victims_to']})
if 'store_to' in conf:
referred_caches.add(conf['store_to'])
if 'load_from' in conf:
referred_caches.add(conf['load_from'])
if 'victims_to' in conf:
referred_caches.add(conf['victims_to'])
for name, conf in d.items():
if 'store_to' in conf and conf['store_to'] is not None:
caches[name].set_store_to(caches[conf['store_to']])
if 'load_from' in conf and conf['load_from'] is not None:
caches[name].set_load_from(caches[conf['load_from']])
if 'victims_to' in conf and conf['victims_to'] is not None:
caches[name].set_victims_to(caches[conf['victims_to']])
first_level = set(d.keys()) - referred_caches
assert len(first_level) == 1, "Unable to find first cache level."
first_level = caches[list(first_level)[0]]
last_level_load = c = first_level
while c is not None:
last_level_load = c
c = c.load_from
assert last_level_load is not None, "Unable to find last cache level."
last_level_store = c = first_level
while c is not None:
last_level_store = c
c = c.store_to
assert last_level_store is not None, "Unable to find last cache level."
main_memory.load_to(last_level_load)
main_memory.store_from(last_level_store)
return cls(first_level, main_memory), caches, main_memory |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_object_getattr; 3, parameters; 3, 4; 3, 5; 4, identifier:obj; 5, identifier:field; 6, block; 6, 7; 6, 9; 6, 13; 6, 39; 7, expression_statement; 7, 8; 8, string:'''Attribute getter for the objects to operate on.
This function can be overridden in classes or instances of Query, Filter, and
Order. Thus, a custom function to extract values to attributes can be
specified, and the system can remain agnostic to the client's data model,
without loosing query power.
For example, the default implementation works with attributes and items::
def _object_getattr(obj, field):
if hasattr(obj, field):
value = getattr(obj, field)
elif field in obj:
value = obj[field]
return value
Or consider a more complex, application-specific structure::
def _object_getattr(version, field):
if field in ['key', 'committed', 'created', 'hash']:
return getattr(version, field)
else:
return version.attributes[field]['value']
'''; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:value; 12, None; 13, if_statement; 13, 14; 13, 19; 13, 28; 14, call; 14, 15; 14, 16; 15, identifier:hasattr; 16, argument_list; 16, 17; 16, 18; 17, identifier:obj; 18, identifier:field; 19, block; 19, 20; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:value; 23, call; 23, 24; 23, 25; 24, identifier:getattr; 25, argument_list; 25, 26; 25, 27; 26, identifier:obj; 27, identifier:field; 28, elif_clause; 28, 29; 28, 32; 29, comparison_operator:in; 29, 30; 29, 31; 30, identifier:field; 31, identifier:obj; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:value; 36, subscript; 36, 37; 36, 38; 37, identifier:obj; 38, identifier:field; 39, return_statement; 39, 40; 40, identifier:value | def _object_getattr(obj, field):
'''Attribute getter for the objects to operate on.
This function can be overridden in classes or instances of Query, Filter, and
Order. Thus, a custom function to extract values to attributes can be
specified, and the system can remain agnostic to the client's data model,
without loosing query power.
For example, the default implementation works with attributes and items::
def _object_getattr(obj, field):
if hasattr(obj, field):
value = getattr(obj, field)
elif field in obj:
value = obj[field]
return value
Or consider a more complex, application-specific structure::
def _object_getattr(version, field):
if field in ['key', 'committed', 'created', 'hash']:
return getattr(version, field)
else:
return version.attributes[field]['value']
'''
value = None
if hasattr(obj, field):
value = getattr(obj, field)
elif field in obj:
value = obj[field]
return value |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:items; 6, identifier:orders; 7, block; 7, 8; 7, 10; 8, expression_statement; 8, 9; 9, string:'''Returns the elements in `items` sorted according to `orders`'''; 10, return_statement; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:sorted; 13, argument_list; 13, 14; 13, 15; 14, identifier:items; 15, keyword_argument; 15, 16; 15, 17; 16, identifier:cmp; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:cls; 20, identifier:multipleOrderComparison; 21, argument_list; 21, 22; 22, identifier:orders | def sorted(cls, items, orders):
'''Returns the elements in `items` sorted according to `orders`'''
return sorted(items, cmp=cls.multipleOrderComparison(orders)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_unique_fields; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 41; 6, for_statement; 6, 7; 6, 8; 6, 13; 7, identifier:unique_together; 8, attribute; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:_meta; 12, identifier:unique_together; 13, block; 13, 14; 14, if_statement; 14, 15; 14, 18; 15, comparison_operator:in; 15, 16; 15, 17; 16, string:'sort_order'; 17, identifier:unique_together; 18, block; 18, 19; 18, 26; 18, 33; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:unique_fields; 22, call; 22, 23; 22, 24; 23, identifier:list; 24, argument_list; 24, 25; 25, identifier:unique_together; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:unique_fields; 30, identifier:remove; 31, argument_list; 31, 32; 32, string:'sort_order'; 33, return_statement; 33, 34; 34, list_comprehension; 34, 35; 34, 38; 35, binary_operator:%; 35, 36; 35, 37; 36, string:'%s_id'; 37, identifier:f; 38, for_in_clause; 38, 39; 38, 40; 39, identifier:f; 40, identifier:unique_fields; 41, return_statement; 41, 42; 42, list:[] | def get_unique_fields(self):
for unique_together in self._meta.unique_together:
if 'sort_order' in unique_together:
unique_fields = list(unique_together)
unique_fields.remove('sort_order')
return ['%s_id' % f for f in unique_fields]
return [] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_is_sort_order_unique_together_with_something; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 32; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:unique_together; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:_meta; 13, identifier:unique_together; 14, for_statement; 14, 15; 14, 16; 14, 17; 15, identifier:fields; 16, identifier:unique_together; 17, block; 17, 18; 18, if_statement; 18, 19; 18, 29; 19, boolean_operator:and; 19, 20; 19, 23; 20, comparison_operator:in; 20, 21; 20, 22; 21, string:'sort_order'; 22, identifier:fields; 23, comparison_operator:>; 23, 24; 23, 28; 24, call; 24, 25; 24, 26; 25, identifier:len; 26, argument_list; 26, 27; 27, identifier:fields; 28, integer:1; 29, block; 29, 30; 30, return_statement; 30, 31; 31, True; 32, return_statement; 32, 33; 33, False | def _is_sort_order_unique_together_with_something(self):
unique_together = self._meta.unique_together
for fields in unique_together:
if 'sort_order' in fields and len(fields) > 1:
return True
return False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_update; 3, parameters; 3, 4; 4, identifier:qs; 5, block; 5, 6; 6, try_statement; 6, 7; 6, 33; 7, block; 7, 8; 8, with_statement; 8, 9; 8, 16; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:transaction; 14, identifier:atomic; 15, argument_list; 16, block; 16, 17; 17, expression_statement; 17, 18; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:qs; 21, identifier:update; 22, argument_list; 22, 23; 23, keyword_argument; 23, 24; 23, 25; 24, identifier:sort_order; 25, binary_operator:+; 25, 26; 25, 32; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:models; 29, identifier:F; 30, argument_list; 30, 31; 31, string:'sort_order'; 32, integer:1; 33, except_clause; 33, 34; 33, 35; 34, identifier:IntegrityError; 35, block; 35, 36; 36, for_statement; 36, 37; 36, 38; 36, 44; 37, identifier:obj; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:qs; 41, identifier:order_by; 42, argument_list; 42, 43; 43, string:'-sort_order'; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, call; 46, 47; 46, 59; 47, attribute; 47, 48; 47, 58; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:qs; 51, identifier:filter; 52, argument_list; 52, 53; 53, keyword_argument; 53, 54; 53, 55; 54, identifier:pk; 55, attribute; 55, 56; 55, 57; 56, identifier:obj; 57, identifier:pk; 58, identifier:update; 59, argument_list; 59, 60; 60, keyword_argument; 60, 61; 60, 62; 61, identifier:sort_order; 62, binary_operator:+; 62, 63; 62, 69; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:models; 66, identifier:F; 67, argument_list; 67, 68; 68, string:'sort_order'; 69, integer:1 | def _update(qs):
try:
with transaction.atomic():
qs.update(sort_order=models.F('sort_order') + 1)
except IntegrityError:
for obj in qs.order_by('-sort_order'):
qs.filter(pk=obj.pk).update(sort_order=models.F('sort_order') + 1) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_orders; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:object_pks; 6, block; 6, 7; 6, 18; 6, 42; 6, 57; 6, 105; 6, 156; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:objects_to_sort; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:filter; 14, argument_list; 14, 15; 15, keyword_argument; 15, 16; 15, 17; 16, identifier:pk__in; 17, identifier:object_pks; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:max_value; 21, subscript; 21, 22; 21, 41; 22, call; 22, 23; 22, 34; 23, attribute; 23, 24; 23, 33; 24, call; 24, 25; 24, 32; 25, attribute; 25, 26; 25, 31; 26, attribute; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:model; 30, identifier:objects; 31, identifier:all; 32, argument_list; 33, identifier:aggregate; 34, argument_list; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:models; 38, identifier:Max; 39, argument_list; 39, 40; 40, string:'sort_order'; 41, string:'sort_order__max'; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:orders; 45, call; 45, 46; 45, 47; 46, identifier:list; 47, argument_list; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:objects_to_sort; 51, identifier:values_list; 52, argument_list; 52, 53; 52, 54; 53, string:'sort_order'; 54, keyword_argument; 54, 55; 54, 56; 55, identifier:flat; 56, True; 57, if_statement; 57, 58; 57, 67; 58, comparison_operator:!=; 58, 59; 58, 63; 59, call; 59, 60; 59, 61; 60, identifier:len; 61, argument_list; 61, 62; 62, identifier:orders; 63, call; 63, 64; 63, 65; 64, identifier:len; 65, argument_list; 65, 66; 66, identifier:object_pks; 67, block; 67, 68; 67, 83; 67, 100; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:pks; 71, call; 71, 72; 71, 73; 72, identifier:set; 73, argument_list; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:objects_to_sort; 77, identifier:values_list; 78, argument_list; 78, 79; 78, 80; 79, string:'pk'; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:flat; 82, True; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:message; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, string:'The following object_pks are not in this queryset: {}'; 89, identifier:format; 90, argument_list; 90, 91; 91, list_comprehension; 91, 92; 91, 93; 91, 96; 92, identifier:pk; 93, for_in_clause; 93, 94; 93, 95; 94, identifier:pk; 95, identifier:object_pks; 96, if_clause; 96, 97; 97, comparison_operator:not; 97, 98; 97, 99; 98, identifier:pk; 99, identifier:pks; 100, raise_statement; 100, 101; 101, call; 101, 102; 101, 103; 102, identifier:TypeError; 103, argument_list; 103, 104; 104, identifier:message; 105, with_statement; 105, 106; 105, 113; 106, with_clause; 106, 107; 107, with_item; 107, 108; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:transaction; 111, identifier:atomic; 112, argument_list; 113, block; 113, 114; 113, 130; 114, expression_statement; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:objects_to_sort; 118, identifier:update; 119, argument_list; 119, 120; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:sort_order; 122, binary_operator:+; 122, 123; 122, 129; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:models; 126, identifier:F; 127, argument_list; 127, 128; 128, string:'sort_order'; 129, identifier:max_value; 130, for_statement; 130, 131; 130, 134; 130, 139; 131, pattern_list; 131, 132; 131, 133; 132, identifier:pk; 133, identifier:order; 134, call; 134, 135; 134, 136; 135, identifier:zip; 136, argument_list; 136, 137; 136, 138; 137, identifier:object_pks; 138, identifier:orders; 139, block; 139, 140; 140, expression_statement; 140, 141; 141, call; 141, 142; 141, 152; 142, attribute; 142, 143; 142, 151; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:self; 146, identifier:filter; 147, argument_list; 147, 148; 148, keyword_argument; 148, 149; 148, 150; 149, identifier:pk; 150, identifier:pk; 151, identifier:update; 152, argument_list; 152, 153; 153, keyword_argument; 153, 154; 153, 155; 154, identifier:sort_order; 155, identifier:order; 156, return_statement; 156, 157; 157, identifier:objects_to_sort | def set_orders(self, object_pks):
objects_to_sort = self.filter(pk__in=object_pks)
max_value = self.model.objects.all().aggregate(
models.Max('sort_order')
)['sort_order__max']
orders = list(objects_to_sort.values_list('sort_order', flat=True))
if len(orders) != len(object_pks):
pks = set(objects_to_sort.values_list('pk', flat=True))
message = 'The following object_pks are not in this queryset: {}'.format(
[pk for pk in object_pks if pk not in pks]
)
raise TypeError(message)
with transaction.atomic():
objects_to_sort.update(sort_order=models.F('sort_order') + max_value)
for pk, order in zip(object_pks, orders):
self.filter(pk=pk).update(sort_order=order)
return objects_to_sort |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:merge_records; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:env; 5, identifier:model_name; 6, identifier:record_ids; 7, identifier:target_record_id; 8, default_parameter; 8, 9; 8, 10; 9, identifier:field_spec; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:method; 13, string:'orm'; 14, default_parameter; 14, 15; 14, 16; 15, identifier:delete; 16, True; 17, default_parameter; 17, 18; 17, 19; 18, identifier:exclude_columns; 19, None; 20, block; 20, 21; 20, 30; 20, 39; 20, 53; 20, 61; 20, 68; 20, 75; 20, 87; 20, 104; 20, 109; 20, 118; 21, if_statement; 21, 22; 21, 25; 22, comparison_operator:is; 22, 23; 22, 24; 23, identifier:exclude_columns; 24, None; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:exclude_columns; 29, list:[]; 30, if_statement; 30, 31; 30, 34; 31, comparison_operator:is; 31, 32; 31, 33; 32, identifier:field_spec; 33, None; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:field_spec; 38, dictionary; 39, if_statement; 39, 40; 39, 45; 40, call; 40, 41; 40, 42; 41, identifier:isinstance; 42, argument_list; 42, 43; 42, 44; 43, identifier:record_ids; 44, identifier:list; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:record_ids; 49, call; 49, 50; 49, 51; 50, identifier:tuple; 51, argument_list; 51, 52; 52, identifier:record_ids; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:args0; 56, tuple; 56, 57; 56, 58; 56, 59; 56, 60; 57, identifier:env; 58, identifier:model_name; 59, identifier:record_ids; 60, identifier:target_record_id; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:args; 64, binary_operator:+; 64, 65; 64, 66; 65, identifier:args0; 66, tuple; 66, 67; 67, identifier:exclude_columns; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:args2; 71, binary_operator:+; 71, 72; 71, 73; 72, identifier:args0; 73, tuple; 73, 74; 74, identifier:field_spec; 75, if_statement; 75, 76; 75, 79; 76, comparison_operator:in; 76, 77; 76, 78; 77, identifier:target_record_id; 78, identifier:record_ids; 79, block; 79, 80; 80, raise_statement; 80, 81; 81, call; 81, 82; 81, 83; 82, identifier:Exception; 83, argument_list; 83, 84; 84, concatenated_string; 84, 85; 84, 86; 85, string:"You can't put the target record in the list or "; 86, string:"records to be merged."; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:record_ids; 90, attribute; 90, 91; 90, 103; 91, call; 91, 92; 91, 102; 92, attribute; 92, 93; 92, 101; 93, call; 93, 94; 93, 99; 94, attribute; 94, 95; 94, 98; 95, subscript; 95, 96; 95, 97; 96, identifier:env; 97, identifier:model_name; 98, identifier:browse; 99, argument_list; 99, 100; 100, identifier:record_ids; 101, identifier:exists; 102, argument_list; 103, identifier:ids; 104, if_statement; 104, 105; 104, 107; 105, not_operator; 105, 106; 106, identifier:record_ids; 107, block; 107, 108; 108, return_statement; 109, expression_statement; 109, 110; 110, call; 110, 111; 110, 112; 111, identifier:_change_generic; 112, argument_list; 112, 113; 112, 115; 113, list_splat; 113, 114; 114, identifier:args; 115, keyword_argument; 115, 116; 115, 117; 116, identifier:method; 117, identifier:method; 118, if_statement; 118, 119; 118, 122; 118, 181; 119, comparison_operator:==; 119, 120; 119, 121; 120, identifier:method; 121, string:'orm'; 122, block; 122, 123; 122, 129; 122, 135; 122, 141; 122, 147; 122, 162; 122, 170; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 126; 125, identifier:_change_many2one_refs_orm; 126, argument_list; 126, 127; 127, list_splat; 127, 128; 128, identifier:args; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 132; 131, identifier:_change_many2many_refs_orm; 132, argument_list; 132, 133; 133, list_splat; 133, 134; 134, identifier:args; 135, expression_statement; 135, 136; 136, call; 136, 137; 136, 138; 137, identifier:_change_reference_refs_orm; 138, argument_list; 138, 139; 139, list_splat; 139, 140; 140, identifier:args; 141, expression_statement; 141, 142; 142, call; 142, 143; 142, 144; 143, identifier:_change_translations_orm; 144, argument_list; 144, 145; 145, list_splat; 145, 146; 146, identifier:args; 147, with_statement; 147, 148; 147, 155; 148, with_clause; 148, 149; 149, with_item; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:env; 153, identifier:norecompute; 154, argument_list; 155, block; 155, 156; 156, expression_statement; 156, 157; 157, call; 157, 158; 157, 159; 158, identifier:_adjust_merged_values_orm; 159, argument_list; 159, 160; 160, list_splat; 160, 161; 161, identifier:args2; 162, expression_statement; 162, 163; 163, call; 163, 164; 163, 169; 164, attribute; 164, 165; 164, 168; 165, subscript; 165, 166; 165, 167; 166, identifier:env; 167, identifier:model_name; 168, identifier:recompute; 169, argument_list; 170, if_statement; 170, 171; 170, 172; 171, identifier:delete; 172, block; 172, 173; 173, expression_statement; 173, 174; 174, call; 174, 175; 174, 176; 175, identifier:_delete_records_orm; 176, argument_list; 176, 177; 176, 178; 176, 179; 176, 180; 177, identifier:env; 178, identifier:model_name; 179, identifier:record_ids; 180, identifier:target_record_id; 181, else_clause; 181, 182; 182, block; 182, 183; 182, 189; 182, 195; 182, 201; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 186; 185, identifier:_change_foreign_key_refs; 186, argument_list; 186, 187; 187, list_splat; 187, 188; 188, identifier:args; 189, expression_statement; 189, 190; 190, call; 190, 191; 190, 192; 191, identifier:_change_reference_refs_sql; 192, argument_list; 192, 193; 193, list_splat; 193, 194; 194, identifier:args; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 198; 197, identifier:_change_translations_sql; 198, argument_list; 198, 199; 199, list_splat; 199, 200; 200, identifier:args; 201, if_statement; 201, 202; 201, 203; 202, identifier:delete; 203, block; 203, 204; 204, expression_statement; 204, 205; 205, call; 205, 206; 205, 207; 206, identifier:_delete_records_sql; 207, argument_list; 207, 208; 207, 209; 207, 210; 207, 211; 208, identifier:env; 209, identifier:model_name; 210, identifier:record_ids; 211, identifier:target_record_id | def merge_records(env, model_name, record_ids, target_record_id,
field_spec=None, method='orm', delete=True,
exclude_columns=None):
if exclude_columns is None:
exclude_columns = []
if field_spec is None:
field_spec = {}
if isinstance(record_ids, list):
record_ids = tuple(record_ids)
args0 = (env, model_name, record_ids, target_record_id)
args = args0 + (exclude_columns, )
args2 = args0 + (field_spec, )
if target_record_id in record_ids:
raise Exception("You can't put the target record in the list or "
"records to be merged.")
record_ids = env[model_name].browse(record_ids).exists().ids
if not record_ids:
return
_change_generic(*args, method=method)
if method == 'orm':
_change_many2one_refs_orm(*args)
_change_many2many_refs_orm(*args)
_change_reference_refs_orm(*args)
_change_translations_orm(*args)
with env.norecompute():
_adjust_merged_values_orm(*args2)
env[model_name].recompute()
if delete:
_delete_records_orm(env, model_name, record_ids, target_record_id)
else:
_change_foreign_key_refs(*args)
_change_reference_refs_sql(*args)
_change_translations_sql(*args)
if delete:
_delete_records_sql(env, model_name, record_ids, target_record_id) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_existing_records; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cr; 5, identifier:fp; 6, identifier:module_name; 7, block; 7, 8; 7, 146; 8, function_definition; 8, 9; 8, 10; 8, 15; 9, function_name:yield_element; 10, parameters; 10, 11; 10, 12; 11, identifier:node; 12, default_parameter; 12, 13; 12, 14; 13, identifier:path; 14, None; 15, block; 15, 16; 16, if_statement; 16, 17; 16, 25; 16, 105; 17, comparison_operator:not; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:node; 20, identifier:tag; 21, list:['openerp', 'odoo', 'data']; 21, 22; 21, 23; 21, 24; 22, string:'openerp'; 23, string:'odoo'; 24, string:'data'; 25, block; 25, 26; 25, 81; 25, 96; 25, 102; 26, if_statement; 26, 27; 26, 32; 27, comparison_operator:==; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:node; 30, identifier:tag; 31, string:'record'; 32, block; 32, 33; 32, 41; 32, 64; 32, 74; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:xmlid; 36, subscript; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:node; 39, identifier:attrib; 40, string:'id'; 41, if_statement; 41, 42; 41, 45; 41, 50; 42, comparison_operator:not; 42, 43; 42, 44; 43, string:'.'; 44, identifier:xmlid; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:module; 49, identifier:module_name; 50, else_clause; 50, 51; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 57; 54, pattern_list; 54, 55; 54, 56; 55, identifier:module; 56, identifier:xmlid; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:xmlid; 60, identifier:split; 61, argument_list; 61, 62; 61, 63; 62, string:'.'; 63, integer:1; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:cr; 68, identifier:execute; 69, argument_list; 69, 70; 69, 71; 70, string:'select id from ir_model_data where module=%s and name=%s'; 71, tuple; 71, 72; 71, 73; 72, identifier:module; 73, identifier:xmlid; 74, if_statement; 74, 75; 74, 79; 75, not_operator; 75, 76; 76, attribute; 76, 77; 76, 78; 77, identifier:cr; 78, identifier:rowcount; 79, block; 79, 80; 80, return_statement; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:result; 84, call; 84, 85; 84, 86; 85, identifier:StringIO; 86, argument_list; 86, 87; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:etree; 90, identifier:tostring; 91, argument_list; 91, 92; 91, 93; 92, identifier:path; 93, keyword_argument; 93, 94; 93, 95; 94, identifier:encoding; 95, string:'unicode'; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:result; 100, identifier:name; 101, None; 102, expression_statement; 102, 103; 103, yield; 103, 104; 104, identifier:result; 105, else_clause; 105, 106; 106, block; 106, 107; 107, for_statement; 107, 108; 107, 109; 107, 110; 108, identifier:child; 109, identifier:node; 110, block; 110, 111; 111, for_statement; 111, 112; 111, 113; 111, 142; 112, identifier:value; 113, call; 113, 114; 113, 115; 114, identifier:yield_element; 115, argument_list; 115, 116; 115, 117; 116, identifier:child; 117, conditional_expression:if; 117, 118; 117, 130; 117, 131; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:etree; 121, identifier:SubElement; 122, argument_list; 122, 123; 122, 124; 122, 127; 123, identifier:path; 124, attribute; 124, 125; 124, 126; 125, identifier:node; 126, identifier:tag; 127, attribute; 127, 128; 127, 129; 128, identifier:node; 129, identifier:attrib; 130, identifier:path; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:etree; 134, identifier:Element; 135, argument_list; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:node; 138, identifier:tag; 139, attribute; 139, 140; 139, 141; 140, identifier:node; 141, identifier:attrib; 142, block; 142, 143; 143, expression_statement; 143, 144; 144, yield; 144, 145; 145, identifier:value; 146, return_statement; 146, 147; 147, call; 147, 148; 147, 149; 148, identifier:yield_element; 149, argument_list; 149, 150; 150, call; 150, 151; 150, 159; 151, attribute; 151, 152; 151, 158; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:etree; 155, identifier:parse; 156, argument_list; 156, 157; 157, identifier:fp; 158, identifier:getroot; 159, argument_list | def _get_existing_records(cr, fp, module_name):
def yield_element(node, path=None):
if node.tag not in ['openerp', 'odoo', 'data']:
if node.tag == 'record':
xmlid = node.attrib['id']
if '.' not in xmlid:
module = module_name
else:
module, xmlid = xmlid.split('.', 1)
cr.execute(
'select id from ir_model_data where module=%s and name=%s',
(module, xmlid)
)
if not cr.rowcount:
return
result = StringIO(etree.tostring(path, encoding='unicode'))
result.name = None
yield result
else:
for child in node:
for value in yield_element(
child,
etree.SubElement(path, node.tag, node.attrib)
if path else etree.Element(node.tag, node.attrib)
):
yield value
return yield_element(etree.parse(fp).getroot()) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:check_ab; 3, parameters; 3, 4; 3, 5; 4, identifier:ab; 5, identifier:verb; 6, block; 6, 7; 6, 9; 6, 27; 6, 67; 6, 96; 6, 107; 6, 115; 6, 123; 6, 155; 6, 187; 7, expression_statement; 7, 8; 8, identifier:r; 9, try_statement; 9, 10; 9, 18; 10, block; 10, 11; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:ab; 14, call; 14, 15; 14, 16; 15, identifier:int; 16, argument_list; 16, 17; 17, identifier:ab; 18, except_clause; 18, 19; 18, 20; 19, identifier:VariableCatch; 20, block; 20, 21; 20, 26; 21, expression_statement; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:print; 24, argument_list; 24, 25; 25, string:'* ERROR :: <ab> must be an integer'; 26, raise_statement; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:pab; 30, list:[11, 12, 13, 14, 15, 16, 21, 22, 23, 24, 25, 26,
31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 45, 46,
51, 52, 53, 54, 55, 56, 61, 62, 63, 64, 65, 66]; 30, 31; 30, 32; 30, 33; 30, 34; 30, 35; 30, 36; 30, 37; 30, 38; 30, 39; 30, 40; 30, 41; 30, 42; 30, 43; 30, 44; 30, 45; 30, 46; 30, 47; 30, 48; 30, 49; 30, 50; 30, 51; 30, 52; 30, 53; 30, 54; 30, 55; 30, 56; 30, 57; 30, 58; 30, 59; 30, 60; 30, 61; 30, 62; 30, 63; 30, 64; 30, 65; 30, 66; 31, integer:11; 32, integer:12; 33, integer:13; 34, integer:14; 35, integer:15; 36, integer:16; 37, integer:21; 38, integer:22; 39, integer:23; 40, integer:24; 41, integer:25; 42, integer:26; 43, integer:31; 44, integer:32; 45, integer:33; 46, integer:34; 47, integer:35; 48, integer:36; 49, integer:41; 50, integer:42; 51, integer:43; 52, integer:44; 53, integer:45; 54, integer:46; 55, integer:51; 56, integer:52; 57, integer:53; 58, integer:54; 59, integer:55; 60, integer:56; 61, integer:61; 62, integer:62; 63, integer:63; 64, integer:64; 65, integer:65; 66, integer:66; 67, if_statement; 67, 68; 67, 71; 68, comparison_operator:not; 68, 69; 68, 70; 69, identifier:ab; 70, identifier:pab; 71, block; 71, 72; 71, 91; 72, expression_statement; 72, 73; 73, call; 73, 74; 73, 75; 74, identifier:print; 75, argument_list; 75, 76; 76, binary_operator:+; 76, 77; 76, 87; 77, binary_operator:+; 77, 78; 77, 86; 78, binary_operator:+; 78, 79; 78, 85; 79, binary_operator:+; 79, 80; 79, 81; 80, string:'* ERROR :: <ab> must be one of: '; 81, call; 81, 82; 81, 83; 82, identifier:str; 83, argument_list; 83, 84; 84, identifier:pab; 85, string:';'; 86, string:' <ab> provided: '; 87, call; 87, 88; 87, 89; 88, identifier:str; 89, argument_list; 89, 90; 90, identifier:ab; 91, raise_statement; 91, 92; 92, call; 92, 93; 92, 94; 93, identifier:ValueError; 94, argument_list; 94, 95; 95, string:'ab'; 96, if_statement; 96, 97; 96, 100; 97, comparison_operator:>; 97, 98; 97, 99; 98, identifier:verb; 99, integer:2; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, call; 102, 103; 102, 104; 103, identifier:print; 104, argument_list; 104, 105; 104, 106; 105, string:" Input ab : "; 106, identifier:ab; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:msrc; 110, comparison_operator:>; 110, 111; 110, 114; 111, binary_operator:%; 111, 112; 111, 113; 112, identifier:ab; 113, integer:10; 114, integer:3; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:mrec; 118, comparison_operator:>; 118, 119; 118, 122; 119, binary_operator://; 119, 120; 119, 121; 120, identifier:ab; 121, integer:10; 122, integer:3; 123, if_statement; 123, 124; 123, 125; 123, 149; 124, identifier:mrec; 125, block; 125, 126; 126, if_statement; 126, 127; 126, 128; 126, 135; 127, identifier:msrc; 128, block; 128, 129; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:ab_calc; 132, binary_operator:-; 132, 133; 132, 134; 133, identifier:ab; 134, integer:33; 135, else_clause; 135, 136; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:ab_calc; 140, binary_operator:+; 140, 141; 140, 146; 141, binary_operator:*; 141, 142; 141, 145; 142, binary_operator:%; 142, 143; 142, 144; 143, identifier:ab; 144, integer:10; 145, integer:10; 146, binary_operator://; 146, 147; 146, 148; 147, identifier:ab; 148, integer:10; 149, else_clause; 149, 150; 150, block; 150, 151; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:ab_calc; 154, identifier:ab; 155, if_statement; 155, 156; 155, 159; 156, comparison_operator:>; 156, 157; 156, 158; 157, identifier:verb; 158, integer:2; 159, block; 159, 160; 160, if_statement; 160, 161; 160, 166; 160, 179; 161, comparison_operator:in; 161, 162; 161, 163; 162, identifier:ab; 163, list:[36, 63]; 163, 164; 163, 165; 164, integer:36; 165, integer:63; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 170; 169, identifier:print; 170, argument_list; 170, 171; 171, binary_operator:+; 171, 172; 171, 178; 172, binary_operator:+; 172, 173; 172, 174; 173, string:"\n> <ab> IS "; 174, call; 174, 175; 174, 176; 175, identifier:str; 176, argument_list; 176, 177; 177, identifier:ab; 178, string:" WHICH IS ZERO; returning"; 179, else_clause; 179, 180; 180, block; 180, 181; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 184; 183, identifier:print; 184, argument_list; 184, 185; 184, 186; 185, string:" Calculated ab : "; 186, identifier:ab_calc; 187, return_statement; 187, 188; 188, expression_list; 188, 189; 188, 190; 188, 191; 189, identifier:ab_calc; 190, identifier:msrc; 191, identifier:mrec | def check_ab(ab, verb):
r
try:
ab = int(ab)
except VariableCatch:
print('* ERROR :: <ab> must be an integer')
raise
pab = [11, 12, 13, 14, 15, 16, 21, 22, 23, 24, 25, 26,
31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 45, 46,
51, 52, 53, 54, 55, 56, 61, 62, 63, 64, 65, 66]
if ab not in pab:
print('* ERROR :: <ab> must be one of: ' + str(pab) + ';' +
' <ab> provided: ' + str(ab))
raise ValueError('ab')
if verb > 2:
print(" Input ab : ", ab)
msrc = ab % 10 > 3
mrec = ab // 10 > 3
if mrec:
if msrc:
ab_calc = ab - 33
else:
ab_calc = ab % 10*10 + ab // 10
else:
ab_calc = ab
if verb > 2:
if ab in [36, 63]:
print("\n> <ab> IS "+str(ab)+" WHICH IS ZERO; returning")
else:
print(" Calculated ab : ", ab_calc)
return ab_calc, msrc, mrec |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:check_opt; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:opt; 5, identifier:loop; 6, identifier:ht; 7, identifier:htarg; 8, identifier:verb; 9, block; 9, 10; 9, 12; 9, 16; 9, 40; 9, 44; 9, 60; 9, 91; 9, 134; 10, expression_statement; 10, 11; 11, identifier:r; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:use_ne_eval; 15, False; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:==; 17, 18; 17, 19; 18, identifier:opt; 19, string:'parallel'; 20, block; 20, 21; 21, if_statement; 21, 22; 21, 23; 21, 30; 22, identifier:numexpr; 23, block; 23, 24; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:use_ne_eval; 27, attribute; 27, 28; 27, 29; 28, identifier:numexpr; 29, identifier:evaluate; 30, elif_clause; 30, 31; 30, 34; 31, comparison_operator:>; 31, 32; 31, 33; 32, identifier:verb; 33, integer:0; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:print; 38, argument_list; 38, 39; 39, identifier:numexpr_msg; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:lagged_splined_fht; 43, False; 44, if_statement; 44, 45; 44, 48; 45, comparison_operator:==; 45, 46; 45, 47; 46, identifier:ht; 47, string:'fht'; 48, block; 48, 49; 49, if_statement; 49, 50; 49, 55; 50, comparison_operator:!=; 50, 51; 50, 54; 51, subscript; 51, 52; 51, 53; 52, identifier:htarg; 53, integer:1; 54, integer:0; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:lagged_splined_fht; 59, True; 60, if_statement; 60, 61; 60, 68; 60, 77; 61, boolean_operator:or; 61, 62; 61, 67; 62, comparison_operator:in; 62, 63; 62, 64; 63, identifier:ht; 64, list:['hqwe', 'hquad']; 64, 65; 64, 66; 65, string:'hqwe'; 66, string:'hquad'; 67, identifier:lagged_splined_fht; 68, block; 68, 69; 68, 73; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:loop_freq; 72, True; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:loop_off; 76, False; 77, else_clause; 77, 78; 78, block; 78, 79; 78, 85; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:loop_off; 82, comparison_operator:==; 82, 83; 82, 84; 83, identifier:loop; 84, string:'off'; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:loop_freq; 88, comparison_operator:==; 88, 89; 88, 90; 89, identifier:loop; 90, string:'freq'; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:>; 92, 93; 92, 94; 93, identifier:verb; 94, integer:2; 95, block; 95, 96; 95, 111; 96, if_statement; 96, 97; 96, 98; 96, 104; 97, identifier:use_ne_eval; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, call; 100, 101; 100, 102; 101, identifier:print; 102, argument_list; 102, 103; 103, string:" Kernel Opt. : Use parallel"; 104, else_clause; 104, 105; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:print; 109, argument_list; 109, 110; 110, string:" Kernel Opt. : None"; 111, if_statement; 111, 112; 111, 113; 111, 119; 111, 127; 112, identifier:loop_off; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:print; 117, argument_list; 117, 118; 118, string:" Loop over : Offsets"; 119, elif_clause; 119, 120; 119, 121; 120, identifier:loop_freq; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 125; 124, identifier:print; 125, argument_list; 125, 126; 126, string:" Loop over : Frequencies"; 127, else_clause; 127, 128; 128, block; 128, 129; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 132; 131, identifier:print; 132, argument_list; 132, 133; 133, string:" Loop over : None (all vectorized)"; 134, return_statement; 134, 135; 135, expression_list; 135, 136; 135, 137; 135, 138; 136, identifier:use_ne_eval; 137, identifier:loop_freq; 138, identifier:loop_off | def check_opt(opt, loop, ht, htarg, verb):
r
use_ne_eval = False
if opt == 'parallel':
if numexpr:
use_ne_eval = numexpr.evaluate
elif verb > 0:
print(numexpr_msg)
lagged_splined_fht = False
if ht == 'fht':
if htarg[1] != 0:
lagged_splined_fht = True
if ht in ['hqwe', 'hquad'] or lagged_splined_fht:
loop_freq = True
loop_off = False
else:
loop_off = loop == 'off'
loop_freq = loop == 'freq'
if verb > 2:
if use_ne_eval:
print(" Kernel Opt. : Use parallel")
else:
print(" Kernel Opt. : None")
if loop_off:
print(" Loop over : Offsets")
elif loop_freq:
print(" Loop over : Frequencies")
else:
print(" Loop over : None (all vectorized)")
return use_ne_eval, loop_freq, loop_off |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_abs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:msrc; 5, identifier:mrec; 6, identifier:srcazm; 7, identifier:srcdip; 8, identifier:recazm; 9, identifier:recdip; 10, identifier:verb; 11, block; 11, 12; 11, 14; 11, 35; 11, 42; 11, 70; 11, 86; 11, 97; 11, 149; 11, 160; 11, 214; 11, 225; 11, 277; 11, 288; 11, 342; 11, 352; 11, 366; 12, expression_statement; 12, 13; 13, identifier:r; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:ab_calc; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:np; 20, identifier:array; 21, argument_list; 21, 22; 22, list:[[11, 12, 13], [21, 22, 23], [31, 32, 33]]; 22, 23; 22, 27; 22, 31; 23, list:[11, 12, 13]; 23, 24; 23, 25; 23, 26; 24, integer:11; 25, integer:12; 26, integer:13; 27, list:[21, 22, 23]; 27, 28; 27, 29; 27, 30; 28, integer:21; 29, integer:22; 30, integer:23; 31, list:[31, 32, 33]; 31, 32; 31, 33; 31, 34; 32, integer:31; 33, integer:32; 34, integer:33; 35, if_statement; 35, 36; 35, 37; 36, identifier:msrc; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, augmented_assignment:+=; 39, 40; 39, 41; 40, identifier:ab_calc; 41, integer:3; 42, if_statement; 42, 43; 42, 44; 43, identifier:mrec; 44, block; 44, 45; 44, 49; 45, expression_statement; 45, 46; 46, augmented_assignment:+=; 46, 47; 46, 48; 47, identifier:ab_calc; 48, integer:30; 49, if_statement; 49, 50; 49, 51; 49, 56; 50, identifier:msrc; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, augmented_assignment:-=; 53, 54; 53, 55; 54, identifier:ab_calc; 55, integer:33; 56, else_clause; 56, 57; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:ab_calc; 61, binary_operator:+; 61, 62; 61, 67; 62, binary_operator:*; 62, 63; 62, 66; 63, binary_operator:%; 63, 64; 63, 65; 64, identifier:ab_calc; 65, integer:10; 66, integer:10; 67, binary_operator://; 67, 68; 67, 69; 68, identifier:ab_calc; 69, integer:10; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:bab; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:np; 76, identifier:asarray; 77, argument_list; 77, 78; 77, 83; 78, binary_operator:+; 78, 79; 78, 82; 79, binary_operator:*; 79, 80; 79, 81; 80, identifier:ab_calc; 81, integer:0; 82, integer:1; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:dtype; 85, identifier:bool; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:check; 89, subscript; 89, 90; 89, 96; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:np; 93, identifier:atleast_1d; 94, argument_list; 94, 95; 95, identifier:srcazm; 96, integer:0; 97, if_statement; 97, 98; 97, 112; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:np; 101, identifier:allclose; 102, argument_list; 102, 103; 102, 111; 103, binary_operator:%; 103, 104; 103, 105; 104, identifier:srcazm; 105, parenthesized_expression; 105, 106; 106, binary_operator:/; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:np; 109, identifier:pi; 110, integer:2; 111, integer:0; 112, block; 112, 113; 113, if_statement; 113, 114; 113, 130; 113, 139; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:np; 117, identifier:isclose; 118, argument_list; 118, 119; 118, 129; 119, binary_operator:%; 119, 120; 119, 128; 120, binary_operator://; 120, 121; 120, 122; 121, identifier:check; 122, parenthesized_expression; 122, 123; 123, binary_operator:/; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:np; 126, identifier:pi; 127, integer:2; 128, integer:2; 129, integer:0; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, augmented_assignment:*=; 132, 133; 132, 138; 133, subscript; 133, 134; 133, 135; 133, 137; 134, identifier:bab; 135, slice; 135, 136; 136, colon; 137, integer:1; 138, False; 139, else_clause; 139, 140; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, augmented_assignment:*=; 142, 143; 142, 148; 143, subscript; 143, 144; 143, 145; 143, 147; 144, identifier:bab; 145, slice; 145, 146; 146, colon; 147, integer:0; 148, False; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:check; 152, subscript; 152, 153; 152, 159; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:np; 156, identifier:atleast_1d; 157, argument_list; 157, 158; 158, identifier:srcdip; 159, integer:0; 160, if_statement; 160, 161; 160, 175; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:np; 164, identifier:allclose; 165, argument_list; 165, 166; 165, 174; 166, binary_operator:%; 166, 167; 166, 168; 167, identifier:srcdip; 168, parenthesized_expression; 168, 169; 169, binary_operator:/; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:np; 172, identifier:pi; 173, integer:2; 174, integer:0; 175, block; 175, 176; 176, if_statement; 176, 177; 176, 193; 176, 202; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:np; 180, identifier:isclose; 181, argument_list; 181, 182; 181, 192; 182, binary_operator:%; 182, 183; 182, 191; 183, binary_operator://; 183, 184; 183, 185; 184, identifier:check; 185, parenthesized_expression; 185, 186; 186, binary_operator:/; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:np; 189, identifier:pi; 190, integer:2; 191, integer:2; 192, integer:0; 193, block; 193, 194; 194, expression_statement; 194, 195; 195, augmented_assignment:*=; 195, 196; 195, 201; 196, subscript; 196, 197; 196, 198; 196, 200; 197, identifier:bab; 198, slice; 198, 199; 199, colon; 200, integer:2; 201, False; 202, else_clause; 202, 203; 203, block; 203, 204; 204, expression_statement; 204, 205; 205, augmented_assignment:*=; 205, 206; 205, 213; 206, subscript; 206, 207; 206, 208; 206, 210; 207, identifier:bab; 208, slice; 208, 209; 209, colon; 210, slice; 210, 211; 210, 212; 211, colon; 212, integer:2; 213, False; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 217; 216, identifier:check; 217, subscript; 217, 218; 217, 224; 218, call; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:np; 221, identifier:atleast_1d; 222, argument_list; 222, 223; 223, identifier:recazm; 224, integer:0; 225, if_statement; 225, 226; 225, 240; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:np; 229, identifier:allclose; 230, argument_list; 230, 231; 230, 239; 231, binary_operator:%; 231, 232; 231, 233; 232, identifier:recazm; 233, parenthesized_expression; 233, 234; 234, binary_operator:/; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:np; 237, identifier:pi; 238, integer:2; 239, integer:0; 240, block; 240, 241; 241, if_statement; 241, 242; 241, 258; 241, 267; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:np; 245, identifier:isclose; 246, argument_list; 246, 247; 246, 257; 247, binary_operator:%; 247, 248; 247, 256; 248, binary_operator://; 248, 249; 248, 250; 249, identifier:check; 250, parenthesized_expression; 250, 251; 251, binary_operator:/; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:np; 254, identifier:pi; 255, integer:2; 256, integer:2; 257, integer:0; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, augmented_assignment:*=; 260, 261; 260, 266; 261, subscript; 261, 262; 261, 263; 261, 264; 262, identifier:bab; 263, integer:1; 264, slice; 264, 265; 265, colon; 266, False; 267, else_clause; 267, 268; 268, block; 268, 269; 269, expression_statement; 269, 270; 270, augmented_assignment:*=; 270, 271; 270, 276; 271, subscript; 271, 272; 271, 273; 271, 274; 272, identifier:bab; 273, integer:0; 274, slice; 274, 275; 275, colon; 276, False; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 280; 279, identifier:check; 280, subscript; 280, 281; 280, 287; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:np; 284, identifier:atleast_1d; 285, argument_list; 285, 286; 286, identifier:recdip; 287, integer:0; 288, if_statement; 288, 289; 288, 303; 289, call; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:np; 292, identifier:allclose; 293, argument_list; 293, 294; 293, 302; 294, binary_operator:%; 294, 295; 294, 296; 295, identifier:recdip; 296, parenthesized_expression; 296, 297; 297, binary_operator:/; 297, 298; 297, 301; 298, attribute; 298, 299; 298, 300; 299, identifier:np; 300, identifier:pi; 301, integer:2; 302, integer:0; 303, block; 303, 304; 304, if_statement; 304, 305; 304, 321; 304, 330; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:np; 308, identifier:isclose; 309, argument_list; 309, 310; 309, 320; 310, binary_operator:%; 310, 311; 310, 319; 311, binary_operator://; 311, 312; 311, 313; 312, identifier:check; 313, parenthesized_expression; 313, 314; 314, binary_operator:/; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:np; 317, identifier:pi; 318, integer:2; 319, integer:2; 320, integer:0; 321, block; 321, 322; 322, expression_statement; 322, 323; 323, augmented_assignment:*=; 323, 324; 323, 329; 324, subscript; 324, 325; 324, 326; 324, 327; 325, identifier:bab; 326, integer:2; 327, slice; 327, 328; 328, colon; 329, False; 330, else_clause; 330, 331; 331, block; 331, 332; 332, expression_statement; 332, 333; 333, augmented_assignment:*=; 333, 334; 333, 341; 334, subscript; 334, 335; 334, 336; 334, 339; 335, identifier:bab; 336, slice; 336, 337; 336, 338; 337, colon; 338, integer:2; 339, slice; 339, 340; 340, colon; 341, False; 342, expression_statement; 342, 343; 343, assignment; 343, 344; 343, 345; 344, identifier:ab_calc; 345, call; 345, 346; 345, 351; 346, attribute; 346, 347; 346, 350; 347, subscript; 347, 348; 347, 349; 348, identifier:ab_calc; 349, identifier:bab; 350, identifier:ravel; 351, argument_list; 352, if_statement; 352, 353; 352, 356; 353, comparison_operator:>; 353, 354; 353, 355; 354, identifier:verb; 355, integer:2; 356, block; 356, 357; 357, expression_statement; 357, 358; 358, call; 358, 359; 358, 360; 359, identifier:print; 360, argument_list; 360, 361; 360, 362; 361, string:" Required ab's : "; 362, call; 362, 363; 362, 364; 363, identifier:_strvar; 364, argument_list; 364, 365; 365, identifier:ab_calc; 366, return_statement; 366, 367; 367, identifier:ab_calc | def get_abs(msrc, mrec, srcazm, srcdip, recazm, recdip, verb):
r
ab_calc = np.array([[11, 12, 13], [21, 22, 23], [31, 32, 33]])
if msrc:
ab_calc += 3
if mrec:
ab_calc += 30
if msrc:
ab_calc -= 33
else:
ab_calc = ab_calc % 10*10 + ab_calc // 10
bab = np.asarray(ab_calc*0+1, dtype=bool)
check = np.atleast_1d(srcazm)[0]
if np.allclose(srcazm % (np.pi/2), 0):
if np.isclose(check // (np.pi/2) % 2, 0):
bab[:, 1] *= False
else:
bab[:, 0] *= False
check = np.atleast_1d(srcdip)[0]
if np.allclose(srcdip % (np.pi/2), 0):
if np.isclose(check // (np.pi/2) % 2, 0):
bab[:, 2] *= False
else:
bab[:, :2] *= False
check = np.atleast_1d(recazm)[0]
if np.allclose(recazm % (np.pi/2), 0):
if np.isclose(check // (np.pi/2) % 2, 0):
bab[1, :] *= False
else:
bab[0, :] *= False
check = np.atleast_1d(recdip)[0]
if np.allclose(recdip % (np.pi/2), 0):
if np.isclose(check // (np.pi/2) % 2, 0):
bab[2, :] *= False
else:
bab[:2, :] *= False
ab_calc = ab_calc[bab].ravel()
if verb > 2:
print(" Required ab's : ", _strvar(ab_calc))
return ab_calc |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:spline_backwards_hankel; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:ht; 5, identifier:htarg; 6, identifier:opt; 7, block; 7, 8; 7, 10; 7, 18; 7, 121; 8, expression_statement; 8, 9; 9, identifier:r; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:ht; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:ht; 16, identifier:lower; 17, argument_list; 18, if_statement; 18, 19; 18, 25; 19, comparison_operator:in; 19, 20; 19, 21; 20, identifier:ht; 21, list:['fht', 'qwe', 'hqwe']; 21, 22; 21, 23; 21, 24; 22, string:'fht'; 23, string:'qwe'; 24, string:'hqwe'; 25, block; 25, 26; 25, 65; 26, if_statement; 26, 27; 26, 30; 26, 41; 27, comparison_operator:==; 27, 28; 27, 29; 28, identifier:ht; 29, string:'fht'; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:htarg; 34, call; 34, 35; 34, 36; 35, identifier:_check_targ; 36, argument_list; 36, 37; 36, 38; 37, identifier:htarg; 38, list:['fhtfilt', 'pts_per_dec']; 38, 39; 38, 40; 39, string:'fhtfilt'; 40, string:'pts_per_dec'; 41, elif_clause; 41, 42; 41, 47; 42, comparison_operator:in; 42, 43; 42, 44; 43, identifier:ht; 44, list:['qwe', 'hqwe']; 44, 45; 44, 46; 45, string:'qwe'; 46, string:'hqwe'; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:htarg; 51, call; 51, 52; 51, 53; 52, identifier:_check_targ; 53, argument_list; 53, 54; 53, 55; 54, identifier:htarg; 55, list:['rtol', 'atol', 'nquad', 'maxint',
'pts_per_dec', 'diff_quad', 'a', 'b', 'limit']; 55, 56; 55, 57; 55, 58; 55, 59; 55, 60; 55, 61; 55, 62; 55, 63; 55, 64; 56, string:'rtol'; 57, string:'atol'; 58, string:'nquad'; 59, string:'maxint'; 60, string:'pts_per_dec'; 61, string:'diff_quad'; 62, string:'a'; 63, string:'b'; 64, string:'limit'; 65, if_statement; 65, 66; 65, 69; 66, comparison_operator:==; 66, 67; 66, 68; 67, identifier:opt; 68, string:'spline'; 69, block; 69, 70; 69, 79; 69, 87; 69, 91; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:mesg; 73, parenthesized_expression; 73, 74; 74, binary_operator:+; 74, 75; 74, 78; 75, binary_operator:+; 75, 76; 75, 77; 76, string:"\n The use of `opt='spline'` is deprecated and will "; 77, string:"be removed\n in v2.0.0; use the corresponding "; 78, string:"setting in `htarg`."; 79, expression_statement; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:warnings; 83, identifier:warn; 84, argument_list; 84, 85; 84, 86; 85, identifier:mesg; 86, identifier:DeprecationWarning; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:opt; 90, None; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:not; 92, 93; 92, 94; 93, string:'pts_per_dec'; 94, identifier:htarg; 95, block; 95, 96; 96, if_statement; 96, 97; 96, 100; 96, 108; 97, comparison_operator:==; 97, 98; 97, 99; 98, identifier:ht; 99, string:'fht'; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 106; 103, subscript; 103, 104; 103, 105; 104, identifier:htarg; 105, string:'pts_per_dec'; 106, unary_operator:-; 106, 107; 107, integer:1; 108, elif_clause; 108, 109; 108, 114; 109, comparison_operator:in; 109, 110; 109, 111; 110, identifier:ht; 111, list:['qwe', 'hqwe']; 111, 112; 111, 113; 112, string:'qwe'; 113, string:'hqwe'; 114, block; 114, 115; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 120; 117, subscript; 117, 118; 117, 119; 118, identifier:htarg; 119, string:'pts_per_dec'; 120, integer:80; 121, return_statement; 121, 122; 122, expression_list; 122, 123; 122, 124; 123, identifier:htarg; 124, identifier:opt | def spline_backwards_hankel(ht, htarg, opt):
r
ht = ht.lower()
if ht in ['fht', 'qwe', 'hqwe']:
if ht == 'fht':
htarg = _check_targ(htarg, ['fhtfilt', 'pts_per_dec'])
elif ht in ['qwe', 'hqwe']:
htarg = _check_targ(htarg, ['rtol', 'atol', 'nquad', 'maxint',
'pts_per_dec', 'diff_quad', 'a', 'b', 'limit'])
if opt == 'spline':
mesg = ("\n The use of `opt='spline'` is deprecated and will " +
"be removed\n in v2.0.0; use the corresponding " +
"setting in `htarg`.")
warnings.warn(mesg, DeprecationWarning)
opt = None
if 'pts_per_dec' not in htarg:
if ht == 'fht':
htarg['pts_per_dec'] = -1
elif ht in ['qwe', 'hqwe']:
htarg['pts_per_dec'] = 80
return htarg, opt |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:dipole_k; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 4, identifier:src; 5, identifier:rec; 6, identifier:depth; 7, identifier:res; 8, identifier:freq; 9, identifier:wavenumber; 10, default_parameter; 10, 11; 10, 12; 11, identifier:ab; 12, integer:11; 13, default_parameter; 13, 14; 13, 15; 14, identifier:aniso; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:epermH; 18, None; 19, default_parameter; 19, 20; 19, 21; 20, identifier:epermV; 21, None; 22, default_parameter; 22, 23; 22, 24; 23, identifier:mpermH; 24, None; 25, default_parameter; 25, 26; 25, 27; 26, identifier:mpermV; 27, None; 28, default_parameter; 28, 29; 28, 30; 29, identifier:verb; 30, integer:2; 31, block; 31, 32; 31, 34; 31, 41; 31, 56; 31, 68; 31, 82; 31, 91; 31, 102; 31, 113; 31, 124; 31, 137; 31, 149; 31, 159; 31, 169; 31, 279; 31, 380; 31, 387; 32, expression_statement; 32, 33; 33, identifier:r; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:t0; 37, call; 37, 38; 37, 39; 38, identifier:printstartfinish; 39, argument_list; 39, 40; 40, identifier:verb; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:modl; 44, call; 44, 45; 44, 46; 45, identifier:check_model; 46, argument_list; 46, 47; 46, 48; 46, 49; 46, 50; 46, 51; 46, 52; 46, 53; 46, 54; 46, 55; 47, identifier:depth; 48, identifier:res; 49, identifier:aniso; 50, identifier:epermH; 51, identifier:epermV; 52, identifier:mpermH; 53, identifier:mpermV; 54, False; 55, identifier:verb; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 67; 58, pattern_list; 58, 59; 58, 60; 58, 61; 58, 62; 58, 63; 58, 64; 58, 65; 58, 66; 59, identifier:depth; 60, identifier:res; 61, identifier:aniso; 62, identifier:epermH; 63, identifier:epermV; 64, identifier:mpermH; 65, identifier:mpermV; 66, identifier:_; 67, identifier:modl; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:f; 71, call; 71, 72; 71, 73; 72, identifier:check_frequency; 73, argument_list; 73, 74; 73, 75; 73, 76; 73, 77; 73, 78; 73, 79; 73, 80; 73, 81; 74, identifier:freq; 75, identifier:res; 76, identifier:aniso; 77, identifier:epermH; 78, identifier:epermV; 79, identifier:mpermH; 80, identifier:mpermV; 81, identifier:verb; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 90; 84, pattern_list; 84, 85; 84, 86; 84, 87; 84, 88; 84, 89; 85, identifier:freq; 86, identifier:etaH; 87, identifier:etaV; 88, identifier:zetaH; 89, identifier:zetaV; 90, identifier:f; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 97; 93, pattern_list; 93, 94; 93, 95; 93, 96; 94, identifier:ab_calc; 95, identifier:msrc; 96, identifier:mrec; 97, call; 97, 98; 97, 99; 98, identifier:check_ab; 99, argument_list; 99, 100; 99, 101; 100, identifier:ab; 101, identifier:verb; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 107; 104, pattern_list; 104, 105; 104, 106; 105, identifier:src; 106, identifier:nsrc; 107, call; 107, 108; 107, 109; 108, identifier:check_dipole; 109, argument_list; 109, 110; 109, 111; 109, 112; 110, identifier:src; 111, string:'src'; 112, identifier:verb; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 118; 115, pattern_list; 115, 116; 115, 117; 116, identifier:rec; 117, identifier:nrec; 118, call; 118, 119; 118, 120; 119, identifier:check_dipole; 120, argument_list; 120, 121; 120, 122; 120, 123; 121, identifier:rec; 122, string:'rec'; 123, identifier:verb; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 129; 126, pattern_list; 126, 127; 126, 128; 127, identifier:off; 128, identifier:angle; 129, call; 129, 130; 129, 131; 130, identifier:get_off_ang; 131, argument_list; 131, 132; 131, 133; 131, 134; 131, 135; 131, 136; 132, identifier:src; 133, identifier:rec; 134, identifier:nsrc; 135, identifier:nrec; 136, identifier:verb; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:factAng; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:kernel; 143, identifier:angle_factor; 144, argument_list; 144, 145; 144, 146; 144, 147; 144, 148; 145, identifier:angle; 146, identifier:ab; 147, identifier:msrc; 148, identifier:mrec; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 154; 151, pattern_list; 151, 152; 151, 153; 152, identifier:lsrc; 153, identifier:zsrc; 154, call; 154, 155; 154, 156; 155, identifier:get_layer_nr; 156, argument_list; 156, 157; 156, 158; 157, identifier:src; 158, identifier:depth; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 164; 161, pattern_list; 161, 162; 161, 163; 162, identifier:lrec; 163, identifier:zrec; 164, call; 164, 165; 164, 166; 165, identifier:get_layer_nr; 166, argument_list; 166, 167; 166, 168; 167, identifier:rec; 168, identifier:depth; 169, if_statement; 169, 170; 169, 184; 169, 235; 170, boolean_operator:and; 170, 171; 170, 176; 171, comparison_operator:==; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:off; 174, identifier:size; 175, integer:1; 176, comparison_operator:==; 176, 177; 176, 183; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:np; 180, identifier:ndim; 181, argument_list; 181, 182; 182, identifier:wavenumber; 183, integer:2; 184, block; 184, 185; 184, 210; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:PJ0; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:np; 191, identifier:zeros; 192, argument_list; 192, 193; 192, 207; 193, tuple; 193, 194; 193, 197; 193, 202; 194, attribute; 194, 195; 194, 196; 195, identifier:freq; 196, identifier:size; 197, subscript; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:wavenumber; 200, identifier:shape; 201, integer:0; 202, subscript; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:wavenumber; 205, identifier:shape; 206, integer:1; 207, keyword_argument; 207, 208; 207, 209; 208, identifier:dtype; 209, identifier:complex; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:PJ1; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:np; 216, identifier:zeros; 217, argument_list; 217, 218; 217, 232; 218, tuple; 218, 219; 218, 222; 218, 227; 219, attribute; 219, 220; 219, 221; 220, identifier:freq; 221, identifier:size; 222, subscript; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:wavenumber; 225, identifier:shape; 226, integer:0; 227, subscript; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:wavenumber; 230, identifier:shape; 231, integer:1; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:dtype; 234, identifier:complex; 235, else_clause; 235, 236; 236, block; 236, 237; 236, 258; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:PJ0; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:np; 243, identifier:zeros; 244, argument_list; 244, 245; 244, 255; 245, tuple; 245, 246; 245, 249; 245, 252; 246, attribute; 246, 247; 246, 248; 247, identifier:freq; 248, identifier:size; 249, attribute; 249, 250; 249, 251; 250, identifier:off; 251, identifier:size; 252, attribute; 252, 253; 252, 254; 253, identifier:wavenumber; 254, identifier:size; 255, keyword_argument; 255, 256; 255, 257; 256, identifier:dtype; 257, identifier:complex; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:PJ1; 261, call; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:np; 264, identifier:zeros; 265, argument_list; 265, 266; 265, 276; 266, tuple; 266, 267; 266, 270; 266, 273; 267, attribute; 267, 268; 267, 269; 268, identifier:freq; 269, identifier:size; 270, attribute; 270, 271; 270, 272; 271, identifier:off; 272, identifier:size; 273, attribute; 273, 274; 273, 275; 274, identifier:wavenumber; 275, identifier:size; 276, keyword_argument; 276, 277; 276, 278; 277, identifier:dtype; 278, identifier:complex; 279, if_statement; 279, 280; 279, 284; 280, comparison_operator:not; 280, 281; 280, 282; 281, identifier:ab_calc; 282, list:[36, ]; 282, 283; 283, integer:36; 284, block; 284, 285; 284, 316; 284, 354; 284, 363; 285, expression_statement; 285, 286; 286, assignment; 286, 287; 286, 291; 287, pattern_list; 287, 288; 287, 289; 287, 290; 288, identifier:J0; 289, identifier:J1; 290, identifier:J0b; 291, call; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:kernel; 294, identifier:wavenumber; 295, argument_list; 295, 296; 295, 297; 295, 298; 295, 299; 295, 300; 295, 301; 295, 302; 295, 303; 295, 304; 295, 305; 295, 311; 295, 312; 295, 313; 295, 314; 295, 315; 296, identifier:zsrc; 297, identifier:zrec; 298, identifier:lsrc; 299, identifier:lrec; 300, identifier:depth; 301, identifier:etaH; 302, identifier:etaV; 303, identifier:zetaH; 304, identifier:zetaV; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:np; 308, identifier:atleast_2d; 309, argument_list; 309, 310; 310, identifier:wavenumber; 311, identifier:ab_calc; 312, False; 313, identifier:msrc; 314, identifier:mrec; 315, False; 316, if_statement; 316, 317; 316, 320; 317, comparison_operator:is; 317, 318; 317, 319; 318, identifier:J1; 319, None; 320, block; 320, 321; 320, 333; 321, expression_statement; 321, 322; 322, augmented_assignment:+=; 322, 323; 322, 324; 323, identifier:PJ1; 324, binary_operator:*; 324, 325; 324, 332; 325, subscript; 325, 326; 325, 327; 325, 329; 326, identifier:factAng; 327, slice; 327, 328; 328, colon; 329, attribute; 329, 330; 329, 331; 330, identifier:np; 331, identifier:newaxis; 332, identifier:J1; 333, if_statement; 333, 334; 333, 345; 334, comparison_operator:in; 334, 335; 334, 336; 335, identifier:ab; 336, list:[11, 12, 21, 22, 14, 24, 15, 25]; 336, 337; 336, 338; 336, 339; 336, 340; 336, 341; 336, 342; 336, 343; 336, 344; 337, integer:11; 338, integer:12; 339, integer:21; 340, integer:22; 341, integer:14; 342, integer:24; 343, integer:15; 344, integer:25; 345, block; 345, 346; 346, expression_statement; 346, 347; 347, augmented_assignment:/=; 347, 348; 347, 349; 348, identifier:PJ1; 349, subscript; 349, 350; 349, 351; 349, 353; 350, identifier:off; 351, slice; 351, 352; 352, colon; 353, None; 354, if_statement; 354, 355; 354, 358; 355, comparison_operator:is; 355, 356; 355, 357; 356, identifier:J0; 357, None; 358, block; 358, 359; 359, expression_statement; 359, 360; 360, augmented_assignment:+=; 360, 361; 360, 362; 361, identifier:PJ0; 362, identifier:J0; 363, if_statement; 363, 364; 363, 367; 364, comparison_operator:is; 364, 365; 364, 366; 365, identifier:J0b; 366, None; 367, block; 367, 368; 368, expression_statement; 368, 369; 369, augmented_assignment:+=; 369, 370; 369, 371; 370, identifier:PJ0; 371, binary_operator:*; 371, 372; 371, 379; 372, subscript; 372, 373; 372, 374; 372, 376; 373, identifier:factAng; 374, slice; 374, 375; 375, colon; 376, attribute; 376, 377; 376, 378; 377, identifier:np; 378, identifier:newaxis; 379, identifier:J0b; 380, expression_statement; 380, 381; 381, call; 381, 382; 381, 383; 382, identifier:printstartfinish; 383, argument_list; 383, 384; 383, 385; 383, 386; 384, identifier:verb; 385, identifier:t0; 386, integer:1; 387, return_statement; 387, 388; 388, expression_list; 388, 389; 388, 395; 389, call; 389, 390; 389, 393; 390, attribute; 390, 391; 390, 392; 391, identifier:np; 392, identifier:squeeze; 393, argument_list; 393, 394; 394, identifier:PJ0; 395, call; 395, 396; 395, 399; 396, attribute; 396, 397; 396, 398; 397, identifier:np; 398, identifier:squeeze; 399, argument_list; 399, 400; 400, identifier:PJ1 | def dipole_k(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None,
epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2):
r
t0 = printstartfinish(verb)
modl = check_model(depth, res, aniso, epermH, epermV, mpermH, mpermV,
False, verb)
depth, res, aniso, epermH, epermV, mpermH, mpermV, _ = modl
f = check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb)
freq, etaH, etaV, zetaH, zetaV = f
ab_calc, msrc, mrec = check_ab(ab, verb)
src, nsrc = check_dipole(src, 'src', verb)
rec, nrec = check_dipole(rec, 'rec', verb)
off, angle = get_off_ang(src, rec, nsrc, nrec, verb)
factAng = kernel.angle_factor(angle, ab, msrc, mrec)
lsrc, zsrc = get_layer_nr(src, depth)
lrec, zrec = get_layer_nr(rec, depth)
if off.size == 1 and np.ndim(wavenumber) == 2:
PJ0 = np.zeros((freq.size, wavenumber.shape[0], wavenumber.shape[1]),
dtype=complex)
PJ1 = np.zeros((freq.size, wavenumber.shape[0], wavenumber.shape[1]),
dtype=complex)
else:
PJ0 = np.zeros((freq.size, off.size, wavenumber.size), dtype=complex)
PJ1 = np.zeros((freq.size, off.size, wavenumber.size), dtype=complex)
if ab_calc not in [36, ]:
J0, J1, J0b = kernel.wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH,
etaV, zetaH, zetaV,
np.atleast_2d(wavenumber), ab_calc,
False, msrc, mrec, False)
if J1 is not None:
PJ1 += factAng[:, np.newaxis]*J1
if ab in [11, 12, 21, 22, 14, 24, 15, 25]:
PJ1 /= off[:, None]
if J0 is not None:
PJ0 += J0
if J0b is not None:
PJ0 += factAng[:, np.newaxis]*J0b
printstartfinish(verb, t0, 1)
return np.squeeze(PJ0), np.squeeze(PJ1) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:plot_result; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:filt; 5, identifier:full; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prntres; 8, True; 9, block; 9, 10; 9, 12; 9, 22; 9, 31; 9, 42; 9, 53; 9, 64; 9, 76; 9, 88; 9, 279; 9, 299; 9, 306; 9, 393; 9, 413; 9, 420; 9, 427; 9, 436; 9, 448; 10, expression_statement; 10, 11; 11, identifier:r; 12, if_statement; 12, 13; 12, 15; 13, not_operator; 13, 14; 14, identifier:plt; 15, block; 15, 16; 15, 21; 16, expression_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:print; 19, argument_list; 19, 20; 20, identifier:plt_msg; 21, return_statement; 22, if_statement; 22, 23; 22, 24; 23, identifier:prntres; 24, block; 24, 25; 25, expression_statement; 25, 26; 26, call; 26, 27; 26, 28; 27, identifier:print_result; 28, argument_list; 28, 29; 28, 30; 29, identifier:filt; 30, identifier:full; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:spacing; 34, subscript; 34, 35; 34, 38; 34, 39; 34, 41; 35, subscript; 35, 36; 35, 37; 36, identifier:full; 37, integer:2; 38, integer:0; 39, slice; 39, 40; 40, colon; 41, integer:0; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:shift; 45, subscript; 45, 46; 45, 49; 45, 50; 45, 51; 46, subscript; 46, 47; 46, 48; 47, identifier:full; 48, integer:2; 49, integer:1; 50, integer:0; 51, slice; 51, 52; 52, colon; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:minfield; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:np; 59, identifier:squeeze; 60, argument_list; 60, 61; 61, subscript; 61, 62; 61, 63; 62, identifier:full; 63, integer:3; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:plt; 68, identifier:figure; 69, argument_list; 69, 70; 69, 71; 70, string:"Brute force result"; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:figsize; 73, tuple; 73, 74; 73, 75; 74, float:9.5; 75, float:4.5; 76, expression_statement; 76, 77; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:plt; 80, identifier:subplots_adjust; 81, argument_list; 81, 82; 81, 85; 82, keyword_argument; 82, 83; 82, 84; 83, identifier:wspace; 84, float:.4; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:bottom; 87, float:0.2; 88, if_statement; 88, 89; 88, 100; 89, boolean_operator:or; 89, 90; 89, 95; 90, comparison_operator:>; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:spacing; 93, identifier:size; 94, integer:1; 95, comparison_operator:>; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:shift; 98, identifier:size; 99, integer:1; 100, block; 100, 101; 100, 108; 100, 170; 101, expression_statement; 101, 102; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:plt; 105, identifier:subplot; 106, argument_list; 106, 107; 107, integer:121; 108, if_statement; 108, 109; 108, 114; 108, 143; 109, comparison_operator:==; 109, 110; 109, 113; 110, subscript; 110, 111; 110, 112; 111, identifier:full; 112, integer:4; 113, integer:0; 114, block; 114, 115; 114, 122; 114, 126; 114, 135; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:plt; 119, identifier:title; 120, argument_list; 120, 121; 121, string:"Minimal recovered fields"; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:ylabel; 125, string:'Minimal recovered amplitude (log10)'; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:field; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:np; 132, identifier:log10; 133, argument_list; 133, 134; 134, identifier:minfield; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:cmap; 138, attribute; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:plt; 141, identifier:cm; 142, identifier:viridis; 143, else_clause; 143, 144; 144, block; 144, 145; 144, 152; 144, 156; 144, 162; 145, expression_statement; 145, 146; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:plt; 149, identifier:title; 150, argument_list; 150, 151; 151, string:"Maximum recovered r"; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:ylabel; 155, string:'Maximum recovered r'; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:field; 159, binary_operator:/; 159, 160; 159, 161; 160, integer:1; 161, identifier:minfield; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 165; 164, identifier:cmap; 165, attribute; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:plt; 168, identifier:cm; 169, identifier:viridis_r; 170, if_statement; 170, 171; 170, 176; 170, 199; 170, 228; 171, comparison_operator:==; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:shift; 174, identifier:size; 175, integer:1; 176, block; 176, 177; 176, 185; 176, 192; 177, expression_statement; 177, 178; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:plt; 181, identifier:plot; 182, argument_list; 182, 183; 182, 184; 183, identifier:spacing; 184, identifier:field; 185, expression_statement; 185, 186; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:plt; 189, identifier:xlabel; 190, argument_list; 190, 191; 191, string:'Spacing'; 192, expression_statement; 192, 193; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:plt; 196, identifier:ylabel; 197, argument_list; 197, 198; 198, identifier:ylabel; 199, elif_clause; 199, 200; 199, 205; 200, comparison_operator:==; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:spacing; 203, identifier:size; 204, integer:1; 205, block; 205, 206; 205, 214; 205, 221; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:plt; 210, identifier:plot; 211, argument_list; 211, 212; 211, 213; 212, identifier:shift; 213, identifier:field; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:plt; 218, identifier:xlabel; 219, argument_list; 219, 220; 220, string:'Shift'; 221, expression_statement; 221, 222; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:plt; 225, identifier:ylabel; 226, argument_list; 226, 227; 227, identifier:ylabel; 228, else_clause; 228, 229; 229, block; 229, 230; 229, 247; 229, 259; 229, 266; 229, 273; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:field; 233, call; 233, 234; 233, 239; 234, attribute; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:np; 237, identifier:ma; 238, identifier:masked_where; 239, argument_list; 239, 240; 239, 246; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:np; 243, identifier:isinf; 244, argument_list; 244, 245; 245, identifier:minfield; 246, identifier:field; 247, expression_statement; 247, 248; 248, call; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:plt; 251, identifier:pcolormesh; 252, argument_list; 252, 253; 252, 254; 252, 255; 252, 256; 253, identifier:shift; 254, identifier:spacing; 255, identifier:field; 256, keyword_argument; 256, 257; 256, 258; 257, identifier:cmap; 258, identifier:cmap; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:plt; 263, identifier:ylabel; 264, argument_list; 264, 265; 265, string:'Spacing'; 266, expression_statement; 266, 267; 267, call; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:plt; 270, identifier:xlabel; 271, argument_list; 271, 272; 272, string:'Shift'; 273, expression_statement; 273, 274; 274, call; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:plt; 277, identifier:colorbar; 278, argument_list; 279, if_statement; 279, 280; 279, 291; 280, boolean_operator:or; 280, 281; 280, 286; 281, comparison_operator:>; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:spacing; 284, identifier:size; 285, integer:1; 286, comparison_operator:>; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:shift; 289, identifier:size; 290, integer:1; 291, block; 291, 292; 292, expression_statement; 292, 293; 293, call; 293, 294; 293, 297; 294, attribute; 294, 295; 294, 296; 295, identifier:plt; 296, identifier:subplot; 297, argument_list; 297, 298; 298, integer:122; 299, expression_statement; 299, 300; 300, call; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:plt; 303, identifier:title; 304, argument_list; 304, 305; 305, string:'Filter values of best filter'; 306, for_statement; 306, 307; 306, 308; 306, 313; 307, identifier:attr; 308, list:['j0', 'j1', 'sin', 'cos']; 308, 309; 308, 310; 308, 311; 308, 312; 309, string:'j0'; 310, string:'j1'; 311, string:'sin'; 312, string:'cos'; 313, block; 313, 314; 314, if_statement; 314, 315; 314, 320; 315, call; 315, 316; 315, 317; 316, identifier:hasattr; 317, argument_list; 317, 318; 317, 319; 318, identifier:filt; 319, identifier:attr; 320, block; 320, 321; 320, 361; 321, expression_statement; 321, 322; 322, call; 322, 323; 322, 326; 323, attribute; 323, 324; 323, 325; 324, identifier:plt; 325, identifier:plot; 326, argument_list; 326, 327; 326, 335; 326, 350; 326, 351; 326, 354; 327, call; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:np; 330, identifier:log10; 331, argument_list; 331, 332; 332, attribute; 332, 333; 332, 334; 333, identifier:filt; 334, identifier:base; 335, call; 335, 336; 335, 339; 336, attribute; 336, 337; 336, 338; 337, identifier:np; 338, identifier:log10; 339, argument_list; 339, 340; 340, call; 340, 341; 340, 344; 341, attribute; 341, 342; 341, 343; 342, identifier:np; 343, identifier:abs; 344, argument_list; 344, 345; 345, call; 345, 346; 345, 347; 346, identifier:getattr; 347, argument_list; 347, 348; 347, 349; 348, identifier:filt; 349, identifier:attr; 350, string:'.-'; 351, keyword_argument; 351, 352; 351, 353; 352, identifier:lw; 353, float:.5; 354, keyword_argument; 354, 355; 354, 356; 355, identifier:label; 356, binary_operator:+; 356, 357; 356, 360; 357, binary_operator:+; 357, 358; 357, 359; 358, string:'abs('; 359, identifier:attr; 360, string:')'; 361, expression_statement; 361, 362; 362, call; 362, 363; 362, 366; 363, attribute; 363, 364; 363, 365; 364, identifier:plt; 365, identifier:plot; 366, argument_list; 366, 367; 366, 375; 366, 386; 366, 387; 366, 390; 367, call; 367, 368; 367, 371; 368, attribute; 368, 369; 368, 370; 369, identifier:np; 370, identifier:log10; 371, argument_list; 371, 372; 372, attribute; 372, 373; 372, 374; 373, identifier:filt; 374, identifier:base; 375, call; 375, 376; 375, 379; 376, attribute; 376, 377; 376, 378; 377, identifier:np; 378, identifier:log10; 379, argument_list; 379, 380; 380, unary_operator:-; 380, 381; 381, call; 381, 382; 381, 383; 382, identifier:getattr; 383, argument_list; 383, 384; 383, 385; 384, identifier:filt; 385, identifier:attr; 386, string:'.'; 387, keyword_argument; 387, 388; 387, 389; 388, identifier:color; 389, string:'k'; 390, keyword_argument; 390, 391; 390, 392; 391, identifier:ms; 392, integer:4; 393, expression_statement; 393, 394; 394, call; 394, 395; 394, 398; 395, attribute; 395, 396; 395, 397; 396, identifier:plt; 397, identifier:plot; 398, argument_list; 398, 399; 398, 402; 398, 403; 398, 404; 398, 407; 398, 410; 399, attribute; 399, 400; 399, 401; 400, identifier:np; 401, identifier:inf; 402, integer:0; 403, string:'.'; 404, keyword_argument; 404, 405; 404, 406; 405, identifier:color; 406, string:'k'; 407, keyword_argument; 407, 408; 407, 409; 408, identifier:ms; 409, integer:4; 410, keyword_argument; 410, 411; 410, 412; 411, identifier:label; 412, string:'Neg. values'; 413, expression_statement; 413, 414; 414, call; 414, 415; 414, 418; 415, attribute; 415, 416; 415, 417; 416, identifier:plt; 417, identifier:xlabel; 418, argument_list; 418, 419; 419, string:'Base (log10)'; 420, expression_statement; 420, 421; 421, call; 421, 422; 421, 425; 422, attribute; 422, 423; 422, 424; 423, identifier:plt; 424, identifier:ylabel; 425, argument_list; 425, 426; 426, string:'Abs(Amplitude) (log10)'; 427, expression_statement; 427, 428; 428, call; 428, 429; 428, 432; 429, attribute; 429, 430; 429, 431; 430, identifier:plt; 431, identifier:legend; 432, argument_list; 432, 433; 433, keyword_argument; 433, 434; 433, 435; 434, identifier:loc; 435, string:'best'; 436, expression_statement; 436, 437; 437, call; 437, 438; 437, 447; 438, attribute; 438, 439; 438, 446; 439, attribute; 439, 440; 439, 445; 440, call; 440, 441; 440, 444; 441, attribute; 441, 442; 441, 443; 442, identifier:plt; 443, identifier:gcf; 444, argument_list; 445, identifier:canvas; 446, identifier:draw; 447, argument_list; 448, expression_statement; 448, 449; 449, call; 449, 450; 449, 453; 450, attribute; 450, 451; 450, 452; 451, identifier:plt; 452, identifier:show; 453, argument_list | def plot_result(filt, full, prntres=True):
r
if not plt:
print(plt_msg)
return
if prntres:
print_result(filt, full)
spacing = full[2][0, :, 0]
shift = full[2][1, 0, :]
minfield = np.squeeze(full[3])
plt.figure("Brute force result", figsize=(9.5, 4.5))
plt.subplots_adjust(wspace=.4, bottom=0.2)
if spacing.size > 1 or shift.size > 1:
plt.subplot(121)
if full[4] == 0:
plt.title("Minimal recovered fields")
ylabel = 'Minimal recovered amplitude (log10)'
field = np.log10(minfield)
cmap = plt.cm.viridis
else:
plt.title("Maximum recovered r")
ylabel = 'Maximum recovered r'
field = 1/minfield
cmap = plt.cm.viridis_r
if shift.size == 1:
plt.plot(spacing, field)
plt.xlabel('Spacing')
plt.ylabel(ylabel)
elif spacing.size == 1:
plt.plot(shift, field)
plt.xlabel('Shift')
plt.ylabel(ylabel)
else:
field = np.ma.masked_where(np.isinf(minfield), field)
plt.pcolormesh(shift, spacing, field, cmap=cmap)
plt.ylabel('Spacing')
plt.xlabel('Shift')
plt.colorbar()
if spacing.size > 1 or shift.size > 1:
plt.subplot(122)
plt.title('Filter values of best filter')
for attr in ['j0', 'j1', 'sin', 'cos']:
if hasattr(filt, attr):
plt.plot(np.log10(filt.base),
np.log10(np.abs(getattr(filt, attr))), '.-', lw=.5,
label='abs('+attr+')')
plt.plot(np.log10(filt.base), np.log10(-getattr(filt, attr)), '.',
color='k', ms=4)
plt.plot(np.inf, 0, '.', color='k', ms=4, label='Neg. values')
plt.xlabel('Base (log10)')
plt.ylabel('Abs(Amplitude) (log10)')
plt.legend(loc='best')
plt.gcf().canvas.draw()
plt.show() |
0, module; 0, 1; 0, 10; 0, 12; 0, 21; 0, 32; 0, 122; 0, 134; 0, 143; 0, 152; 0, 163; 0, 223; 0, 372; 0, 384; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_plot_transform_pairs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:fCI; 5, identifier:r; 6, identifier:k; 7, identifier:axes; 8, identifier:tit; 9, block:; 10, expression_statement; 10, 11; 11, identifier:r; 12, expression_statement; 12, 13; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:plt; 16, identifier:sca; 17, argument_list; 17, 18; 18, subscript; 18, 19; 18, 20; 19, identifier:axes; 20, integer:0; 21, expression_statement; 21, 22; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:plt; 25, identifier:title; 26, argument_list; 26, 27; 27, binary_operator:+; 27, 28; 27, 31; 28, binary_operator:+; 28, 29; 28, 30; 29, string:'|'; 30, identifier:tit; 31, string:' lhs|'; 32, for_statement; 32, 33; 32, 34; 32, 35; 33, identifier:f; 34, identifier:fCI; 35, block; 35, 36; 36, if_statement; 36, 37; 36, 42; 36, 94; 37, comparison_operator:==; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:f; 40, identifier:name; 41, string:'j2'; 42, block; 42, 43; 42, 52; 42, 73; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:lhs; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:f; 49, identifier:lhs; 50, argument_list; 50, 51; 51, identifier:k; 52, expression_statement; 52, 53; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:plt; 56, identifier:loglog; 57, argument_list; 57, 58; 57, 59; 57, 67; 57, 70; 58, identifier:k; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:np; 62, identifier:abs; 63, argument_list; 63, 64; 64, subscript; 64, 65; 64, 66; 65, identifier:lhs; 66, integer:0; 67, keyword_argument; 67, 68; 67, 69; 68, identifier:lw; 69, integer:2; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:label; 72, string:'j0'; 73, expression_statement; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:plt; 77, identifier:loglog; 78, argument_list; 78, 79; 78, 80; 78, 88; 78, 91; 79, identifier:k; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:np; 83, identifier:abs; 84, argument_list; 84, 85; 85, subscript; 85, 86; 85, 87; 86, identifier:lhs; 87, integer:1; 88, keyword_argument; 88, 89; 88, 90; 89, identifier:lw; 90, integer:2; 91, keyword_argument; 91, 92; 91, 93; 92, identifier:label; 93, string:'j1'; 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:plt; 100, identifier:loglog; 101, argument_list; 101, 102; 101, 103; 101, 114; 101, 117; 102, identifier:k; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:np; 106, identifier:abs; 107, argument_list; 107, 108; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:f; 111, identifier:lhs; 112, argument_list; 112, 113; 113, identifier:k; 114, keyword_argument; 114, 115; 114, 116; 115, identifier:lw; 116, integer:2; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:label; 119, attribute; 119, 120; 119, 121; 120, identifier:f; 121, identifier:name; 122, if_statement; 122, 123; 122, 126; 123, comparison_operator:!=; 123, 124; 123, 125; 124, identifier:tit; 125, string:'fC'; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:plt; 131, identifier:xlabel; 132, argument_list; 132, 133; 133, string:'l'; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:plt; 138, identifier:legend; 139, argument_list; 139, 140; 140, keyword_argument; 140, 141; 140, 142; 141, identifier:loc; 142, string:'best'; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:plt; 147, identifier:sca; 148, argument_list; 148, 149; 149, subscript; 149, 150; 149, 151; 150, identifier:axes; 151, integer:1; 152, expression_statement; 152, 153; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:plt; 156, identifier:title; 157, argument_list; 157, 158; 158, binary_operator:+; 158, 159; 158, 162; 159, binary_operator:+; 159, 160; 159, 161; 160, string:'|'; 161, identifier:tit; 162, string:' rhs|'; 163, for_statement; 163, 164; 163, 165; 163, 166; 164, identifier:f; 165, identifier:fCI; 166, block; 166, 167; 167, if_statement; 167, 168; 167, 171; 167, 195; 168, comparison_operator:==; 168, 169; 168, 170; 169, identifier:tit; 170, string:'fC'; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:plt; 176, identifier:loglog; 177, argument_list; 177, 178; 177, 179; 177, 187; 177, 190; 178, identifier:r; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:np; 182, identifier:abs; 183, argument_list; 183, 184; 184, attribute; 184, 185; 184, 186; 185, identifier:f; 186, identifier:rhs; 187, keyword_argument; 187, 188; 187, 189; 188, identifier:lw; 189, integer:2; 190, keyword_argument; 190, 191; 190, 192; 191, identifier:label; 192, attribute; 192, 193; 192, 194; 193, identifier:f; 194, identifier:name; 195, else_clause; 195, 196; 196, block; 196, 197; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:plt; 201, identifier:loglog; 202, argument_list; 202, 203; 202, 204; 202, 215; 202, 218; 203, identifier:r; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:np; 207, identifier:abs; 208, argument_list; 208, 209; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:f; 212, identifier:rhs; 213, argument_list; 213, 214; 214, identifier:r; 215, keyword_argument; 215, 216; 215, 217; 216, identifier:lw; 217, integer:2; 218, keyword_argument; 218, 219; 218, 220; 219, identifier:label; 220, attribute; 220, 221; 220, 222; 221, identifier:f; 222, identifier:name; 223, for_statement; 223, 224; 223, 225; 223, 226; 224, identifier:f; 225, identifier:fCI; 226, block; 226, 227; 226, 253; 226, 265; 226, 350; 227, if_statement; 227, 228; 227, 238; 227, 245; 228, comparison_operator:in; 228, 229; 228, 234; 229, subscript; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:f; 232, identifier:name; 233, integer:1; 234, list:['0', '1', '2']; 234, 235; 234, 236; 234, 237; 235, string:'0'; 236, string:'1'; 237, string:'2'; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, assignment; 240, 241; 240, 242; 241, identifier:filt; 242, call; 242, 243; 242, 244; 243, identifier:j0j1filt; 244, argument_list; 245, else_clause; 245, 246; 246, block; 246, 247; 247, expression_statement; 247, 248; 248, assignment; 248, 249; 248, 250; 249, identifier:filt; 250, call; 250, 251; 250, 252; 251, identifier:sincosfilt; 252, argument_list; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 256; 255, identifier:kk; 256, binary_operator:/; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:filt; 259, identifier:base; 260, subscript; 260, 261; 260, 262; 260, 264; 261, identifier:r; 262, slice; 262, 263; 263, colon; 264, None; 265, if_statement; 265, 266; 265, 271; 265, 325; 266, comparison_operator:==; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:f; 269, identifier:name; 270, string:'j2'; 271, block; 271, 272; 271, 281; 271, 299; 271, 319; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:lhs; 275, call; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:f; 278, identifier:lhs; 279, argument_list; 279, 280; 280, identifier:kk; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 284; 283, identifier:kr0; 284, binary_operator:/; 284, 285; 284, 298; 285, call; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, identifier:np; 288, identifier:dot; 289, argument_list; 289, 290; 289, 293; 290, subscript; 290, 291; 290, 292; 291, identifier:lhs; 292, integer:0; 293, call; 293, 294; 293, 295; 294, identifier:getattr; 295, argument_list; 295, 296; 295, 297; 296, identifier:filt; 297, string:'j0'; 298, identifier:r; 299, expression_statement; 299, 300; 300, assignment; 300, 301; 300, 302; 301, identifier:kr1; 302, binary_operator:/; 302, 303; 302, 316; 303, call; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, identifier:np; 306, identifier:dot; 307, argument_list; 307, 308; 307, 311; 308, subscript; 308, 309; 308, 310; 309, identifier:lhs; 310, integer:1; 311, call; 311, 312; 311, 313; 312, identifier:getattr; 313, argument_list; 313, 314; 313, 315; 314, identifier:filt; 315, string:'j1'; 316, binary_operator:**; 316, 317; 316, 318; 317, identifier:r; 318, integer:2; 319, expression_statement; 319, 320; 320, assignment; 320, 321; 320, 322; 321, identifier:kr; 322, binary_operator:+; 322, 323; 322, 324; 323, identifier:kr0; 324, identifier:kr1; 325, else_clause; 325, 326; 326, block; 326, 327; 327, expression_statement; 327, 328; 328, assignment; 328, 329; 328, 330; 329, identifier:kr; 330, binary_operator:/; 330, 331; 330, 349; 331, call; 331, 332; 331, 335; 332, attribute; 332, 333; 332, 334; 333, identifier:np; 334, identifier:dot; 335, argument_list; 335, 336; 335, 342; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:f; 339, identifier:lhs; 340, argument_list; 340, 341; 341, identifier:kk; 342, call; 342, 343; 342, 344; 343, identifier:getattr; 344, argument_list; 344, 345; 344, 346; 345, identifier:filt; 346, attribute; 346, 347; 346, 348; 347, identifier:f; 348, identifier:name; 349, identifier:r; 350, expression_statement; 350, 351; 351, call; 351, 352; 351, 355; 352, attribute; 352, 353; 352, 354; 353, identifier:plt; 354, identifier:loglog; 355, argument_list; 355, 356; 355, 357; 355, 363; 355, 364; 355, 367; 356, identifier:r; 357, call; 357, 358; 357, 361; 358, attribute; 358, 359; 358, 360; 359, identifier:np; 360, identifier:abs; 361, argument_list; 361, 362; 362, identifier:kr; 363, string:'-.'; 364, keyword_argument; 364, 365; 364, 366; 365, identifier:lw; 366, integer:2; 367, keyword_argument; 367, 368; 367, 369; 368, identifier:label; 369, attribute; 369, 370; 369, 371; 370, identifier:filt; 371, identifier:name; 372, if_statement; 372, 373; 372, 376; 373, comparison_operator:!=; 373, 374; 373, 375; 374, identifier:tit; 375, string:'fC'; 376, block; 376, 377; 377, expression_statement; 377, 378; 378, call; 378, 379; 378, 382; 379, attribute; 379, 380; 379, 381; 380, identifier:plt; 381, identifier:xlabel; 382, argument_list; 382, 383; 383, string:'r'; 384, expression_statement; 384, 385; 385, call; 385, 386; 385, 389; 386, attribute; 386, 387; 386, 388; 387, identifier:plt; 388, identifier:legend; 389, argument_list; 389, 390; 390, keyword_argument; 390, 391; 390, 392; 391, identifier:loc; 392, string:'best' | def _plot_transform_pairs(fCI, r, k, axes, tit):
r
plt.sca(axes[0])
plt.title('|' + tit + ' lhs|')
for f in fCI:
if f.name == 'j2':
lhs = f.lhs(k)
plt.loglog(k, np.abs(lhs[0]), lw=2, label='j0')
plt.loglog(k, np.abs(lhs[1]), lw=2, label='j1')
else:
plt.loglog(k, np.abs(f.lhs(k)), lw=2, label=f.name)
if tit != 'fC':
plt.xlabel('l')
plt.legend(loc='best')
plt.sca(axes[1])
plt.title('|' + tit + ' rhs|')
for f in fCI:
if tit == 'fC':
plt.loglog(r, np.abs(f.rhs), lw=2, label=f.name)
else:
plt.loglog(r, np.abs(f.rhs(r)), lw=2, label=f.name)
for f in fCI:
if f.name[1] in ['0', '1', '2']:
filt = j0j1filt()
else:
filt = sincosfilt()
kk = filt.base/r[:, None]
if f.name == 'j2':
lhs = f.lhs(kk)
kr0 = np.dot(lhs[0], getattr(filt, 'j0'))/r
kr1 = np.dot(lhs[1], getattr(filt, 'j1'))/r**2
kr = kr0+kr1
else:
kr = np.dot(f.lhs(kk), getattr(filt, f.name))/r
plt.loglog(r, np.abs(kr), '-.', lw=2, label=filt.name)
if tit != 'fC':
plt.xlabel('r')
plt.legend(loc='best') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 36; 2, function_name:empy_hankel; 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; 3, 30; 3, 33; 4, identifier:ftype; 5, identifier:zsrc; 6, identifier:zrec; 7, identifier:res; 8, identifier:freqtime; 9, default_parameter; 9, 10; 9, 11; 10, identifier:depth; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:aniso; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:epermH; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:epermV; 20, None; 21, default_parameter; 21, 22; 21, 23; 22, identifier:mpermH; 23, None; 24, default_parameter; 24, 25; 24, 26; 25, identifier:mpermV; 26, None; 27, default_parameter; 27, 28; 27, 29; 28, identifier:htarg; 29, None; 30, default_parameter; 30, 31; 30, 32; 31, identifier:verblhs; 32, integer:0; 33, default_parameter; 33, 34; 33, 35; 34, identifier:verbrhs; 35, integer:0; 36, block; 36, 37; 36, 39; 36, 79; 36, 110; 36, 195; 36, 235; 36, 288; 37, expression_statement; 37, 38; 38, identifier:r; 39, if_statement; 39, 40; 39, 45; 40, call; 40, 41; 40, 42; 41, identifier:isinstance; 42, argument_list; 42, 43; 42, 44; 43, identifier:ftype; 44, identifier:list; 45, block; 45, 46; 45, 50; 45, 77; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:out; 49, list:[]; 50, for_statement; 50, 51; 50, 52; 50, 53; 51, identifier:f; 52, identifier:ftype; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:out; 58, identifier:append; 59, argument_list; 59, 60; 60, call; 60, 61; 60, 62; 61, identifier:empy_hankel; 62, argument_list; 62, 63; 62, 64; 62, 65; 62, 66; 62, 67; 62, 68; 62, 69; 62, 70; 62, 71; 62, 72; 62, 73; 62, 74; 62, 75; 62, 76; 63, identifier:f; 64, identifier:zsrc; 65, identifier:zrec; 66, identifier:res; 67, identifier:freqtime; 68, identifier:depth; 69, identifier:aniso; 70, identifier:epermH; 71, identifier:epermV; 72, identifier:mpermH; 73, identifier:mpermV; 74, identifier:htarg; 75, identifier:verblhs; 76, identifier:verbrhs; 77, return_statement; 77, 78; 78, identifier:out; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:model; 82, dictionary; 82, 83; 82, 89; 82, 92; 82, 95; 82, 98; 82, 101; 82, 104; 82, 107; 83, pair; 83, 84; 83, 85; 84, string:'src'; 85, list:[0, 0, zsrc]; 85, 86; 85, 87; 85, 88; 86, integer:0; 87, integer:0; 88, identifier:zsrc; 89, pair; 89, 90; 89, 91; 90, string:'depth'; 91, identifier:depth; 92, pair; 92, 93; 92, 94; 93, string:'res'; 94, identifier:res; 95, pair; 95, 96; 95, 97; 96, string:'aniso'; 97, identifier:aniso; 98, pair; 98, 99; 98, 100; 99, string:'epermH'; 100, identifier:epermH; 101, pair; 101, 102; 101, 103; 102, string:'epermV'; 103, identifier:epermV; 104, pair; 104, 105; 104, 106; 105, string:'mpermH'; 106, identifier:mpermH; 107, pair; 107, 108; 107, 109; 108, string:'mpermV'; 109, identifier:mpermV; 110, if_statement; 110, 111; 110, 114; 110, 143; 110, 162; 111, comparison_operator:==; 111, 112; 111, 113; 112, identifier:ftype; 113, string:'j0'; 114, block; 114, 115; 114, 121; 114, 132; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 120; 117, subscript; 117, 118; 117, 119; 118, identifier:model; 119, string:'ab'; 120, integer:11; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:x; 124, binary_operator:/; 124, 125; 124, 126; 125, integer:1; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:np; 129, identifier:sqrt; 130, argument_list; 130, 131; 131, integer:2; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:y; 135, binary_operator:/; 135, 136; 135, 137; 136, integer:1; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:np; 140, identifier:sqrt; 141, argument_list; 141, 142; 142, integer:2; 143, elif_clause; 143, 144; 143, 147; 144, comparison_operator:==; 144, 145; 144, 146; 145, identifier:ftype; 146, string:'j1'; 147, block; 147, 148; 147, 154; 147, 158; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 153; 150, subscript; 150, 151; 150, 152; 151, identifier:model; 152, string:'ab'; 153, integer:31; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:x; 157, integer:1; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:y; 161, integer:0; 162, elif_clause; 162, 163; 162, 166; 163, comparison_operator:==; 163, 164; 163, 165; 164, identifier:ftype; 165, string:'j2'; 166, block; 166, 167; 166, 173; 166, 184; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 172; 169, subscript; 169, 170; 169, 171; 170, identifier:model; 171, string:'ab'; 172, integer:12; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:x; 176, binary_operator:/; 176, 177; 176, 178; 177, integer:1; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:np; 181, identifier:sqrt; 182, argument_list; 182, 183; 183, integer:2; 184, expression_statement; 184, 185; 185, assignment; 185, 186; 185, 187; 186, identifier:y; 187, binary_operator:/; 187, 188; 187, 189; 188, integer:1; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:np; 192, identifier:sqrt; 193, argument_list; 193, 194; 194, integer:2; 195, function_definition; 195, 196; 195, 197; 195, 199; 196, function_name:rhs; 197, parameters; 197, 198; 198, identifier:r; 199, block; 199, 200; 199, 233; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:out; 203, call; 203, 204; 203, 205; 204, identifier:dipole; 205, argument_list; 205, 206; 205, 216; 205, 219; 205, 222; 205, 225; 205, 228; 205, 231; 206, keyword_argument; 206, 207; 206, 208; 207, identifier:rec; 208, list:[r*x, r*y, zrec]; 208, 209; 208, 212; 208, 215; 209, binary_operator:*; 209, 210; 209, 211; 210, identifier:r; 211, identifier:x; 212, binary_operator:*; 212, 213; 212, 214; 213, identifier:r; 214, identifier:y; 215, identifier:zrec; 216, keyword_argument; 216, 217; 216, 218; 217, identifier:ht; 218, string:'qwe'; 219, keyword_argument; 219, 220; 219, 221; 220, identifier:xdirect; 221, True; 222, keyword_argument; 222, 223; 222, 224; 223, identifier:verb; 224, identifier:verbrhs; 225, keyword_argument; 225, 226; 225, 227; 226, identifier:htarg; 227, identifier:htarg; 228, keyword_argument; 228, 229; 228, 230; 229, identifier:freqtime; 230, identifier:freqtime; 231, dictionary_splat; 231, 232; 232, identifier:model; 233, return_statement; 233, 234; 234, identifier:out; 235, function_definition; 235, 236; 235, 237; 235, 239; 236, function_name:lhs; 237, parameters; 237, 238; 238, identifier:k; 239, block; 239, 240; 239, 265; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 245; 242, pattern_list; 242, 243; 242, 244; 243, identifier:lhs0; 244, identifier:lhs1; 245, call; 245, 246; 245, 247; 246, identifier:dipole_k; 247, argument_list; 247, 248; 247, 254; 247, 257; 247, 260; 247, 263; 248, keyword_argument; 248, 249; 248, 250; 249, identifier:rec; 250, list:[x, y, zrec]; 250, 251; 250, 252; 250, 253; 251, identifier:x; 252, identifier:y; 253, identifier:zrec; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:wavenumber; 256, identifier:k; 257, keyword_argument; 257, 258; 257, 259; 258, identifier:verb; 259, identifier:verblhs; 260, keyword_argument; 260, 261; 260, 262; 261, identifier:freq; 262, identifier:freqtime; 263, dictionary_splat; 263, 264; 264, identifier:model; 265, if_statement; 265, 266; 265, 269; 265, 272; 265, 279; 266, comparison_operator:==; 266, 267; 266, 268; 267, identifier:ftype; 268, string:'j0'; 269, block; 269, 270; 270, return_statement; 270, 271; 271, identifier:lhs0; 272, elif_clause; 272, 273; 272, 276; 273, comparison_operator:==; 273, 274; 273, 275; 274, identifier:ftype; 275, string:'j1'; 276, block; 276, 277; 277, return_statement; 277, 278; 278, identifier:lhs1; 279, elif_clause; 279, 280; 279, 283; 280, comparison_operator:==; 280, 281; 280, 282; 281, identifier:ftype; 282, string:'j2'; 283, block; 283, 284; 284, return_statement; 284, 285; 285, tuple; 285, 286; 285, 287; 286, identifier:lhs0; 287, identifier:lhs1; 288, return_statement; 288, 289; 289, call; 289, 290; 289, 291; 290, identifier:Ghosh; 291, argument_list; 291, 292; 291, 293; 291, 294; 292, identifier:ftype; 293, identifier:lhs; 294, identifier:rhs | def empy_hankel(ftype, zsrc, zrec, res, freqtime, depth=None, aniso=None,
epermH=None, epermV=None, mpermH=None, mpermV=None,
htarg=None, verblhs=0, verbrhs=0):
r
if isinstance(ftype, list):
out = []
for f in ftype:
out.append(empy_hankel(f, zsrc, zrec, res, freqtime, depth, aniso,
epermH, epermV, mpermH, mpermV, htarg,
verblhs, verbrhs))
return out
model = {'src': [0, 0, zsrc],
'depth': depth,
'res': res,
'aniso': aniso,
'epermH': epermH,
'epermV': epermV,
'mpermH': mpermH,
'mpermV': mpermV}
if ftype == 'j0':
model['ab'] = 11
x = 1/np.sqrt(2)
y = 1/np.sqrt(2)
elif ftype == 'j1':
model['ab'] = 31
x = 1
y = 0
elif ftype == 'j2':
model['ab'] = 12
x = 1/np.sqrt(2)
y = 1/np.sqrt(2)
def rhs(r):
out = dipole(rec=[r*x, r*y, zrec], ht='qwe', xdirect=True,
verb=verbrhs, htarg=htarg, freqtime=freqtime, **model)
return out
def lhs(k):
lhs0, lhs1 = dipole_k(rec=[x, y, zrec], wavenumber=k, verb=verblhs,
freq=freqtime, **model)
if ftype == 'j0':
return lhs0
elif ftype == 'j1':
return lhs1
elif ftype == 'j2':
return (lhs0, lhs1)
return Ghosh(ftype, lhs, rhs) |
0, module; 0, 1; 0, 8; 0, 10; 0, 16; 0, 31; 0, 44; 0, 56; 0, 370; 0, 382; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_min_val; 3, parameters; 3, 4; 3, 5; 4, identifier:spaceshift; 5, list_splat_pattern; 5, 6; 6, identifier:params; 7, block:; 8, expression_statement; 8, 9; 9, identifier:r; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 15; 12, pattern_list; 12, 13; 12, 14; 13, identifier:spacing; 14, identifier:shift; 15, identifier:spaceshift; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 30; 18, pattern_list; 18, 19; 18, 20; 18, 21; 18, 22; 18, 23; 18, 24; 18, 25; 18, 26; 18, 27; 18, 28; 18, 29; 19, identifier:n; 20, identifier:fI; 21, identifier:fC; 22, identifier:r; 23, identifier:r_def; 24, identifier:error; 25, identifier:reim; 26, identifier:cvar; 27, identifier:verb; 28, identifier:plot; 29, identifier:log; 30, identifier:params; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:dlf; 34, call; 34, 35; 34, 36; 35, identifier:_calculate_filter; 36, argument_list; 36, 37; 36, 38; 36, 39; 36, 40; 36, 41; 36, 42; 36, 43; 37, identifier:n; 38, identifier:spacing; 39, identifier:shift; 40, identifier:fI; 41, identifier:r_def; 42, identifier:reim; 43, string:'filt'; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:k; 47, binary_operator:/; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:dlf; 50, identifier:base; 51, subscript; 51, 52; 51, 53; 51, 55; 52, identifier:r; 53, slice; 53, 54; 54, colon; 55, None; 56, for_statement; 56, 57; 56, 60; 56, 64; 57, pattern_list; 57, 58; 57, 59; 58, identifier:i; 59, identifier:f; 60, call; 60, 61; 60, 62; 61, identifier:enumerate; 62, argument_list; 62, 63; 63, identifier:fC; 64, block; 64, 65; 64, 74; 64, 145; 64, 163; 64, 176; 64, 287; 64, 313; 64, 353; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:lhs; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:f; 71, identifier:lhs; 72, argument_list; 72, 73; 73, identifier:k; 74, if_statement; 74, 75; 74, 80; 74, 125; 75, comparison_operator:==; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:f; 78, identifier:name; 79, string:'j2'; 80, block; 80, 81; 80, 99; 80, 119; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:rhs0; 84, binary_operator:/; 84, 85; 84, 98; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:np; 88, identifier:dot; 89, argument_list; 89, 90; 89, 93; 90, subscript; 90, 91; 90, 92; 91, identifier:lhs; 92, integer:0; 93, call; 93, 94; 93, 95; 94, identifier:getattr; 95, argument_list; 95, 96; 95, 97; 96, identifier:dlf; 97, string:'j0'; 98, identifier:r; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:rhs1; 102, binary_operator:/; 102, 103; 102, 116; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:np; 106, identifier:dot; 107, argument_list; 107, 108; 107, 111; 108, subscript; 108, 109; 108, 110; 109, identifier:lhs; 110, integer:1; 111, call; 111, 112; 111, 113; 112, identifier:getattr; 113, argument_list; 113, 114; 113, 115; 114, identifier:dlf; 115, string:'j1'; 116, binary_operator:**; 116, 117; 116, 118; 117, identifier:r; 118, integer:2; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:rhs; 122, binary_operator:+; 122, 123; 122, 124; 123, identifier:rhs0; 124, identifier:rhs1; 125, else_clause; 125, 126; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:rhs; 130, binary_operator:/; 130, 131; 130, 144; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:np; 134, identifier:dot; 135, argument_list; 135, 136; 135, 137; 136, identifier:lhs; 137, call; 137, 138; 137, 139; 138, identifier:getattr; 139, argument_list; 139, 140; 139, 141; 140, identifier:dlf; 141, attribute; 141, 142; 141, 143; 142, identifier:f; 143, identifier:name; 144, identifier:r; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:rel_error; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:np; 151, identifier:abs; 152, argument_list; 152, 153; 153, binary_operator:/; 153, 154; 153, 160; 154, parenthesized_expression; 154, 155; 155, binary_operator:-; 155, 156; 155, 157; 156, identifier:rhs; 157, attribute; 157, 158; 157, 159; 158, identifier:f; 159, identifier:rhs; 160, attribute; 160, 161; 160, 162; 161, identifier:f; 162, identifier:rhs; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:imin0; 166, subscript; 166, 167; 166, 175; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:np; 170, identifier:where; 171, argument_list; 171, 172; 172, comparison_operator:>; 172, 173; 172, 174; 173, identifier:rel_error; 174, identifier:error; 175, integer:0; 176, if_statement; 176, 177; 176, 197; 176, 202; 176, 246; 177, boolean_operator:or; 177, 178; 177, 186; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:np; 181, identifier:all; 182, argument_list; 182, 183; 183, comparison_operator:==; 183, 184; 183, 185; 184, identifier:rhs; 185, integer:0; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:np; 189, identifier:all; 190, argument_list; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:np; 194, identifier:isnan; 195, argument_list; 195, 196; 196, identifier:rhs; 197, block; 197, 198; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:imin0; 201, integer:0; 202, elif_clause; 202, 203; 202, 208; 203, comparison_operator:==; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:imin0; 206, identifier:size; 207, integer:0; 208, block; 208, 209; 208, 217; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:imin0; 212, binary_operator:-; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:rhs; 215, identifier:size; 216, integer:1; 217, if_statement; 217, 218; 217, 227; 218, boolean_operator:and; 218, 219; 218, 222; 219, comparison_operator:>; 219, 220; 219, 221; 220, identifier:verb; 221, integer:0; 222, comparison_operator:==; 222, 223; 222, 226; 223, subscript; 223, 224; 223, 225; 224, identifier:log; 225, string:'warn-r'; 226, integer:0; 227, block; 227, 228; 227, 240; 228, expression_statement; 228, 229; 229, call; 229, 230; 229, 231; 230, identifier:print; 231, argument_list; 231, 232; 232, binary_operator:+; 232, 233; 232, 239; 233, binary_operator:+; 233, 234; 233, 235; 234, string:'* WARNING :: all data have error < '; 235, call; 235, 236; 235, 237; 236, identifier:str; 237, argument_list; 237, 238; 238, identifier:error; 239, string:'; choose larger r or set error-level higher.'; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 245; 242, subscript; 242, 243; 242, 244; 243, identifier:log; 244, string:'warn-r'; 245, integer:1; 246, else_clause; 246, 247; 247, block; 247, 248; 248, if_statement; 248, 249; 248, 254; 248, 270; 249, comparison_operator:>; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:imin0; 252, identifier:size; 253, integer:4; 254, block; 254, 255; 255, expression_statement; 255, 256; 256, assignment; 256, 257; 256, 258; 257, identifier:imin0; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:np; 261, identifier:max; 262, argument_list; 262, 263; 263, list:[0, imin0[4]-5]; 263, 264; 263, 265; 264, integer:0; 265, binary_operator:-; 265, 266; 265, 269; 266, subscript; 266, 267; 266, 268; 267, identifier:imin0; 268, integer:4; 269, integer:5; 270, else_clause; 270, 271; 271, block; 271, 272; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:imin0; 275, call; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:np; 278, identifier:max; 279, argument_list; 279, 280; 280, list:[0, imin0[0]-1]; 280, 281; 280, 282; 281, integer:0; 282, binary_operator:-; 282, 283; 282, 286; 283, subscript; 283, 284; 283, 285; 284, identifier:imin0; 285, integer:0; 286, integer:1; 287, if_statement; 287, 288; 287, 291; 287, 303; 288, comparison_operator:==; 288, 289; 288, 290; 289, identifier:cvar; 290, string:'amp'; 291, block; 291, 292; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 295; 294, identifier:min_val0; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:np; 298, identifier:abs; 299, argument_list; 299, 300; 300, subscript; 300, 301; 300, 302; 301, identifier:rhs; 302, identifier:imin0; 303, else_clause; 303, 304; 304, block; 304, 305; 305, expression_statement; 305, 306; 306, assignment; 306, 307; 306, 308; 307, identifier:min_val0; 308, binary_operator:/; 308, 309; 308, 310; 309, integer:1; 310, subscript; 310, 311; 310, 312; 311, identifier:r; 312, identifier:imin0; 313, if_statement; 313, 314; 313, 317; 313, 332; 314, comparison_operator:==; 314, 315; 314, 316; 315, identifier:i; 316, integer:0; 317, block; 317, 318; 317, 325; 318, expression_statement; 318, 319; 319, assignment; 319, 320; 319, 321; 320, identifier:imin; 321, call; 321, 322; 321, 323; 322, identifier:dc; 323, argument_list; 323, 324; 324, identifier:imin0; 325, expression_statement; 325, 326; 326, assignment; 326, 327; 326, 328; 327, identifier:min_val; 328, call; 328, 329; 328, 330; 329, identifier:dc; 330, argument_list; 330, 331; 331, identifier:min_val0; 332, else_clause; 332, 333; 333, block; 333, 334; 334, if_statement; 334, 335; 334, 338; 335, comparison_operator:>; 335, 336; 335, 337; 336, identifier:min_val0; 337, identifier:min_val; 338, block; 338, 339; 338, 346; 339, expression_statement; 339, 340; 340, assignment; 340, 341; 340, 342; 341, identifier:min_val; 342, call; 342, 343; 342, 344; 343, identifier:dc; 344, argument_list; 344, 345; 345, identifier:min_val0; 346, expression_statement; 346, 347; 347, assignment; 347, 348; 347, 349; 348, identifier:imin; 349, call; 349, 350; 349, 351; 350, identifier:dc; 351, argument_list; 351, 352; 352, identifier:imin0; 353, if_statement; 353, 354; 353, 357; 354, comparison_operator:>; 354, 355; 354, 356; 355, identifier:plot; 356, integer:2; 357, block; 357, 358; 358, expression_statement; 358, 359; 359, call; 359, 360; 359, 361; 360, identifier:_plot_inversion; 361, argument_list; 361, 362; 361, 363; 361, 364; 361, 365; 361, 366; 361, 367; 361, 368; 361, 369; 362, identifier:f; 363, identifier:rhs; 364, identifier:r; 365, identifier:k; 366, identifier:imin0; 367, identifier:spacing; 368, identifier:shift; 369, identifier:cvar; 370, if_statement; 370, 371; 370, 374; 371, comparison_operator:>; 371, 372; 371, 373; 372, identifier:verb; 373, integer:1; 374, block; 374, 375; 375, expression_statement; 375, 376; 376, assignment; 376, 377; 376, 378; 377, identifier:log; 378, call; 378, 379; 378, 380; 379, identifier:_print_count; 380, argument_list; 380, 381; 381, identifier:log; 382, return_statement; 382, 383; 383, call; 383, 384; 383, 387; 384, attribute; 384, 385; 384, 386; 385, identifier:np; 386, identifier:where; 387, argument_list; 387, 388; 387, 391; 387, 394; 388, comparison_operator:==; 388, 389; 388, 390; 389, identifier:imin; 390, integer:0; 391, attribute; 391, 392; 391, 393; 392, identifier:np; 393, identifier:inf; 394, identifier:min_val | def _get_min_val(spaceshift, *params):
r
spacing, shift = spaceshift
n, fI, fC, r, r_def, error, reim, cvar, verb, plot, log = params
dlf = _calculate_filter(n, spacing, shift, fI, r_def, reim, 'filt')
k = dlf.base/r[:, None]
for i, f in enumerate(fC):
lhs = f.lhs(k)
if f.name == 'j2':
rhs0 = np.dot(lhs[0], getattr(dlf, 'j0'))/r
rhs1 = np.dot(lhs[1], getattr(dlf, 'j1'))/r**2
rhs = rhs0 + rhs1
else:
rhs = np.dot(lhs, getattr(dlf, f.name))/r
rel_error = np.abs((rhs - f.rhs)/f.rhs)
imin0 = np.where(rel_error > error)[0]
if np.all(rhs == 0) or np.all(np.isnan(rhs)):
imin0 = 0
elif imin0.size == 0:
imin0 = rhs.size-1
if verb > 0 and log['warn-r'] == 0:
print('* WARNING :: all data have error < ' + str(error) +
'; choose larger r or set error-level higher.')
log['warn-r'] = 1
else:
if imin0.size > 4:
imin0 = np.max([0, imin0[4]-5])
else:
imin0 = np.max([0, imin0[0]-1])
if cvar == 'amp':
min_val0 = np.abs(rhs[imin0])
else:
min_val0 = 1/r[imin0]
if i == 0:
imin = dc(imin0)
min_val = dc(min_val0)
else:
if min_val0 > min_val:
min_val = dc(min_val0)
imin = dc(imin0)
if plot > 2:
_plot_inversion(f, rhs, r, k, imin0, spacing, shift, cvar)
if verb > 1:
log = _print_count(log)
return np.where(imin == 0, np.inf, min_val) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:wavenumber; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 18; 4, identifier:zsrc; 5, identifier:zrec; 6, identifier:lsrc; 7, identifier:lrec; 8, identifier:depth; 9, identifier:etaH; 10, identifier:etaV; 11, identifier:zetaH; 12, identifier:zetaV; 13, identifier:lambd; 14, identifier:ab; 15, identifier:xdirect; 16, identifier:msrc; 17, identifier:mrec; 18, identifier:use_ne_eval; 19, block; 19, 20; 19, 22; 19, 45; 19, 49; 19, 53; 19, 57; 19, 71; 19, 85; 19, 219; 20, expression_statement; 20, 21; 21, identifier:r; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 27; 24, pattern_list; 24, 25; 24, 26; 25, identifier:PTM; 26, identifier:PTE; 27, call; 27, 28; 27, 29; 28, identifier:greenfct; 29, argument_list; 29, 30; 29, 31; 29, 32; 29, 33; 29, 34; 29, 35; 29, 36; 29, 37; 29, 38; 29, 39; 29, 40; 29, 41; 29, 42; 29, 43; 29, 44; 30, identifier:zsrc; 31, identifier:zrec; 32, identifier:lsrc; 33, identifier:lrec; 34, identifier:depth; 35, identifier:etaH; 36, identifier:etaV; 37, identifier:zetaH; 38, identifier:zetaV; 39, identifier:lambd; 40, identifier:ab; 41, identifier:xdirect; 42, identifier:msrc; 43, identifier:mrec; 44, identifier:use_ne_eval; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:PJ0; 48, None; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:PJ1; 52, None; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:PJ0b; 56, None; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:Ptot; 60, binary_operator:/; 60, 61; 60, 65; 61, parenthesized_expression; 61, 62; 62, binary_operator:+; 62, 63; 62, 64; 63, identifier:PTM; 64, identifier:PTE; 65, parenthesized_expression; 65, 66; 66, binary_operator:*; 66, 67; 66, 68; 67, integer:4; 68, attribute; 68, 69; 68, 70; 69, identifier:np; 70, identifier:pi; 71, if_statement; 71, 72; 71, 73; 71, 79; 72, identifier:mrec; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:sign; 77, unary_operator:-; 77, 78; 78, integer:1; 79, else_clause; 79, 80; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:sign; 84, integer:1; 85, if_statement; 85, 86; 85, 97; 85, 166; 85, 201; 86, comparison_operator:in; 86, 87; 86, 88; 87, identifier:ab; 88, list:[11, 12, 21, 22, 14, 24, 15, 25]; 88, 89; 88, 90; 88, 91; 88, 92; 88, 93; 88, 94; 88, 95; 88, 96; 89, integer:11; 90, integer:12; 91, integer:21; 92, integer:22; 93, integer:14; 94, integer:24; 95, integer:15; 96, integer:25; 97, block; 97, 98; 97, 110; 97, 120; 97, 127; 98, if_statement; 98, 99; 98, 104; 99, comparison_operator:in; 99, 100; 99, 101; 100, identifier:ab; 101, list:[14, 22]; 101, 102; 101, 103; 102, integer:14; 103, integer:22; 104, block; 104, 105; 105, expression_statement; 105, 106; 106, augmented_assignment:*=; 106, 107; 106, 108; 107, identifier:sign; 108, unary_operator:-; 108, 109; 109, integer:1; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:PJ0b; 113, binary_operator:*; 113, 114; 113, 119; 114, binary_operator:*; 114, 115; 114, 118; 115, binary_operator:/; 115, 116; 115, 117; 116, identifier:sign; 117, integer:2; 118, identifier:Ptot; 119, identifier:lambd; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:PJ1; 123, binary_operator:*; 123, 124; 123, 126; 124, unary_operator:-; 124, 125; 125, identifier:sign; 126, identifier:Ptot; 127, if_statement; 127, 128; 127, 135; 128, comparison_operator:in; 128, 129; 128, 130; 129, identifier:ab; 130, list:[11, 22, 24, 15]; 130, 131; 130, 132; 130, 133; 130, 134; 131, integer:11; 132, integer:22; 133, integer:24; 134, integer:15; 135, block; 135, 136; 135, 148; 136, if_statement; 136, 137; 136, 142; 137, comparison_operator:in; 137, 138; 137, 139; 138, identifier:ab; 139, list:[22, 24]; 139, 140; 139, 141; 140, integer:22; 141, integer:24; 142, block; 142, 143; 143, expression_statement; 143, 144; 144, augmented_assignment:*=; 144, 145; 144, 146; 145, identifier:sign; 146, unary_operator:-; 146, 147; 147, integer:1; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:PJ0; 151, binary_operator:*; 151, 152; 151, 165; 152, binary_operator:/; 152, 153; 152, 159; 153, binary_operator:*; 153, 154; 153, 155; 154, identifier:sign; 155, parenthesized_expression; 155, 156; 156, binary_operator:-; 156, 157; 156, 158; 157, identifier:PTM; 158, identifier:PTE; 159, parenthesized_expression; 159, 160; 160, binary_operator:*; 160, 161; 160, 162; 161, integer:8; 162, attribute; 162, 163; 162, 164; 163, identifier:np; 164, identifier:pi; 165, identifier:lambd; 166, elif_clause; 166, 167; 166, 178; 167, comparison_operator:in; 167, 168; 167, 169; 168, identifier:ab; 169, list:[13, 23, 31, 32, 34, 35, 16, 26]; 169, 170; 169, 171; 169, 172; 169, 173; 169, 174; 169, 175; 169, 176; 169, 177; 170, integer:13; 171, integer:23; 172, integer:31; 173, integer:32; 174, integer:34; 175, integer:35; 176, integer:16; 177, integer:26; 178, block; 178, 179; 178, 189; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:PJ1; 182, binary_operator:*; 182, 183; 182, 188; 183, binary_operator:*; 183, 184; 183, 187; 184, binary_operator:*; 184, 185; 184, 186; 185, identifier:sign; 186, identifier:Ptot; 187, identifier:lambd; 188, identifier:lambd; 189, if_statement; 189, 190; 189, 195; 190, comparison_operator:in; 190, 191; 190, 192; 191, identifier:ab; 192, list:[34, 26]; 192, 193; 192, 194; 193, integer:34; 194, integer:26; 195, block; 195, 196; 196, expression_statement; 196, 197; 197, augmented_assignment:*=; 197, 198; 197, 199; 198, identifier:PJ1; 199, unary_operator:-; 199, 200; 200, integer:1; 201, elif_clause; 201, 202; 201, 206; 202, comparison_operator:in; 202, 203; 202, 204; 203, identifier:ab; 204, list:[33, ]; 204, 205; 205, integer:33; 206, block; 206, 207; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 210; 209, identifier:PJ0; 210, binary_operator:*; 210, 211; 210, 218; 211, binary_operator:*; 211, 212; 211, 217; 212, binary_operator:*; 212, 213; 212, 216; 213, binary_operator:*; 213, 214; 213, 215; 214, identifier:sign; 215, identifier:Ptot; 216, identifier:lambd; 217, identifier:lambd; 218, identifier:lambd; 219, return_statement; 219, 220; 220, expression_list; 220, 221; 220, 222; 220, 223; 221, identifier:PJ0; 222, identifier:PJ1; 223, identifier:PJ0b | def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd,
ab, xdirect, msrc, mrec, use_ne_eval):
r
PTM, PTE = greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH,
zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval)
PJ0 = None
PJ1 = None
PJ0b = None
Ptot = (PTM + PTE)/(4*np.pi)
if mrec:
sign = -1
else:
sign = 1
if ab in [11, 12, 21, 22, 14, 24, 15, 25]:
if ab in [14, 22]:
sign *= -1
PJ0b = sign/2*Ptot*lambd
PJ1 = -sign*Ptot
if ab in [11, 22, 24, 15]:
if ab in [22, 24]:
sign *= -1
PJ0 = sign*(PTM - PTE)/(8*np.pi)*lambd
elif ab in [13, 23, 31, 32, 34, 35, 16, 26]:
PJ1 = sign*Ptot*lambd*lambd
if ab in [34, 26]:
PJ1 *= -1
elif ab in [33, ]:
PJ0 = sign*Ptot*lambd*lambd*lambd
return PJ0, PJ1, PJ0b |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:reflections; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:depth; 5, identifier:e_zH; 6, identifier:Gam; 7, identifier:lrec; 8, identifier:lsrc; 9, identifier:use_ne_eval; 10, block; 10, 11; 10, 13; 10, 407; 11, expression_statement; 11, 12; 12, identifier:r; 13, for_statement; 13, 14; 13, 15; 13, 18; 14, identifier:plus; 15, list:[True, False]; 15, 16; 15, 17; 16, True; 17, False; 18, block; 18, 19; 18, 102; 18, 115; 18, 131; 18, 140; 18, 175; 18, 379; 18, 394; 19, if_statement; 19, 20; 19, 21; 19, 65; 20, identifier:plus; 21, block; 21, 22; 21, 26; 21, 48; 21, 57; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:pm; 25, integer:1; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:layer_count; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:np; 32, identifier:arange; 33, argument_list; 33, 34; 33, 39; 33, 46; 34, binary_operator:-; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:depth; 37, identifier:size; 38, integer:2; 39, binary_operator:-; 39, 40; 39, 45; 40, call; 40, 41; 40, 42; 41, identifier:min; 42, argument_list; 42, 43; 42, 44; 43, identifier:lrec; 44, identifier:lsrc; 45, integer:1; 46, unary_operator:-; 46, 47; 47, integer:1; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:izout; 51, call; 51, 52; 51, 53; 52, identifier:abs; 53, argument_list; 53, 54; 54, binary_operator:-; 54, 55; 54, 56; 55, identifier:lsrc; 56, identifier:lrec; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:minmax; 60, call; 60, 61; 60, 62; 61, identifier:max; 62, argument_list; 62, 63; 62, 64; 63, identifier:lrec; 64, identifier:lsrc; 65, else_clause; 65, 66; 66, block; 66, 67; 66, 72; 66, 89; 66, 93; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:pm; 70, unary_operator:-; 70, 71; 71, integer:1; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:layer_count; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:np; 78, identifier:arange; 79, argument_list; 79, 80; 79, 81; 79, 88; 80, integer:1; 81, binary_operator:+; 81, 82; 81, 87; 82, call; 82, 83; 82, 84; 83, identifier:max; 84, argument_list; 84, 85; 84, 86; 85, identifier:lrec; 86, identifier:lsrc; 87, integer:1; 88, integer:1; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:izout; 92, integer:0; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:minmax; 96, unary_operator:-; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:min; 99, argument_list; 99, 100; 99, 101; 100, identifier:lrec; 101, identifier:lsrc; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:shiftplus; 105, boolean_operator:and; 105, 106; 105, 113; 106, boolean_operator:and; 106, 107; 106, 110; 107, comparison_operator:<; 107, 108; 107, 109; 108, identifier:lrec; 109, identifier:lsrc; 110, comparison_operator:==; 110, 111; 110, 112; 111, identifier:lrec; 112, integer:0; 113, not_operator; 113, 114; 114, identifier:plus; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:shiftminus; 118, boolean_operator:and; 118, 119; 118, 130; 119, boolean_operator:and; 119, 120; 119, 123; 120, comparison_operator:>; 120, 121; 120, 122; 121, identifier:lrec; 122, identifier:lsrc; 123, comparison_operator:==; 123, 124; 123, 125; 124, identifier:lrec; 125, binary_operator:-; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:depth; 128, identifier:size; 129, integer:1; 130, identifier:plus; 131, if_statement; 131, 132; 131, 135; 132, boolean_operator:or; 132, 133; 132, 134; 133, identifier:shiftplus; 134, identifier:shiftminus; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, augmented_assignment:-=; 137, 138; 137, 139; 138, identifier:izout; 139, identifier:pm; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:Ref; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:np; 146, identifier:zeros; 147, argument_list; 147, 148; 147, 172; 148, tuple; 148, 149; 148, 154; 148, 159; 148, 167; 149, subscript; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:Gam; 152, identifier:shape; 153, integer:0; 154, subscript; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:Gam; 157, identifier:shape; 158, integer:1; 159, binary_operator:+; 159, 160; 159, 166; 160, call; 160, 161; 160, 162; 161, identifier:abs; 162, argument_list; 162, 163; 163, binary_operator:-; 163, 164; 163, 165; 164, identifier:lsrc; 165, identifier:lrec; 166, integer:1; 167, subscript; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:Gam; 170, identifier:shape; 171, integer:3; 172, keyword_argument; 172, 173; 172, 174; 173, identifier:dtype; 174, identifier:complex; 175, for_statement; 175, 176; 175, 177; 175, 178; 176, identifier:iz; 177, identifier:layer_count; 178, block; 178, 179; 178, 191; 178, 203; 178, 213; 178, 227; 178, 267; 178, 349; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:e_zHa; 182, subscript; 182, 183; 182, 184; 182, 186; 182, 187; 182, 190; 183, identifier:e_zH; 184, slice; 184, 185; 185, colon; 186, None; 187, binary_operator:+; 187, 188; 187, 189; 188, identifier:iz; 189, identifier:pm; 190, None; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:Gama; 194, subscript; 194, 195; 194, 196; 194, 198; 194, 200; 194, 201; 195, identifier:Gam; 196, slice; 196, 197; 197, colon; 198, slice; 198, 199; 199, colon; 200, identifier:iz; 201, slice; 201, 202; 202, colon; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:e_zHb; 206, subscript; 206, 207; 206, 208; 206, 210; 206, 211; 206, 212; 207, identifier:e_zH; 208, slice; 208, 209; 209, colon; 210, None; 211, identifier:iz; 212, None; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 216; 215, identifier:Gamb; 216, subscript; 216, 217; 216, 218; 216, 220; 216, 222; 216, 225; 217, identifier:Gam; 218, slice; 218, 219; 219, colon; 220, slice; 220, 221; 221, colon; 222, binary_operator:+; 222, 223; 222, 224; 223, identifier:iz; 224, identifier:pm; 225, slice; 225, 226; 226, colon; 227, if_statement; 227, 228; 227, 229; 227, 241; 228, identifier:use_ne_eval; 229, block; 229, 230; 229, 234; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:rlocstr; 233, string:"(e_zHa*Gama - e_zHb*Gamb)/(e_zHa*Gama + e_zHb*Gamb)"; 234, expression_statement; 234, 235; 235, assignment; 235, 236; 235, 237; 236, identifier:rloc; 237, call; 237, 238; 237, 239; 238, identifier:use_ne_eval; 239, argument_list; 239, 240; 240, identifier:rlocstr; 241, else_clause; 241, 242; 242, block; 242, 243; 242, 249; 242, 255; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:rloca; 246, binary_operator:*; 246, 247; 246, 248; 247, identifier:e_zHa; 248, identifier:Gama; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 252; 251, identifier:rlocb; 252, binary_operator:*; 252, 253; 252, 254; 253, identifier:e_zHb; 254, identifier:Gamb; 255, expression_statement; 255, 256; 256, assignment; 256, 257; 256, 258; 257, identifier:rloc; 258, binary_operator:/; 258, 259; 258, 263; 259, parenthesized_expression; 259, 260; 260, binary_operator:-; 260, 261; 260, 262; 261, identifier:rloca; 262, identifier:rlocb; 263, parenthesized_expression; 263, 264; 264, binary_operator:+; 264, 265; 264, 266; 265, identifier:rloca; 266, identifier:rlocb; 267, if_statement; 267, 268; 267, 273; 267, 282; 268, comparison_operator:==; 268, 269; 268, 270; 269, identifier:iz; 270, subscript; 270, 271; 270, 272; 271, identifier:layer_count; 272, integer:0; 273, block; 273, 274; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:tRef; 277, call; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, identifier:rloc; 280, identifier:copy; 281, argument_list; 282, else_clause; 282, 283; 283, block; 283, 284; 283, 300; 284, expression_statement; 284, 285; 285, assignment; 285, 286; 285, 287; 286, identifier:ddepth; 287, binary_operator:-; 287, 288; 287, 295; 288, subscript; 288, 289; 288, 290; 289, identifier:depth; 290, binary_operator:+; 290, 291; 290, 294; 291, binary_operator:+; 291, 292; 291, 293; 292, identifier:iz; 293, integer:1; 294, identifier:pm; 295, subscript; 295, 296; 295, 297; 296, identifier:depth; 297, binary_operator:+; 297, 298; 297, 299; 298, identifier:iz; 299, identifier:pm; 300, if_statement; 300, 301; 300, 302; 300, 317; 301, identifier:use_ne_eval; 302, block; 302, 303; 302, 310; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 306; 305, identifier:term; 306, call; 306, 307; 306, 308; 307, identifier:use_ne_eval; 308, argument_list; 308, 309; 309, string:"tRef*exp(-2*Gamb*ddepth)"; 310, expression_statement; 310, 311; 311, assignment; 311, 312; 311, 313; 312, identifier:tRef; 313, call; 313, 314; 313, 315; 314, identifier:use_ne_eval; 315, argument_list; 315, 316; 316, string:"(rloc + term)/(1 + rloc*term)"; 317, else_clause; 317, 318; 318, block; 318, 319; 318, 335; 319, expression_statement; 319, 320; 320, assignment; 320, 321; 320, 322; 321, identifier:term; 322, binary_operator:*; 322, 323; 322, 324; 323, identifier:tRef; 324, call; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:np; 327, identifier:exp; 328, argument_list; 328, 329; 329, binary_operator:*; 329, 330; 329, 334; 330, binary_operator:*; 330, 331; 330, 333; 331, unary_operator:-; 331, 332; 332, integer:2; 333, identifier:Gamb; 334, identifier:ddepth; 335, expression_statement; 335, 336; 336, assignment; 336, 337; 336, 338; 337, identifier:tRef; 338, binary_operator:/; 338, 339; 338, 343; 339, parenthesized_expression; 339, 340; 340, binary_operator:+; 340, 341; 340, 342; 341, identifier:rloc; 342, identifier:term; 343, parenthesized_expression; 343, 344; 344, binary_operator:+; 344, 345; 344, 346; 345, integer:1; 346, binary_operator:*; 346, 347; 346, 348; 347, identifier:rloc; 348, identifier:term; 349, if_statement; 349, 350; 349, 359; 350, boolean_operator:and; 350, 351; 350, 354; 351, comparison_operator:!=; 351, 352; 351, 353; 352, identifier:lrec; 353, identifier:lsrc; 354, comparison_operator:<=; 354, 355; 354, 358; 355, binary_operator:*; 355, 356; 355, 357; 356, identifier:pm; 357, identifier:iz; 358, identifier:minmax; 359, block; 359, 360; 359, 375; 360, expression_statement; 360, 361; 361, assignment; 361, 362; 361, 371; 362, subscript; 362, 363; 362, 364; 362, 366; 362, 368; 362, 369; 363, identifier:Ref; 364, slice; 364, 365; 365, colon; 366, slice; 366, 367; 367, colon; 368, identifier:izout; 369, slice; 369, 370; 370, colon; 371, subscript; 371, 372; 371, 373; 372, identifier:tRef; 373, slice; 373, 374; 374, colon; 375, expression_statement; 375, 376; 376, augmented_assignment:-=; 376, 377; 376, 378; 377, identifier:izout; 378, identifier:pm; 379, if_statement; 379, 380; 379, 389; 380, boolean_operator:and; 380, 381; 380, 384; 381, comparison_operator:==; 381, 382; 381, 383; 382, identifier:lsrc; 383, identifier:lrec; 384, comparison_operator:>; 384, 385; 384, 388; 385, attribute; 385, 386; 385, 387; 386, identifier:layer_count; 387, identifier:size; 388, integer:0; 389, block; 389, 390; 390, expression_statement; 390, 391; 391, assignment; 391, 392; 391, 393; 392, identifier:Ref; 393, identifier:tRef; 394, if_statement; 394, 395; 394, 396; 394, 401; 395, identifier:plus; 396, block; 396, 397; 397, expression_statement; 397, 398; 398, assignment; 398, 399; 398, 400; 399, identifier:Rm; 400, identifier:Ref; 401, else_clause; 401, 402; 402, block; 402, 403; 403, expression_statement; 403, 404; 404, assignment; 404, 405; 404, 406; 405, identifier:Rp; 406, identifier:Ref; 407, return_statement; 407, 408; 408, expression_list; 408, 409; 408, 410; 409, identifier:Rm; 410, identifier:Rp | def reflections(depth, e_zH, Gam, lrec, lsrc, use_ne_eval):
r
for plus in [True, False]:
if plus:
pm = 1
layer_count = np.arange(depth.size-2, min(lrec, lsrc)-1, -1)
izout = abs(lsrc-lrec)
minmax = max(lrec, lsrc)
else:
pm = -1
layer_count = np.arange(1, max(lrec, lsrc)+1, 1)
izout = 0
minmax = -min(lrec, lsrc)
shiftplus = lrec < lsrc and lrec == 0 and not plus
shiftminus = lrec > lsrc and lrec == depth.size-1 and plus
if shiftplus or shiftminus:
izout -= pm
Ref = np.zeros((Gam.shape[0], Gam.shape[1], abs(lsrc-lrec)+1,
Gam.shape[3]), dtype=complex)
for iz in layer_count:
e_zHa = e_zH[:, None, iz+pm, None]
Gama = Gam[:, :, iz, :]
e_zHb = e_zH[:, None, iz, None]
Gamb = Gam[:, :, iz+pm, :]
if use_ne_eval:
rlocstr = "(e_zHa*Gama - e_zHb*Gamb)/(e_zHa*Gama + e_zHb*Gamb)"
rloc = use_ne_eval(rlocstr)
else:
rloca = e_zHa*Gama
rlocb = e_zHb*Gamb
rloc = (rloca - rlocb)/(rloca + rlocb)
if iz == layer_count[0]:
tRef = rloc.copy()
else:
ddepth = depth[iz+1+pm]-depth[iz+pm]
if use_ne_eval:
term = use_ne_eval("tRef*exp(-2*Gamb*ddepth)")
tRef = use_ne_eval("(rloc + term)/(1 + rloc*term)")
else:
term = tRef*np.exp(-2*Gamb*ddepth)
tRef = (rloc + term)/(1 + rloc*term)
if lrec != lsrc and pm*iz <= minmax:
Ref[:, :, izout, :] = tRef[:]
izout -= pm
if lsrc == lrec and layer_count.size > 0:
Ref = tRef
if plus:
Rm = Ref
else:
Rp = Ref
return Rm, Rp |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:hquad; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 18; 3, 19; 3, 20; 4, identifier:zsrc; 5, identifier:zrec; 6, identifier:lsrc; 7, identifier:lrec; 8, identifier:off; 9, identifier:factAng; 10, identifier:depth; 11, identifier:ab; 12, identifier:etaH; 13, identifier:etaV; 14, identifier:zetaH; 15, identifier:zetaV; 16, identifier:xdirect; 17, identifier:quadargs; 18, identifier:use_ne_eval; 19, identifier:msrc; 20, identifier:mrec; 21, block; 21, 22; 21, 24; 21, 34; 21, 43; 21, 52; 21, 70; 21, 101; 21, 146; 21, 191; 21, 236; 21, 250; 21, 254; 21, 273; 21, 310; 22, expression_statement; 22, 23; 23, identifier:r; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 33; 26, pattern_list; 26, 27; 26, 28; 26, 29; 26, 30; 26, 31; 26, 32; 27, identifier:rtol; 28, identifier:atol; 29, identifier:limit; 30, identifier:a; 31, identifier:b; 32, identifier:pts_per_dec; 33, identifier:quadargs; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:la; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:np; 40, identifier:log10; 41, argument_list; 41, 42; 42, identifier:a; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:lb; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:np; 49, identifier:log10; 50, argument_list; 50, 51; 51, identifier:b; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:ilambd; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:np; 58, identifier:logspace; 59, argument_list; 59, 60; 59, 61; 59, 62; 60, identifier:la; 61, identifier:lb; 62, binary_operator:+; 62, 63; 62, 69; 63, binary_operator:*; 63, 64; 63, 68; 64, parenthesized_expression; 64, 65; 65, binary_operator:-; 65, 66; 65, 67; 66, identifier:lb; 67, identifier:la; 68, identifier:pts_per_dec; 69, integer:1; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 76; 72, pattern_list; 72, 73; 72, 74; 72, 75; 73, identifier:PJ0; 74, identifier:PJ1; 75, identifier:PJ0b; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:kernel; 79, identifier:wavenumber; 80, argument_list; 80, 81; 80, 82; 80, 83; 80, 84; 80, 85; 80, 86; 80, 87; 80, 88; 80, 89; 80, 90; 80, 96; 80, 97; 80, 98; 80, 99; 80, 100; 81, identifier:zsrc; 82, identifier:zrec; 83, identifier:lsrc; 84, identifier:lrec; 85, identifier:depth; 86, identifier:etaH; 87, identifier:etaV; 88, identifier:zetaH; 89, identifier:zetaV; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:np; 93, identifier:atleast_2d; 94, argument_list; 94, 95; 95, identifier:ilambd; 96, identifier:ab; 97, identifier:xdirect; 98, identifier:msrc; 99, identifier:mrec; 100, identifier:use_ne_eval; 101, if_statement; 101, 102; 101, 105; 101, 136; 102, comparison_operator:is; 102, 103; 102, 104; 103, identifier:PJ0; 104, None; 105, block; 105, 106; 105, 121; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:sPJ0r; 109, call; 109, 110; 109, 111; 110, identifier:iuSpline; 111, argument_list; 111, 112; 111, 118; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:np; 115, identifier:log; 116, argument_list; 116, 117; 117, identifier:ilambd; 118, attribute; 118, 119; 118, 120; 119, identifier:PJ0; 120, identifier:real; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:sPJ0i; 124, call; 124, 125; 124, 126; 125, identifier:iuSpline; 126, argument_list; 126, 127; 126, 133; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:np; 130, identifier:log; 131, argument_list; 131, 132; 132, identifier:ilambd; 133, attribute; 133, 134; 133, 135; 134, identifier:PJ0; 135, identifier:imag; 136, else_clause; 136, 137; 137, block; 137, 138; 137, 142; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:sPJ0r; 141, None; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:sPJ0i; 145, None; 146, if_statement; 146, 147; 146, 150; 146, 181; 147, comparison_operator:is; 147, 148; 147, 149; 148, identifier:PJ1; 149, None; 150, block; 150, 151; 150, 166; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:sPJ1r; 154, call; 154, 155; 154, 156; 155, identifier:iuSpline; 156, argument_list; 156, 157; 156, 163; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:np; 160, identifier:log; 161, argument_list; 161, 162; 162, identifier:ilambd; 163, attribute; 163, 164; 163, 165; 164, identifier:PJ1; 165, identifier:real; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 169; 168, identifier:sPJ1i; 169, call; 169, 170; 169, 171; 170, identifier:iuSpline; 171, argument_list; 171, 172; 171, 178; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:np; 175, identifier:log; 176, argument_list; 176, 177; 177, identifier:ilambd; 178, attribute; 178, 179; 178, 180; 179, identifier:PJ1; 180, identifier:imag; 181, else_clause; 181, 182; 182, block; 182, 183; 182, 187; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 186; 185, identifier:sPJ1r; 186, None; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 190; 189, identifier:sPJ1i; 190, None; 191, if_statement; 191, 192; 191, 195; 191, 226; 192, comparison_operator:is; 192, 193; 192, 194; 193, identifier:PJ0b; 194, None; 195, block; 195, 196; 195, 211; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 199; 198, identifier:sPJ0br; 199, call; 199, 200; 199, 201; 200, identifier:iuSpline; 201, argument_list; 201, 202; 201, 208; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:np; 205, identifier:log; 206, argument_list; 206, 207; 207, identifier:ilambd; 208, attribute; 208, 209; 208, 210; 209, identifier:PJ0b; 210, identifier:real; 211, expression_statement; 211, 212; 212, assignment; 212, 213; 212, 214; 213, identifier:sPJ0bi; 214, call; 214, 215; 214, 216; 215, identifier:iuSpline; 216, argument_list; 216, 217; 216, 223; 217, call; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:np; 220, identifier:log; 221, argument_list; 221, 222; 222, identifier:ilambd; 223, attribute; 223, 224; 223, 225; 224, identifier:PJ0b; 225, identifier:imag; 226, else_clause; 226, 227; 227, block; 227, 228; 227, 232; 228, expression_statement; 228, 229; 229, assignment; 229, 230; 229, 231; 230, identifier:sPJ0br; 231, None; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:sPJ0bi; 235, None; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:fEM; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:np; 242, identifier:zeros; 243, argument_list; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:off; 246, identifier:size; 247, keyword_argument; 247, 248; 247, 249; 248, identifier:dtype; 249, identifier:complex; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:conv; 253, True; 254, expression_statement; 254, 255; 255, assignment; 255, 256; 255, 257; 256, identifier:iinp; 257, dictionary; 257, 258; 257, 261; 257, 264; 257, 267; 257, 270; 258, pair; 258, 259; 258, 260; 259, string:'a'; 260, identifier:a; 261, pair; 261, 262; 261, 263; 262, string:'b'; 263, identifier:b; 264, pair; 264, 265; 264, 266; 265, string:'epsabs'; 266, identifier:atol; 267, pair; 267, 268; 267, 269; 268, string:'epsrel'; 269, identifier:rtol; 270, pair; 270, 271; 270, 272; 271, string:'limit'; 272, identifier:limit; 273, for_statement; 273, 274; 273, 275; 273, 281; 274, identifier:i; 275, call; 275, 276; 275, 277; 276, identifier:range; 277, argument_list; 277, 278; 278, attribute; 278, 279; 278, 280; 279, identifier:off; 280, identifier:size; 281, block; 281, 282; 281, 306; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 289; 284, pattern_list; 284, 285; 284, 288; 285, subscript; 285, 286; 285, 287; 286, identifier:fEM; 287, identifier:i; 288, identifier:tc; 289, call; 289, 290; 289, 291; 290, identifier:quad; 291, argument_list; 291, 292; 291, 293; 291, 294; 291, 295; 291, 296; 291, 297; 291, 298; 291, 299; 291, 302; 291, 305; 292, identifier:sPJ0r; 293, identifier:sPJ0i; 294, identifier:sPJ1r; 295, identifier:sPJ1i; 296, identifier:sPJ0br; 297, identifier:sPJ0bi; 298, identifier:ab; 299, subscript; 299, 300; 299, 301; 300, identifier:off; 301, identifier:i; 302, subscript; 302, 303; 302, 304; 303, identifier:factAng; 304, identifier:i; 305, identifier:iinp; 306, expression_statement; 306, 307; 307, augmented_assignment:*=; 307, 308; 307, 309; 308, identifier:conv; 309, identifier:tc; 310, return_statement; 310, 311; 311, expression_list; 311, 312; 311, 313; 311, 314; 312, identifier:fEM; 313, integer:1; 314, identifier:conv | def hquad(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH,
zetaV, xdirect, quadargs, use_ne_eval, msrc, mrec):
r
rtol, atol, limit, a, b, pts_per_dec = quadargs
la = np.log10(a)
lb = np.log10(b)
ilambd = np.logspace(la, lb, (lb-la)*pts_per_dec + 1)
PJ0, PJ1, PJ0b = kernel.wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH,
etaV, zetaH, zetaV,
np.atleast_2d(ilambd), ab, xdirect,
msrc, mrec, use_ne_eval)
if PJ0 is not None:
sPJ0r = iuSpline(np.log(ilambd), PJ0.real)
sPJ0i = iuSpline(np.log(ilambd), PJ0.imag)
else:
sPJ0r = None
sPJ0i = None
if PJ1 is not None:
sPJ1r = iuSpline(np.log(ilambd), PJ1.real)
sPJ1i = iuSpline(np.log(ilambd), PJ1.imag)
else:
sPJ1r = None
sPJ1i = None
if PJ0b is not None:
sPJ0br = iuSpline(np.log(ilambd), PJ0b.real)
sPJ0bi = iuSpline(np.log(ilambd), PJ0b.imag)
else:
sPJ0br = None
sPJ0bi = None
fEM = np.zeros(off.size, dtype=complex)
conv = True
iinp = {'a': a, 'b': b, 'epsabs': atol, 'epsrel': rtol, 'limit': limit}
for i in range(off.size):
fEM[i], tc = quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab,
off[i], factAng[i], iinp)
conv *= tc
return fEM, 1, conv |
0, module; 0, 1; 0, 24; 0, 26; 0, 45; 0, 54; 0, 56; 0, 70; 0, 87; 0, 98; 0, 106; 0, 108; 0, 129; 0, 133; 0, 144; 0, 150; 0, 217; 0, 288; 0, 357; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:quad; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, identifier:sPJ0r; 5, identifier:sPJ0i; 6, identifier:sPJ1r; 7, identifier:sPJ1i; 8, identifier:sPJ0br; 9, identifier:sPJ0bi; 10, identifier:ab; 11, identifier:off; 12, identifier:factAng; 13, identifier:iinp; 14, block; 14, 15; 14, 17; 15, expression_statement; 15, 16; 16, identifier:r; 17, function_definition; 17, 18; 17, 19; 17, 23; 18, function_name:quad_PJ0; 19, parameters; 19, 20; 19, 21; 19, 22; 20, identifier:klambd; 21, identifier:sPJ0; 22, identifier:koff; 23, block:; 24, expression_statement; 24, 25; 25, identifier:r; 26, return_statement; 26, 27; 27, binary_operator:*; 27, 28; 27, 37; 28, call; 28, 29; 28, 30; 29, identifier:sPJ0; 30, argument_list; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:np; 34, identifier:log; 35, argument_list; 35, 36; 36, identifier:klambd; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:special; 40, identifier:j0; 41, argument_list; 41, 42; 42, binary_operator:*; 42, 43; 42, 44; 43, identifier:koff; 44, identifier:klambd; 45, function_definition; 45, 46; 45, 47; 45, 53; 46, function_name:quad_PJ1; 47, parameters; 47, 48; 47, 49; 47, 50; 47, 51; 47, 52; 48, identifier:klambd; 49, identifier:sPJ1; 50, identifier:ab; 51, identifier:koff; 52, identifier:kang; 53, block:; 54, expression_statement; 54, 55; 55, identifier:r; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:tP1; 59, binary_operator:*; 59, 60; 59, 61; 60, identifier:kang; 61, call; 61, 62; 61, 63; 62, identifier:sPJ1; 63, argument_list; 63, 64; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:np; 67, identifier:log; 68, argument_list; 68, 69; 69, identifier:klambd; 70, if_statement; 70, 71; 70, 82; 71, comparison_operator:in; 71, 72; 71, 73; 72, identifier:ab; 73, list:[11, 12, 21, 22, 14, 24, 15, 25]; 73, 74; 73, 75; 73, 76; 73, 77; 73, 78; 73, 79; 73, 80; 73, 81; 74, integer:11; 75, integer:12; 76, integer:21; 77, integer:22; 78, integer:14; 79, integer:24; 80, integer:15; 81, integer:25; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, augmented_assignment:/=; 84, 85; 84, 86; 85, identifier:tP1; 86, identifier:koff; 87, return_statement; 87, 88; 88, binary_operator:*; 88, 89; 88, 90; 89, identifier:tP1; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:special; 93, identifier:j1; 94, argument_list; 94, 95; 95, binary_operator:*; 95, 96; 95, 97; 96, identifier:koff; 97, identifier:klambd; 98, function_definition; 98, 99; 98, 100; 98, 105; 99, function_name:quad_PJ0b; 100, parameters; 100, 101; 100, 102; 100, 103; 100, 104; 101, identifier:klambd; 102, identifier:sPJ0b; 103, identifier:koff; 104, identifier:kang; 105, block:; 106, expression_statement; 106, 107; 107, identifier:r; 108, return_statement; 108, 109; 109, binary_operator:*; 109, 110; 109, 121; 110, binary_operator:*; 110, 111; 110, 112; 111, identifier:kang; 112, call; 112, 113; 112, 114; 113, identifier:sPJ0b; 114, argument_list; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:np; 118, identifier:log; 119, argument_list; 119, 120; 120, identifier:klambd; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:special; 124, identifier:j0; 125, argument_list; 125, 126; 126, binary_operator:*; 126, 127; 126, 128; 127, identifier:koff; 128, identifier:klambd; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:conv; 132, True; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:out; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:np; 139, identifier:array; 140, argument_list; 140, 141; 141, binary_operator:+; 141, 142; 141, 143; 142, float:0.0; 143, float:0.0j; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 149; 146, subscript; 146, 147; 146, 148; 147, identifier:iinp; 148, string:'full_output'; 149, integer:1; 150, if_statement; 150, 151; 150, 154; 151, comparison_operator:is; 151, 152; 151, 153; 152, identifier:sPJ0r; 153, None; 154, block; 154, 155; 154, 171; 154, 187; 154, 199; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:re; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:integrate; 161, identifier:quad; 162, argument_list; 162, 163; 162, 164; 162, 169; 163, identifier:quad_PJ0; 164, keyword_argument; 164, 165; 164, 166; 165, identifier:args; 166, tuple; 166, 167; 166, 168; 167, identifier:sPJ0r; 168, identifier:off; 169, dictionary_splat; 169, 170; 170, identifier:iinp; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:im; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:integrate; 177, identifier:quad; 178, argument_list; 178, 179; 178, 180; 178, 185; 179, identifier:quad_PJ0; 180, keyword_argument; 180, 181; 180, 182; 181, identifier:args; 182, tuple; 182, 183; 182, 184; 183, identifier:sPJ0i; 184, identifier:off; 185, dictionary_splat; 185, 186; 186, identifier:iinp; 187, expression_statement; 187, 188; 188, augmented_assignment:+=; 188, 189; 188, 190; 189, identifier:out; 190, binary_operator:+; 190, 191; 190, 194; 191, subscript; 191, 192; 191, 193; 192, identifier:re; 193, integer:0; 194, binary_operator:*; 194, 195; 194, 196; 195, integer:1j; 196, subscript; 196, 197; 196, 198; 197, identifier:im; 198, integer:0; 199, if_statement; 199, 200; 199, 212; 200, comparison_operator:>; 200, 201; 200, 211; 201, parenthesized_expression; 201, 202; 202, boolean_operator:or; 202, 203; 202, 207; 203, call; 203, 204; 203, 205; 204, identifier:len; 205, argument_list; 205, 206; 206, identifier:re; 207, call; 207, 208; 207, 209; 208, identifier:len; 209, argument_list; 209, 210; 210, identifier:im; 211, integer:3; 212, block; 212, 213; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 216; 215, identifier:conv; 216, False; 217, if_statement; 217, 218; 217, 221; 218, comparison_operator:is; 218, 219; 218, 220; 219, identifier:sPJ1r; 220, None; 221, block; 221, 222; 221, 240; 221, 258; 221, 270; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:re; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:integrate; 228, identifier:quad; 229, argument_list; 229, 230; 229, 231; 229, 238; 230, identifier:quad_PJ1; 231, keyword_argument; 231, 232; 231, 233; 232, identifier:args; 233, tuple; 233, 234; 233, 235; 233, 236; 233, 237; 234, identifier:sPJ1r; 235, identifier:ab; 236, identifier:off; 237, identifier:factAng; 238, dictionary_splat; 238, 239; 239, identifier:iinp; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 243; 242, identifier:im; 243, call; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:integrate; 246, identifier:quad; 247, argument_list; 247, 248; 247, 249; 247, 256; 248, identifier:quad_PJ1; 249, keyword_argument; 249, 250; 249, 251; 250, identifier:args; 251, tuple; 251, 252; 251, 253; 251, 254; 251, 255; 252, identifier:sPJ1i; 253, identifier:ab; 254, identifier:off; 255, identifier:factAng; 256, dictionary_splat; 256, 257; 257, identifier:iinp; 258, expression_statement; 258, 259; 259, augmented_assignment:+=; 259, 260; 259, 261; 260, identifier:out; 261, binary_operator:+; 261, 262; 261, 265; 262, subscript; 262, 263; 262, 264; 263, identifier:re; 264, integer:0; 265, binary_operator:*; 265, 266; 265, 267; 266, integer:1j; 267, subscript; 267, 268; 267, 269; 268, identifier:im; 269, integer:0; 270, if_statement; 270, 271; 270, 283; 271, comparison_operator:>; 271, 272; 271, 282; 272, parenthesized_expression; 272, 273; 273, boolean_operator:or; 273, 274; 273, 278; 274, call; 274, 275; 274, 276; 275, identifier:len; 276, argument_list; 276, 277; 277, identifier:re; 278, call; 278, 279; 278, 280; 279, identifier:len; 280, argument_list; 280, 281; 281, identifier:im; 282, integer:3; 283, block; 283, 284; 284, expression_statement; 284, 285; 285, assignment; 285, 286; 285, 287; 286, identifier:conv; 287, False; 288, if_statement; 288, 289; 288, 292; 289, comparison_operator:is; 289, 290; 289, 291; 290, identifier:sPJ0br; 291, None; 292, block; 292, 293; 292, 310; 292, 327; 292, 339; 293, expression_statement; 293, 294; 294, assignment; 294, 295; 294, 296; 295, identifier:re; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:integrate; 299, identifier:quad; 300, argument_list; 300, 301; 300, 302; 300, 308; 301, identifier:quad_PJ0b; 302, keyword_argument; 302, 303; 302, 304; 303, identifier:args; 304, tuple; 304, 305; 304, 306; 304, 307; 305, identifier:sPJ0br; 306, identifier:off; 307, identifier:factAng; 308, dictionary_splat; 308, 309; 309, identifier:iinp; 310, expression_statement; 310, 311; 311, assignment; 311, 312; 311, 313; 312, identifier:im; 313, call; 313, 314; 313, 317; 314, attribute; 314, 315; 314, 316; 315, identifier:integrate; 316, identifier:quad; 317, argument_list; 317, 318; 317, 319; 317, 325; 318, identifier:quad_PJ0b; 319, keyword_argument; 319, 320; 319, 321; 320, identifier:args; 321, tuple; 321, 322; 321, 323; 321, 324; 322, identifier:sPJ0bi; 323, identifier:off; 324, identifier:factAng; 325, dictionary_splat; 325, 326; 326, identifier:iinp; 327, expression_statement; 327, 328; 328, augmented_assignment:+=; 328, 329; 328, 330; 329, identifier:out; 330, binary_operator:+; 330, 331; 330, 334; 331, subscript; 331, 332; 331, 333; 332, identifier:re; 333, integer:0; 334, binary_operator:*; 334, 335; 334, 336; 335, integer:1j; 336, subscript; 336, 337; 336, 338; 337, identifier:im; 338, integer:0; 339, if_statement; 339, 340; 339, 352; 340, comparison_operator:>; 340, 341; 340, 351; 341, parenthesized_expression; 341, 342; 342, boolean_operator:or; 342, 343; 342, 347; 343, call; 343, 344; 343, 345; 344, identifier:len; 345, argument_list; 345, 346; 346, identifier:re; 347, call; 347, 348; 347, 349; 348, identifier:len; 349, argument_list; 349, 350; 350, identifier:im; 351, integer:3; 352, block; 352, 353; 353, expression_statement; 353, 354; 354, assignment; 354, 355; 354, 356; 355, identifier:conv; 356, False; 357, return_statement; 357, 358; 358, expression_list; 358, 359; 358, 360; 359, identifier:out; 360, identifier:conv | def quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab, off, factAng, iinp):
r
def quad_PJ0(klambd, sPJ0, koff):
r
return sPJ0(np.log(klambd))*special.j0(koff*klambd)
def quad_PJ1(klambd, sPJ1, ab, koff, kang):
r
tP1 = kang*sPJ1(np.log(klambd))
if ab in [11, 12, 21, 22, 14, 24, 15, 25]:
tP1 /= koff
return tP1*special.j1(koff*klambd)
def quad_PJ0b(klambd, sPJ0b, koff, kang):
r
return kang*sPJ0b(np.log(klambd))*special.j0(koff*klambd)
conv = True
out = np.array(0.0+0.0j)
iinp['full_output'] = 1
if sPJ0r is not None:
re = integrate.quad(quad_PJ0, args=(sPJ0r, off), **iinp)
im = integrate.quad(quad_PJ0, args=(sPJ0i, off), **iinp)
out += re[0] + 1j*im[0]
if (len(re) or len(im)) > 3:
conv = False
if sPJ1r is not None:
re = integrate.quad(quad_PJ1, args=(sPJ1r, ab, off, factAng), **iinp)
im = integrate.quad(quad_PJ1, args=(sPJ1i, ab, off, factAng), **iinp)
out += re[0] + 1j*im[0]
if (len(re) or len(im)) > 3:
conv = False
if sPJ0br is not None:
re = integrate.quad(quad_PJ0b, args=(sPJ0br, off, factAng), **iinp)
im = integrate.quad(quad_PJ0b, args=(sPJ0bi, off, factAng), **iinp)
out += re[0] + 1j*im[0]
if (len(re) or len(im)) > 3:
conv = False
return out, conv |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:is_participle_clause_fragment; 3, parameters; 3, 4; 4, identifier:sentence; 5, block; 5, 6; 5, 19; 5, 53; 5, 113; 5, 138; 6, if_statement; 6, 7; 6, 16; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:_begins_with_one_of; 10, argument_list; 10, 11; 10, 12; 11, identifier:sentence; 12, list:['VBG', 'VBN', 'JJ']; 12, 13; 12, 14; 12, 15; 13, string:'VBG'; 14, string:'VBN'; 15, string:'JJ'; 16, block; 16, 17; 17, return_statement; 17, 18; 18, float:0.0; 19, if_statement; 19, 20; 19, 26; 20, call; 20, 21; 20, 22; 21, identifier:_begins_with_one_of; 22, argument_list; 22, 23; 22, 24; 23, identifier:sentence; 24, list:['JJ']; 24, 25; 25, string:'JJ'; 26, block; 26, 27; 26, 34; 26, 44; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:doc; 30, call; 30, 31; 30, 32; 31, identifier:nlp; 32, argument_list; 32, 33; 33, identifier:sentence; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:fw; 37, subscript; 37, 38; 37, 43; 38, list_comprehension; 38, 39; 38, 40; 39, identifier:w; 40, for_in_clause; 40, 41; 40, 42; 41, identifier:w; 42, identifier:doc; 43, integer:0; 44, if_statement; 44, 45; 44, 50; 45, comparison_operator:==; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:fw; 48, identifier:dep_; 49, string:'amod'; 50, block; 50, 51; 51, return_statement; 51, 52; 52, float:0.0; 53, if_statement; 53, 54; 53, 60; 54, call; 54, 55; 54, 56; 55, identifier:_begins_with_one_of; 56, argument_list; 56, 57; 56, 58; 57, identifier:sentence; 58, list:['VBG']; 58, 59; 59, string:'VBG'; 60, block; 60, 61; 60, 68; 60, 78; 60, 90; 60, 100; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:doc; 64, call; 64, 65; 64, 66; 65, identifier:nlp; 66, argument_list; 66, 67; 67, identifier:sentence; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:fw; 71, subscript; 71, 72; 71, 77; 72, list_comprehension; 72, 73; 72, 74; 73, identifier:w; 74, for_in_clause; 74, 75; 74, 76; 75, identifier:w; 76, identifier:doc; 77, integer:0; 78, if_statement; 78, 79; 78, 87; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:fw; 83, identifier:dep_; 84, identifier:endswith; 85, argument_list; 85, 86; 86, string:'subj'; 87, block; 87, 88; 88, return_statement; 88, 89; 89, float:0.0; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:fc; 93, list_comprehension; 93, 94; 93, 95; 94, identifier:c; 95, for_in_clause; 95, 96; 95, 97; 96, identifier:c; 97, attribute; 97, 98; 97, 99; 98, identifier:doc; 99, identifier:noun_chunks; 100, if_statement; 100, 101; 100, 110; 101, comparison_operator:in; 101, 102; 101, 106; 102, call; 102, 103; 102, 104; 103, identifier:str; 104, argument_list; 104, 105; 105, identifier:fw; 106, call; 106, 107; 106, 108; 107, identifier:str; 108, argument_list; 108, 109; 109, identifier:fc; 110, block; 110, 111; 111, return_statement; 111, 112; 112, float:0.0; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:positive_prob; 116, subscript; 116, 117; 116, 137; 117, subscript; 117, 118; 117, 136; 118, call; 118, 119; 118, 124; 119, attribute; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:models; 122, string:'participle'; 123, identifier:predict; 124, argument_list; 124, 125; 125, list:[_text_to_vector(sentence,
trigram2idx['participle'], trigram_count['participle'])]; 125, 126; 126, call; 126, 127; 126, 128; 127, identifier:_text_to_vector; 128, argument_list; 128, 129; 128, 130; 128, 133; 129, identifier:sentence; 130, subscript; 130, 131; 130, 132; 131, identifier:trigram2idx; 132, string:'participle'; 133, subscript; 133, 134; 133, 135; 134, identifier:trigram_count; 135, string:'participle'; 136, integer:0; 137, integer:1; 138, return_statement; 138, 139; 139, call; 139, 140; 139, 141; 140, identifier:float; 141, argument_list; 141, 142; 142, identifier:positive_prob | def is_participle_clause_fragment(sentence):
if not _begins_with_one_of(sentence, ['VBG', 'VBN', 'JJ']):
return 0.0
if _begins_with_one_of(sentence, ['JJ']):
doc = nlp(sentence)
fw = [w for w in doc][0]
if fw.dep_ == 'amod':
return 0.0
if _begins_with_one_of(sentence, ['VBG']):
doc = nlp(sentence)
fw = [w for w in doc][0]
if fw.dep_.endswith('subj'):
return 0.0
fc = [c for c in doc.noun_chunks]
if str(fw) in str(fc):
return 0.0
positive_prob = models['participle'].predict([_text_to_vector(sentence,
trigram2idx['participle'], trigram_count['participle'])])[0][1]
return float(positive_prob) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check; 3, parameters; 3, 4; 4, identifier:sentence; 5, block; 5, 6; 5, 12; 5, 19; 5, 26; 5, 33; 5, 40; 5, 47; 5, 82; 5, 119; 5, 165; 5, 200; 5, 236; 5, 310; 5, 328; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, call; 9, 10; 9, 11; 10, identifier:Feedback; 11, argument_list; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:is_missing_verb; 15, call; 15, 16; 15, 17; 16, identifier:detect_missing_verb; 17, argument_list; 17, 18; 18, identifier:sentence; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:is_infinitive; 22, call; 22, 23; 22, 24; 23, identifier:detect_infinitive_phrase; 24, argument_list; 24, 25; 25, identifier:sentence; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:is_participle; 29, call; 29, 30; 29, 31; 30, identifier:is_participle_clause_fragment; 31, argument_list; 31, 32; 32, identifier:sentence; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:lang_tool_feedback; 36, call; 36, 37; 36, 38; 37, identifier:get_language_tool_feedback; 38, argument_list; 38, 39; 39, identifier:sentence; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:subject_and_verb_agree; 43, call; 43, 44; 43, 45; 44, identifier:get_subject_verb_agreement_feedback; 45, argument_list; 45, 46; 46, identifier:sentence; 47, if_statement; 47, 48; 47, 49; 48, identifier:is_missing_verb; 49, block; 49, 50; 49, 58; 49, 70; 49, 76; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 57; 52, subscript; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:result; 55, identifier:matches; 56, string:'missing_verb'; 57, True; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:result; 62, identifier:human_readable; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:MISSING_VERB_ADVICE; 66, identifier:replace; 67, argument_list; 67, 68; 67, 69; 68, string:'\n'; 69, string:''; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:result; 74, identifier:primary_error; 75, string:'MISSING_VERB_ERROR'; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:result; 80, identifier:specific_error; 81, string:'MISSING_VERB'; 82, if_statement; 82, 83; 82, 86; 83, comparison_operator:>; 83, 84; 83, 85; 84, identifier:is_participle; 85, float:.5; 86, block; 86, 87; 86, 95; 86, 107; 86, 113; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 94; 89, subscript; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:result; 92, identifier:matches; 93, string:'participle_phrase'; 94, identifier:is_participle; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:result; 99, identifier:human_readable; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:PARTICIPLE_FRAGMENT_ADVICE; 103, identifier:replace; 104, argument_list; 104, 105; 104, 106; 105, string:'\n'; 106, string:''; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:result; 111, identifier:primary_error; 112, string:'FRAGMENT_ERROR'; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:result; 117, identifier:specific_error; 118, string:'PARTICIPLE_PHRASE'; 119, if_statement; 119, 120; 119, 121; 120, identifier:lang_tool_feedback; 121, block; 121, 122; 121, 130; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 129; 124, subscript; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:result; 127, identifier:matches; 128, string:'lang_tool'; 129, identifier:lang_tool_feedback; 130, for_statement; 130, 131; 130, 132; 130, 133; 131, identifier:ltf; 132, identifier:lang_tool_feedback; 133, block; 133, 134; 134, if_statement; 134, 135; 134, 142; 135, comparison_operator:==; 135, 136; 135, 141; 136, subscript; 136, 137; 136, 140; 137, subscript; 137, 138; 137, 139; 138, identifier:ltf; 139, string:'rule'; 140, string:'id'; 141, string:'SENTENCE_FRAGMENT'; 142, block; 142, 143; 142, 153; 142, 159; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:result; 147, identifier:human_readable; 148, subscript; 148, 149; 148, 152; 149, subscript; 149, 150; 149, 151; 150, identifier:lang_tool_feedback; 151, integer:0; 152, string:'message'; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:result; 157, identifier:primary_error; 158, string:'FRAGMENT_ERROR'; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:result; 163, identifier:specific_error; 164, string:'SUBORDINATE_CLAUSE'; 165, if_statement; 165, 166; 165, 167; 166, identifier:is_infinitive; 167, block; 167, 168; 167, 176; 167, 188; 167, 194; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 175; 170, subscript; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:result; 173, identifier:matches; 174, string:'infinitive_phrase'; 175, True; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:result; 180, identifier:human_readable; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:INFINITIVE_PHRASE_ADVICE; 184, identifier:replace; 185, argument_list; 185, 186; 185, 187; 186, string:'\n'; 187, string:''; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:result; 192, identifier:primary_error; 193, string:'INFINITIVE_PHRASE_ERROR'; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:result; 198, identifier:specific_error; 199, string:'INFINITIVE_PHRASE'; 200, if_statement; 200, 201; 200, 203; 201, not_operator; 201, 202; 202, identifier:subject_and_verb_agree; 203, block; 203, 204; 203, 212; 203, 224; 203, 230; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 211; 206, subscript; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:result; 209, identifier:matches; 210, string:'subject_verb_agreement'; 211, identifier:subject_and_verb_agree; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:result; 216, identifier:human_readable; 217, call; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:SUBJECT_VERB_AGREEMENT_ADVICE; 220, identifier:replace; 221, argument_list; 221, 222; 221, 223; 222, string:'\n'; 223, string:''; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:result; 228, identifier:primary_error; 229, string:'SUBJECT_VERB_AGREEMENT_ERROR'; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:result; 234, identifier:specific_error; 235, string:'SUBJECT_VERB_AGREEMENT'; 236, if_statement; 236, 237; 236, 238; 237, identifier:lang_tool_feedback; 238, block; 238, 239; 238, 247; 238, 280; 239, expression_statement; 239, 240; 240, assignment; 240, 241; 240, 246; 241, subscript; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:result; 244, identifier:matches; 245, string:'lang_tool'; 246, identifier:lang_tool_feedback; 247, for_statement; 247, 248; 247, 249; 247, 250; 248, identifier:ltf; 249, identifier:lang_tool_feedback; 250, block; 250, 251; 251, if_statement; 251, 252; 251, 259; 252, comparison_operator:==; 252, 253; 252, 258; 253, subscript; 253, 254; 253, 257; 254, subscript; 254, 255; 254, 256; 255, identifier:ltf; 256, string:'rule'; 257, string:'id'; 258, string:'MORFOLOGIK_RULE_EN_US'; 259, block; 259, 260; 259, 268; 259, 274; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:result; 264, identifier:human_readable; 265, subscript; 265, 266; 265, 267; 266, identifier:ltf; 267, string:'message'; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:result; 272, identifier:primary_error; 273, string:'SPELLING_ERROR'; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:result; 278, identifier:specific_error; 279, string:'SPELLING_ERROR'; 280, if_statement; 280, 281; 280, 285; 281, not_operator; 281, 282; 282, attribute; 282, 283; 282, 284; 283, identifier:result; 284, identifier:primary_error; 285, block; 285, 286; 285, 294; 285, 300; 286, expression_statement; 286, 287; 287, assignment; 287, 288; 287, 291; 288, attribute; 288, 289; 288, 290; 289, identifier:result; 290, identifier:human_readable; 291, subscript; 291, 292; 291, 293; 292, identifier:ltf; 293, string:'message'; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:result; 298, identifier:primary_error; 299, string:'OTHER_ERROR'; 300, expression_statement; 300, 301; 301, assignment; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:result; 304, identifier:specific_error; 305, subscript; 305, 306; 305, 309; 306, subscript; 306, 307; 306, 308; 307, identifier:ltf; 308, string:'rule'; 309, string:'id'; 310, if_statement; 310, 311; 310, 315; 311, not_operator; 311, 312; 312, attribute; 312, 313; 312, 314; 313, identifier:result; 314, identifier:matches; 315, block; 315, 316; 316, expression_statement; 316, 317; 317, assignment; 317, 318; 317, 321; 318, attribute; 318, 319; 318, 320; 319, identifier:result; 320, identifier:human_readable; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:STRONG_SENTENCE_ADVICE; 324, identifier:replace; 325, argument_list; 325, 326; 325, 327; 326, string:'\n'; 327, string:''; 328, return_statement; 328, 329; 329, identifier:result | def check(sentence):
result = Feedback()
is_missing_verb = detect_missing_verb(sentence)
is_infinitive = detect_infinitive_phrase(sentence)
is_participle = is_participle_clause_fragment(sentence)
lang_tool_feedback = get_language_tool_feedback(sentence)
subject_and_verb_agree = get_subject_verb_agreement_feedback(sentence)
if is_missing_verb:
result.matches['missing_verb'] = True
result.human_readable = MISSING_VERB_ADVICE.replace('\n', '')
result.primary_error = 'MISSING_VERB_ERROR'
result.specific_error = 'MISSING_VERB'
if is_participle > .5:
result.matches['participle_phrase'] = is_participle
result.human_readable = PARTICIPLE_FRAGMENT_ADVICE.replace('\n', '')
result.primary_error = 'FRAGMENT_ERROR'
result.specific_error = 'PARTICIPLE_PHRASE'
if lang_tool_feedback:
result.matches['lang_tool'] = lang_tool_feedback
for ltf in lang_tool_feedback:
if ltf['rule']['id'] == 'SENTENCE_FRAGMENT':
result.human_readable = lang_tool_feedback[0]['message']
result.primary_error = 'FRAGMENT_ERROR'
result.specific_error = 'SUBORDINATE_CLAUSE'
if is_infinitive:
result.matches['infinitive_phrase'] = True
result.human_readable = INFINITIVE_PHRASE_ADVICE.replace('\n', '')
result.primary_error = 'INFINITIVE_PHRASE_ERROR'
result.specific_error = 'INFINITIVE_PHRASE'
if not subject_and_verb_agree:
result.matches['subject_verb_agreement'] = subject_and_verb_agree
result.human_readable = SUBJECT_VERB_AGREEMENT_ADVICE.replace('\n', '')
result.primary_error = 'SUBJECT_VERB_AGREEMENT_ERROR'
result.specific_error = 'SUBJECT_VERB_AGREEMENT'
if lang_tool_feedback:
result.matches['lang_tool'] = lang_tool_feedback
for ltf in lang_tool_feedback:
if ltf['rule']['id'] == 'MORFOLOGIK_RULE_EN_US':
result.human_readable = ltf['message']
result.primary_error = 'SPELLING_ERROR'
result.specific_error = 'SPELLING_ERROR'
if not result.primary_error:
result.human_readable = ltf['message']
result.primary_error = 'OTHER_ERROR'
result.specific_error = ltf['rule']['id']
if not result.matches:
result.human_readable = STRONG_SENTENCE_ADVICE.replace('\n', '')
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:execute; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 34; 5, 71; 5, 79; 5, 137; 5, 188; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:count; 11, integer:0; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:taskset; 17, list:[]; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:results; 23, dictionary; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:totaltime; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:time; 32, identifier:time; 33, argument_list; 34, for_statement; 34, 35; 34, 36; 34, 42; 35, identifier:task; 36, call; 36, 37; 36, 38; 37, identifier:list; 38, argument_list; 38, 39; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:taskseq; 42, block; 42, 43; 42, 52; 42, 65; 43, expression_statement; 43, 44; 44, call; 44, 45; 44, 50; 45, attribute; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:taskset; 49, identifier:append; 50, argument_list; 50, 51; 51, identifier:task; 52, expression_statement; 52, 53; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:task; 56, identifier:add_callback; 57, argument_list; 57, 58; 57, 59; 57, 62; 58, string:'resolved'; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:child_done; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:count; 65, expression_statement; 65, 66; 66, augmented_assignment:+=; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:count; 70, integer:1; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:numtasks; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:count; 79, with_statement; 79, 80; 79, 85; 80, with_clause; 80, 81; 81, with_item; 81, 82; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:regcond; 85, block; 85, 86; 85, 108; 85, 122; 86, for_statement; 86, 87; 86, 88; 86, 94; 87, identifier:task; 88, call; 88, 89; 88, 90; 89, identifier:list; 90, argument_list; 90, 91; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:taskset; 94, block; 94, 95; 94, 102; 95, expression_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:task; 99, identifier:initialize; 100, argument_list; 100, 101; 101, identifier:self; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:task; 106, identifier:start; 107, argument_list; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:self; 112, identifier:totaltime; 113, binary_operator:-; 113, 114; 113, 119; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:time; 117, identifier:time; 118, argument_list; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:totaltime; 122, while_statement; 122, 123; 122, 128; 123, comparison_operator:>; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:count; 127, integer:0; 128, block; 128, 129; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 136; 131, attribute; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:regcond; 135, identifier:wait; 136, argument_list; 137, for_statement; 137, 138; 137, 139; 137, 146; 138, identifier:key; 139, call; 139, 140; 139, 145; 140, attribute; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:results; 144, identifier:keys; 145, argument_list; 146, block; 146, 147; 146, 155; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:value; 150, subscript; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:self; 153, identifier:results; 154, identifier:key; 155, if_statement; 155, 156; 155, 161; 156, call; 156, 157; 156, 158; 157, identifier:isinstance; 158, argument_list; 158, 159; 158, 160; 159, identifier:value; 160, identifier:Exception; 161, block; 161, 162; 161, 168; 161, 186; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 167; 164, tuple_pattern; 164, 165; 164, 166; 165, identifier:count; 166, identifier:task; 167, identifier:key; 168, expression_statement; 168, 169; 169, call; 169, 170; 169, 175; 170, attribute; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:self; 173, identifier:logger; 174, identifier:error; 175, argument_list; 175, 176; 176, binary_operator:%; 176, 177; 176, 178; 177, string:"Child task %s terminated with exception: %s"; 178, tuple; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:task; 181, identifier:tag; 182, call; 182, 183; 182, 184; 183, identifier:str; 184, argument_list; 184, 185; 185, identifier:value; 186, raise_statement; 186, 187; 187, identifier:value; 188, return_statement; 188, 189; 189, integer:0 | def execute(self):
self.count = 0
self.taskset = []
self.results = {}
self.totaltime = time.time()
for task in list(self.taskseq):
self.taskset.append(task)
task.add_callback('resolved', self.child_done, self.count)
self.count += 1
self.numtasks = self.count
with self.regcond:
for task in list(self.taskset):
task.initialize(self)
task.start()
self.totaltime = time.time() - self.totaltime
while self.count > 0:
self.regcond.wait()
for key in self.results.keys():
value = self.results[key]
if isinstance(value, Exception):
(count, task) = key
self.logger.error("Child task %s terminated with exception: %s" % (
task.tag, str(value)))
raise value
return 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:startall; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wait; 7, False; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwdargs; 10, block; 10, 11; 10, 20; 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:debug; 18, argument_list; 18, 19; 19, string:"startall called"; 20, with_statement; 20, 21; 20, 26; 21, with_clause; 21, 22; 22, with_item; 22, 23; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:regcond; 26, block; 26, 27; 26, 82; 26, 92; 26, 98; 26, 104; 26, 110; 26, 123; 26, 132; 26, 182; 26, 230; 27, while_statement; 27, 28; 27, 33; 28, comparison_operator:!=; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:status; 32, string:'down'; 33, block; 33, 34; 33, 61; 33, 74; 34, if_statement; 34, 35; 34, 50; 35, boolean_operator:or; 35, 36; 35, 43; 36, comparison_operator:in; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:status; 40, tuple; 40, 41; 40, 42; 41, string:'start'; 42, string:'up'; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:ev_quit; 48, identifier:is_set; 49, argument_list; 50, block; 50, 51; 50, 60; 51, expression_statement; 51, 52; 52, call; 52, 53; 52, 58; 53, attribute; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:self; 56, identifier:logger; 57, identifier:error; 58, argument_list; 58, 59; 59, string:"ignoring duplicate request to start thread pool"; 60, return_statement; 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:logger; 67, identifier:debug; 68, argument_list; 68, 69; 69, binary_operator:%; 69, 70; 69, 71; 70, string:"waiting for threads: count=%d"; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:runningcount; 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:regcond; 80, identifier:wait; 81, argument_list; 82, if_statement; 82, 83; 82, 90; 83, call; 83, 84; 83, 89; 84, attribute; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:ev_quit; 88, identifier:is_set; 89, argument_list; 90, block; 90, 91; 91, return_statement; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:runningcount; 97, integer:0; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:status; 103, string:'start'; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:workers; 109, list:[]; 110, if_statement; 110, 111; 110, 112; 110, 117; 111, identifier:wait; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:tpool; 116, identifier:self; 117, else_clause; 117, 118; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:tpool; 122, None; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 130; 125, attribute; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:logger; 129, identifier:debug; 130, argument_list; 130, 131; 131, string:"starting threads in thread pool"; 132, for_statement; 132, 133; 132, 134; 132, 140; 133, identifier:i; 134, call; 134, 135; 134, 136; 135, identifier:range; 136, argument_list; 136, 137; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:numthreads; 140, block; 140, 141; 140, 167; 140, 176; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:t; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:workerClass; 148, argument_list; 148, 149; 148, 152; 148, 157; 148, 162; 148, 165; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:queue; 152, keyword_argument; 152, 153; 152, 154; 153, identifier:logger; 154, attribute; 154, 155; 154, 156; 155, identifier:self; 156, identifier:logger; 157, keyword_argument; 157, 158; 157, 159; 158, identifier:ev_quit; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:ev_quit; 162, keyword_argument; 162, 163; 162, 164; 163, identifier:tpool; 164, identifier:tpool; 165, dictionary_splat; 165, 166; 166, identifier:kwdargs; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 174; 169, attribute; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:self; 172, identifier:workers; 173, identifier:append; 174, argument_list; 174, 175; 175, identifier:t; 176, expression_statement; 176, 177; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:t; 180, identifier:start; 181, argument_list; 182, if_statement; 182, 183; 182, 184; 182, 222; 183, identifier:wait; 184, block; 184, 185; 185, while_statement; 185, 186; 185, 200; 186, boolean_operator:and; 186, 187; 186, 192; 187, comparison_operator:!=; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:self; 190, identifier:status; 191, string:'up'; 192, not_operator; 192, 193; 193, call; 193, 194; 193, 199; 194, attribute; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:self; 197, identifier:ev_quit; 198, identifier:is_set; 199, argument_list; 200, block; 200, 201; 200, 214; 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:debug; 208, argument_list; 208, 209; 209, binary_operator:%; 209, 210; 209, 211; 210, string:"waiting for threads: count=%d"; 211, attribute; 211, 212; 211, 213; 212, identifier:self; 213, identifier:runningcount; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 221; 216, attribute; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:self; 219, identifier:regcond; 220, identifier:wait; 221, argument_list; 222, else_clause; 222, 223; 223, block; 223, 224; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:self; 228, identifier:status; 229, string:'up'; 230, expression_statement; 230, 231; 231, call; 231, 232; 231, 237; 232, attribute; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:self; 235, identifier:logger; 236, identifier:debug; 237, argument_list; 237, 238; 238, string:"startall done" | def startall(self, wait=False, **kwdargs):
self.logger.debug("startall called")
with self.regcond:
while self.status != 'down':
if self.status in ('start', 'up') or self.ev_quit.is_set():
self.logger.error("ignoring duplicate request to start thread pool")
return
self.logger.debug("waiting for threads: count=%d" %
self.runningcount)
self.regcond.wait()
if self.ev_quit.is_set():
return
self.runningcount = 0
self.status = 'start'
self.workers = []
if wait:
tpool = self
else:
tpool = None
self.logger.debug("starting threads in thread pool")
for i in range(self.numthreads):
t = self.workerClass(self.queue, logger=self.logger,
ev_quit=self.ev_quit, tpool=tpool,
**kwdargs)
self.workers.append(t)
t.start()
if wait:
while self.status != 'up' and not self.ev_quit.is_set():
self.logger.debug("waiting for threads: count=%d" %
self.runningcount)
self.regcond.wait()
else:
self.status = 'up'
self.logger.debug("startall done") |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:handle; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 22; 5, 30; 5, 38; 5, 47; 5, 58; 5, 65; 5, 71; 5, 491; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:logger; 11, attribute; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:server; 15, identifier:logger; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:packet; 19, call; 19, 20; 19, 21; 20, identifier:iis; 21, argument_list; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:packet; 26, identifier:datain; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:rfile; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:packet; 34, identifier:dataout; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:wfile; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:size; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:struct; 44, identifier:calcsize; 45, argument_list; 45, 46; 46, string:'8h'; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:line; 50, call; 50, 51; 50, 56; 51, attribute; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:packet; 54, identifier:datain; 55, identifier:read; 56, argument_list; 56, 57; 57, identifier:size; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:n; 61, call; 61, 62; 61, 63; 62, identifier:len; 63, argument_list; 63, 64; 64, identifier:line; 65, if_statement; 65, 66; 65, 69; 66, comparison_operator:<; 66, 67; 66, 68; 67, identifier:n; 68, identifier:size; 69, block; 69, 70; 70, return_statement; 71, while_statement; 71, 72; 71, 75; 72, comparison_operator:>; 72, 73; 72, 74; 73, identifier:n; 74, integer:0; 75, block; 75, 76; 75, 113; 75, 119; 75, 125; 75, 131; 75, 139; 75, 147; 75, 155; 75, 163; 75, 170; 75, 182; 75, 188; 75, 194; 75, 200; 75, 206; 75, 212; 75, 218; 75, 224; 75, 230; 75, 243; 75, 411; 75, 467; 75, 478; 75, 485; 76, try_statement; 76, 77; 76, 88; 77, block; 77, 78; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:bytes; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:struct; 84, identifier:unpack; 85, argument_list; 85, 86; 85, 87; 86, string:'8h'; 87, identifier:line; 88, except_clause; 88, 89; 88, 90; 89, identifier:Exception; 90, block; 90, 91; 90, 100; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 98; 93, attribute; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:logger; 97, identifier:error; 98, argument_list; 98, 99; 99, string:'error unpacking the data.'; 100, for_statement; 100, 101; 100, 102; 100, 107; 101, identifier:exctn; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:sys; 105, identifier:exc_info; 106, argument_list; 107, block; 107, 108; 108, expression_statement; 108, 109; 109, call; 109, 110; 109, 111; 110, identifier:print; 111, argument_list; 111, 112; 112, identifier:exctn; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:subunit; 116, subscript; 116, 117; 116, 118; 117, identifier:bytes; 118, integer:2; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:subunit077; 122, binary_operator:&; 122, 123; 122, 124; 123, identifier:subunit; 124, integer:0o77; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 128; 127, identifier:tid; 128, subscript; 128, 129; 128, 130; 129, identifier:bytes; 130, integer:0; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:x; 134, binary_operator:&; 134, 135; 134, 138; 135, subscript; 135, 136; 135, 137; 136, identifier:bytes; 137, integer:4; 138, integer:0o177777; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:y; 142, binary_operator:&; 142, 143; 142, 146; 143, subscript; 143, 144; 143, 145; 144, identifier:bytes; 145, integer:5; 146, integer:0o177777; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:z; 150, binary_operator:&; 150, 151; 150, 154; 151, subscript; 151, 152; 151, 153; 152, identifier:bytes; 153, integer:6; 154, integer:0o177777; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:t; 158, binary_operator:&; 158, 159; 158, 162; 159, subscript; 159, 160; 159, 161; 160, identifier:bytes; 161, integer:7; 162, integer:0o17777; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:ndatabytes; 166, unary_operator:-; 166, 167; 167, subscript; 167, 168; 167, 169; 168, identifier:bytes; 169, integer:1; 170, if_statement; 170, 171; 170, 177; 171, parenthesized_expression; 171, 172; 172, not_operator; 172, 173; 173, parenthesized_expression; 173, 174; 174, binary_operator:&; 174, 175; 174, 176; 175, identifier:tid; 176, identifier:PACKED; 177, block; 177, 178; 178, expression_statement; 178, 179; 179, augmented_assignment:*=; 179, 180; 179, 181; 180, identifier:ndatabytes; 181, integer:2; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:packet; 186, identifier:subunit; 187, identifier:subunit; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:packet; 192, identifier:subunit077; 193, identifier:subunit077; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:packet; 198, identifier:tid; 199, identifier:tid; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:packet; 204, identifier:x; 205, identifier:x; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:packet; 210, identifier:y; 211, identifier:y; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:packet; 216, identifier:z; 217, identifier:z; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:packet; 222, identifier:t; 223, identifier:t; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:packet; 228, identifier:nbytes; 229, identifier:ndatabytes; 230, expression_statement; 230, 231; 231, call; 231, 232; 231, 237; 232, attribute; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:self; 235, identifier:logger; 236, identifier:debug; 237, argument_list; 237, 238; 238, binary_operator:%; 238, 239; 238, 240; 239, string:"PACKET IS %o"; 240, attribute; 240, 241; 240, 242; 241, identifier:packet; 242, identifier:subunit; 243, if_statement; 243, 244; 243, 249; 243, 257; 243, 290; 243, 329; 243, 362; 243, 395; 244, comparison_operator:==; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:packet; 247, identifier:subunit077; 248, identifier:FEEDBACK; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:self; 254, identifier:handle_feedback; 255, argument_list; 255, 256; 256, identifier:packet; 257, elif_clause; 257, 258; 257, 263; 258, comparison_operator:==; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:packet; 261, identifier:subunit077; 262, identifier:LUT; 263, block; 263, 264; 263, 271; 263, 282; 263, 289; 264, expression_statement; 264, 265; 265, call; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:self; 268, identifier:handle_lut; 269, argument_list; 269, 270; 270, identifier:packet; 271, expression_statement; 271, 272; 272, assignment; 272, 273; 272, 274; 273, identifier:line; 274, call; 274, 275; 274, 280; 275, attribute; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:packet; 278, identifier:datain; 279, identifier:read; 280, argument_list; 280, 281; 281, identifier:size; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:n; 285, call; 285, 286; 285, 287; 286, identifier:len; 287, argument_list; 287, 288; 288, identifier:line; 289, continue_statement; 290, elif_clause; 290, 291; 290, 296; 291, comparison_operator:==; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:packet; 294, identifier:subunit077; 295, identifier:MEMORY; 296, block; 296, 297; 296, 304; 296, 310; 296, 321; 296, 328; 297, expression_statement; 297, 298; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:self; 301, identifier:handle_memory; 302, argument_list; 302, 303; 303, identifier:packet; 304, if_statement; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:self; 307, identifier:needs_update; 308, block; 308, 309; 309, pass_statement; 310, expression_statement; 310, 311; 311, assignment; 311, 312; 311, 313; 312, identifier:line; 313, call; 313, 314; 313, 319; 314, attribute; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:packet; 317, identifier:datain; 318, identifier:read; 319, argument_list; 319, 320; 320, identifier:size; 321, expression_statement; 321, 322; 322, assignment; 322, 323; 322, 324; 323, identifier:n; 324, call; 324, 325; 324, 326; 325, identifier:len; 326, argument_list; 326, 327; 327, identifier:line; 328, continue_statement; 329, elif_clause; 329, 330; 329, 335; 330, comparison_operator:==; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:packet; 333, identifier:subunit077; 334, identifier:WCS; 335, block; 335, 336; 335, 343; 335, 354; 335, 361; 336, expression_statement; 336, 337; 337, call; 337, 338; 337, 341; 338, attribute; 338, 339; 338, 340; 339, identifier:self; 340, identifier:handle_wcs; 341, argument_list; 341, 342; 342, identifier:packet; 343, expression_statement; 343, 344; 344, assignment; 344, 345; 344, 346; 345, identifier:line; 346, call; 346, 347; 346, 352; 347, attribute; 347, 348; 347, 351; 348, attribute; 348, 349; 348, 350; 349, identifier:packet; 350, identifier:datain; 351, identifier:read; 352, argument_list; 352, 353; 353, identifier:size; 354, expression_statement; 354, 355; 355, assignment; 355, 356; 355, 357; 356, identifier:n; 357, call; 357, 358; 357, 359; 358, identifier:len; 359, argument_list; 359, 360; 360, identifier:line; 361, continue_statement; 362, elif_clause; 362, 363; 362, 368; 363, comparison_operator:==; 363, 364; 363, 367; 364, attribute; 364, 365; 364, 366; 365, identifier:packet; 366, identifier:subunit077; 367, identifier:IMCURSOR; 368, block; 368, 369; 368, 376; 368, 387; 368, 394; 369, expression_statement; 369, 370; 370, call; 370, 371; 370, 374; 371, attribute; 371, 372; 371, 373; 372, identifier:self; 373, identifier:handle_imcursor; 374, argument_list; 374, 375; 375, identifier:packet; 376, expression_statement; 376, 377; 377, assignment; 377, 378; 377, 379; 378, identifier:line; 379, call; 379, 380; 379, 385; 380, attribute; 380, 381; 380, 384; 381, attribute; 381, 382; 381, 383; 382, identifier:packet; 383, identifier:datain; 384, identifier:read; 385, argument_list; 385, 386; 386, identifier:size; 387, expression_statement; 387, 388; 388, assignment; 388, 389; 388, 390; 389, identifier:n; 390, call; 390, 391; 390, 392; 391, identifier:len; 392, argument_list; 392, 393; 393, identifier:line; 394, continue_statement; 395, else_clause; 395, 396; 396, block; 396, 397; 397, expression_statement; 397, 398; 398, call; 398, 399; 398, 404; 399, attribute; 399, 400; 399, 403; 400, attribute; 400, 401; 400, 402; 401, identifier:self; 402, identifier:logger; 403, identifier:debug; 404, argument_list; 404, 405; 405, binary_operator:%; 405, 406; 405, 407; 406, string:'?NO OP (0%o)'; 407, parenthesized_expression; 407, 408; 408, attribute; 408, 409; 408, 410; 409, identifier:packet; 410, identifier:subunit077; 411, if_statement; 411, 412; 411, 419; 412, not_operator; 412, 413; 413, parenthesized_expression; 413, 414; 414, binary_operator:&; 414, 415; 414, 418; 415, attribute; 415, 416; 415, 417; 416, identifier:packet; 417, identifier:tid; 418, identifier:IIS_READ; 419, block; 419, 420; 419, 426; 420, expression_statement; 420, 421; 421, assignment; 421, 422; 421, 423; 422, identifier:nbytes; 423, attribute; 423, 424; 423, 425; 424, identifier:packet; 425, identifier:nbytes; 426, while_statement; 426, 427; 426, 430; 427, comparison_operator:>; 427, 428; 427, 429; 428, identifier:nbytes; 429, integer:0; 430, block; 430, 431; 430, 446; 430, 457; 430, 463; 431, if_statement; 431, 432; 431, 435; 431, 440; 432, comparison_operator:<; 432, 433; 432, 434; 433, identifier:nbytes; 434, identifier:SZ_FIFOBUF; 435, block; 435, 436; 436, expression_statement; 436, 437; 437, assignment; 437, 438; 437, 439; 438, identifier:n; 439, identifier:nbytes; 440, else_clause; 440, 441; 441, block; 441, 442; 442, expression_statement; 442, 443; 443, assignment; 443, 444; 443, 445; 444, identifier:n; 445, identifier:SZ_FIFOBUF; 446, expression_statement; 446, 447; 447, assignment; 447, 448; 447, 449; 448, identifier:m; 449, call; 449, 450; 449, 455; 450, attribute; 450, 451; 450, 454; 451, attribute; 451, 452; 451, 453; 452, identifier:self; 453, identifier:rfile; 454, identifier:read; 455, argument_list; 455, 456; 456, identifier:n; 457, if_statement; 457, 458; 457, 461; 458, comparison_operator:<=; 458, 459; 458, 460; 459, identifier:m; 460, integer:0; 461, block; 461, 462; 462, break_statement; 463, expression_statement; 463, 464; 464, augmented_assignment:-=; 464, 465; 464, 466; 465, identifier:nbytes; 466, identifier:n; 467, expression_statement; 467, 468; 468, assignment; 468, 469; 468, 470; 469, identifier:line; 470, call; 470, 471; 470, 476; 471, attribute; 471, 472; 471, 475; 472, attribute; 472, 473; 472, 474; 473, identifier:packet; 474, identifier:datain; 475, identifier:read; 476, argument_list; 476, 477; 477, identifier:size; 478, expression_statement; 478, 479; 479, assignment; 479, 480; 479, 481; 480, identifier:n; 481, call; 481, 482; 481, 483; 482, identifier:len; 483, argument_list; 483, 484; 484, identifier:line; 485, if_statement; 485, 486; 485, 489; 486, comparison_operator:<; 486, 487; 486, 488; 487, identifier:n; 488, identifier:size; 489, block; 489, 490; 490, return_statement; 491, if_statement; 491, 492; 491, 495; 492, attribute; 492, 493; 492, 494; 493, identifier:self; 494, identifier:needs_update; 495, block; 495, 496; 495, 502; 496, expression_statement; 496, 497; 497, call; 497, 498; 497, 501; 498, attribute; 498, 499; 498, 500; 499, identifier:self; 500, identifier:display_image; 501, argument_list; 502, expression_statement; 502, 503; 503, assignment; 503, 504; 503, 507; 504, attribute; 504, 505; 504, 506; 505, identifier:self; 506, identifier:needs_update; 507, False | def handle(self):
self.logger = self.server.logger
packet = iis()
packet.datain = self.rfile
packet.dataout = self.wfile
size = struct.calcsize('8h')
line = packet.datain.read(size)
n = len(line)
if n < size:
return
while n > 0:
try:
bytes = struct.unpack('8h', line)
except Exception:
self.logger.error('error unpacking the data.')
for exctn in sys.exc_info():
print(exctn)
subunit = bytes[2]
subunit077 = subunit & 0o77
tid = bytes[0]
x = bytes[4] & 0o177777
y = bytes[5] & 0o177777
z = bytes[6] & 0o177777
t = bytes[7] & 0o17777
ndatabytes = - bytes[1]
if (not(tid & PACKED)):
ndatabytes *= 2
packet.subunit = subunit
packet.subunit077 = subunit077
packet.tid = tid
packet.x = x
packet.y = y
packet.z = z
packet.t = t
packet.nbytes = ndatabytes
self.logger.debug("PACKET IS %o" % packet.subunit)
if packet.subunit077 == FEEDBACK:
self.handle_feedback(packet)
elif packet.subunit077 == LUT:
self.handle_lut(packet)
line = packet.datain.read(size)
n = len(line)
continue
elif packet.subunit077 == MEMORY:
self.handle_memory(packet)
if self.needs_update:
pass
line = packet.datain.read(size)
n = len(line)
continue
elif packet.subunit077 == WCS:
self.handle_wcs(packet)
line = packet.datain.read(size)
n = len(line)
continue
elif packet.subunit077 == IMCURSOR:
self.handle_imcursor(packet)
line = packet.datain.read(size)
n = len(line)
continue
else:
self.logger.debug('?NO OP (0%o)' % (packet.subunit077))
if not (packet.tid & IIS_READ):
nbytes = packet.nbytes
while nbytes > 0:
if nbytes < SZ_FIFOBUF:
n = nbytes
else:
n = SZ_FIFOBUF
m = self.rfile.read(n)
if m <= 0:
break
nbytes -= n
line = packet.datain.read(size)
n = len(line)
if n < size:
return
if self.needs_update:
self.display_image()
self.needs_update = False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:load_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:filepath; 6, default_parameter; 6, 7; 6, 8; 7, identifier:chname; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:wait; 11, True; 12, default_parameter; 12, 13; 12, 14; 13, identifier:create_channel; 14, True; 15, default_parameter; 15, 16; 15, 17; 16, identifier:display_image; 17, True; 18, default_parameter; 18, 19; 18, 20; 19, identifier:image_loader; 20, None; 21, block; 21, 22; 21, 66; 21, 72; 21, 83; 21, 97; 21, 109; 21, 133; 21, 139; 21, 143; 21, 147; 21, 162; 21, 201; 21, 209; 21, 219; 21, 231; 21, 251; 21, 261; 21, 287; 21, 337; 22, if_statement; 22, 23; 22, 25; 22, 34; 23, not_operator; 23, 24; 24, identifier:chname; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:channel; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:get_current_channel; 33, argument_list; 34, else_clause; 34, 35; 35, block; 35, 36; 35, 57; 36, if_statement; 36, 37; 36, 46; 37, boolean_operator:and; 37, 38; 37, 45; 38, not_operator; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:has_channel; 43, argument_list; 43, 44; 44, identifier:chname; 45, identifier:create_channel; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:gui_call; 52, argument_list; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:add_channel; 56, identifier:chname; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:channel; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:get_channel; 64, argument_list; 64, 65; 65, identifier:chname; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:chname; 69, attribute; 69, 70; 69, 71; 70, identifier:channel; 71, identifier:name; 72, if_statement; 72, 73; 72, 76; 73, comparison_operator:is; 73, 74; 73, 75; 74, identifier:image_loader; 75, None; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:image_loader; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:load_image; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:cache_dir; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:settings; 91, identifier:get; 92, argument_list; 92, 93; 92, 94; 93, string:'download_folder'; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:tmpdir; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:info; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:iohelper; 103, identifier:get_fileinfo; 104, argument_list; 104, 105; 104, 106; 105, identifier:filepath; 106, keyword_argument; 106, 107; 106, 108; 107, identifier:cache_dir; 108, identifier:cache_dir; 109, if_statement; 109, 110; 109, 114; 110, not_operator; 110, 111; 111, attribute; 111, 112; 111, 113; 112, identifier:info; 113, identifier:ondisk; 114, block; 114, 115; 114, 122; 114, 132; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:errmsg; 118, binary_operator:%; 118, 119; 118, 120; 119, string:"File must be locally loadable: %s"; 120, parenthesized_expression; 120, 121; 121, identifier:filepath; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:gui_do; 127, argument_list; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:self; 130, identifier:show_error; 131, identifier:errmsg; 132, return_statement; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:filepath; 136, attribute; 136, 137; 136, 138; 137, identifier:info; 138, identifier:filepath; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:kwargs; 142, dictionary; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 146; 145, identifier:idx; 146, None; 147, if_statement; 147, 148; 147, 153; 148, comparison_operator:is; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:info; 151, identifier:numhdu; 152, None; 153, block; 153, 154; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 159; 156, subscript; 156, 157; 156, 158; 157, identifier:kwargs; 158, string:'idx'; 159, attribute; 159, 160; 159, 161; 160, identifier:info; 161, identifier:numhdu; 162, try_statement; 162, 163; 162, 173; 163, block; 163, 164; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:image; 167, call; 167, 168; 167, 169; 168, identifier:image_loader; 169, argument_list; 169, 170; 169, 171; 170, identifier:filepath; 171, dictionary_splat; 171, 172; 172, identifier:kwargs; 173, except_clause; 173, 174; 173, 178; 174, as_pattern; 174, 175; 174, 176; 175, identifier:Exception; 176, as_pattern_target; 176, 177; 177, identifier:e; 178, block; 178, 179; 178, 190; 178, 200; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:errmsg; 182, binary_operator:%; 182, 183; 182, 184; 183, string:"Failed to load '%s': %s"; 184, tuple; 184, 185; 184, 186; 185, identifier:filepath; 186, call; 186, 187; 186, 188; 187, identifier:str; 188, argument_list; 188, 189; 189, identifier:e; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:self; 194, identifier:gui_do; 195, argument_list; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:self; 198, identifier:show_error; 199, identifier:errmsg; 200, return_statement; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:future; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:Future; 207, identifier:Future; 208, argument_list; 209, expression_statement; 209, 210; 210, call; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:future; 213, identifier:freeze; 214, argument_list; 214, 215; 214, 216; 214, 217; 215, identifier:image_loader; 216, identifier:filepath; 217, dictionary_splat; 217, 218; 218, identifier:kwargs; 219, expression_statement; 219, 220; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:image; 223, identifier:set; 224, argument_list; 224, 225; 224, 228; 225, keyword_argument; 225, 226; 225, 227; 226, identifier:loader; 227, identifier:image_loader; 228, keyword_argument; 228, 229; 228, 230; 229, identifier:image_future; 230, identifier:future; 231, if_statement; 231, 232; 231, 241; 232, comparison_operator:is; 232, 233; 232, 240; 233, call; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:image; 236, identifier:get; 237, argument_list; 237, 238; 237, 239; 238, string:'path'; 239, None; 240, None; 241, block; 241, 242; 242, expression_statement; 242, 243; 243, call; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:image; 246, identifier:set; 247, argument_list; 247, 248; 248, keyword_argument; 248, 249; 248, 250; 249, identifier:path; 250, identifier:filepath; 251, expression_statement; 251, 252; 252, assignment; 252, 253; 252, 254; 253, identifier:name; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:image; 257, identifier:get; 258, argument_list; 258, 259; 258, 260; 259, string:'name'; 260, None; 261, if_statement; 261, 262; 261, 265; 262, comparison_operator:is; 262, 263; 262, 264; 263, identifier:name; 264, None; 265, block; 265, 266; 265, 278; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 269; 268, identifier:name; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:iohelper; 272, identifier:name_image_from_path; 273, argument_list; 273, 274; 273, 275; 274, identifier:filepath; 275, keyword_argument; 275, 276; 275, 277; 276, identifier:idx; 277, identifier:idx; 278, expression_statement; 278, 279; 279, call; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:image; 282, identifier:set; 283, argument_list; 283, 284; 284, keyword_argument; 284, 285; 284, 286; 285, identifier:name; 286, identifier:name; 287, if_statement; 287, 288; 287, 289; 287, 323; 288, identifier:display_image; 289, block; 289, 290; 290, if_statement; 290, 291; 290, 292; 290, 307; 291, identifier:wait; 292, block; 292, 293; 293, expression_statement; 293, 294; 294, call; 294, 295; 294, 298; 295, attribute; 295, 296; 295, 297; 296, identifier:self; 297, identifier:gui_call; 298, argument_list; 298, 299; 298, 302; 298, 303; 298, 304; 299, attribute; 299, 300; 299, 301; 300, identifier:self; 301, identifier:add_image; 302, identifier:name; 303, identifier:image; 304, keyword_argument; 304, 305; 304, 306; 305, identifier:chname; 306, identifier:chname; 307, else_clause; 307, 308; 308, block; 308, 309; 309, expression_statement; 309, 310; 310, call; 310, 311; 310, 314; 311, attribute; 311, 312; 311, 313; 312, identifier:self; 313, identifier:gui_do; 314, argument_list; 314, 315; 314, 318; 314, 319; 314, 320; 315, attribute; 315, 316; 315, 317; 316, identifier:self; 317, identifier:add_image; 318, identifier:name; 319, identifier:image; 320, keyword_argument; 320, 321; 320, 322; 321, identifier:chname; 322, identifier:chname; 323, else_clause; 323, 324; 324, block; 324, 325; 325, expression_statement; 325, 326; 326, call; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:self; 329, identifier:gui_do; 330, argument_list; 330, 331; 330, 334; 330, 335; 330, 336; 331, attribute; 331, 332; 331, 333; 332, identifier:self; 333, identifier:bulk_add_image; 334, identifier:name; 335, identifier:image; 336, identifier:chname; 337, return_statement; 337, 338; 338, identifier:image | def load_file(self, filepath, chname=None, wait=True,
create_channel=True, display_image=True,
image_loader=None):
if not chname:
channel = self.get_current_channel()
else:
if not self.has_channel(chname) and create_channel:
self.gui_call(self.add_channel, chname)
channel = self.get_channel(chname)
chname = channel.name
if image_loader is None:
image_loader = self.load_image
cache_dir = self.settings.get('download_folder', self.tmpdir)
info = iohelper.get_fileinfo(filepath, cache_dir=cache_dir)
if not info.ondisk:
errmsg = "File must be locally loadable: %s" % (filepath)
self.gui_do(self.show_error, errmsg)
return
filepath = info.filepath
kwargs = {}
idx = None
if info.numhdu is not None:
kwargs['idx'] = info.numhdu
try:
image = image_loader(filepath, **kwargs)
except Exception as e:
errmsg = "Failed to load '%s': %s" % (filepath, str(e))
self.gui_do(self.show_error, errmsg)
return
future = Future.Future()
future.freeze(image_loader, filepath, **kwargs)
image.set(loader=image_loader, image_future=future)
if image.get('path', None) is None:
image.set(path=filepath)
name = image.get('name', None)
if name is None:
name = iohelper.name_image_from_path(filepath, idx=idx)
image.set(name=name)
if display_image:
if wait:
self.gui_call(self.add_image, name, image, chname=chname)
else:
self.gui_do(self.add_image, name, image, chname=chname)
else:
self.gui_do(self.bulk_add_image, name, image, chname)
return image |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:open_uris; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:uris; 6, default_parameter; 6, 7; 6, 8; 7, identifier:chname; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:bulk_add; 11, False; 12, block; 12, 13; 12, 22; 12, 47; 12, 56; 12, 74; 12, 90; 12, 108; 12, 124; 12, 149; 12, 155; 13, if_statement; 13, 14; 13, 20; 14, comparison_operator:==; 14, 15; 14, 19; 15, call; 15, 16; 15, 17; 16, identifier:len; 17, argument_list; 17, 18; 18, identifier:uris; 19, integer:0; 20, block; 20, 21; 21, return_statement; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:is; 23, 24; 23, 25; 24, identifier:chname; 25, None; 26, block; 26, 27; 26, 35; 26, 41; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:channel; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:get_channel_info; 34, argument_list; 35, if_statement; 35, 36; 35, 39; 36, comparison_operator:is; 36, 37; 36, 38; 37, identifier:channel; 38, None; 39, block; 39, 40; 40, return_statement; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:chname; 44, attribute; 44, 45; 44, 46; 45, identifier:channel; 46, identifier:name; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:channel; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:get_channel_on_demand; 54, argument_list; 54, 55; 55, identifier:chname; 56, function_definition; 56, 57; 56, 58; 56, 60; 57, function_name:show_dataobj_bulk; 58, parameters; 58, 59; 59, identifier:data_obj; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:gui_do; 66, argument_list; 66, 67; 66, 70; 66, 71; 67, attribute; 67, 68; 67, 69; 68, identifier:channel; 69, identifier:add_image; 70, identifier:data_obj; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:bulk_add; 73, True; 74, function_definition; 74, 75; 74, 76; 74, 78; 75, function_name:load_file_bulk; 76, parameters; 76, 77; 77, identifier:filepath; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:nongui_do; 84, argument_list; 84, 85; 84, 88; 84, 89; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:open_file_cont; 88, identifier:filepath; 89, identifier:show_dataobj_bulk; 90, function_definition; 90, 91; 90, 92; 90, 94; 91, function_name:show_dataobj; 92, parameters; 92, 93; 93, identifier:data_obj; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:gui_do; 100, argument_list; 100, 101; 100, 104; 100, 105; 101, attribute; 101, 102; 101, 103; 102, identifier:channel; 103, identifier:add_image; 104, identifier:data_obj; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:bulk_add; 107, False; 108, function_definition; 108, 109; 108, 110; 108, 112; 109, function_name:load_file; 110, parameters; 110, 111; 111, identifier:filepath; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:self; 117, identifier:nongui_do; 118, argument_list; 118, 119; 118, 122; 118, 123; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:open_file_cont; 122, identifier:filepath; 123, identifier:show_dataobj; 124, if_statement; 124, 125; 124, 126; 124, 137; 125, identifier:bulk_add; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:self; 131, identifier:open_uri_cont; 132, argument_list; 132, 133; 132, 136; 133, subscript; 133, 134; 133, 135; 134, identifier:uris; 135, integer:0; 136, identifier:load_file_bulk; 137, else_clause; 137, 138; 138, block; 138, 139; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:open_uri_cont; 144, argument_list; 144, 145; 144, 148; 145, subscript; 145, 146; 145, 147; 146, identifier:uris; 147, integer:0; 148, identifier:load_file; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:self; 153, identifier:update_pending; 154, argument_list; 155, for_statement; 155, 156; 155, 157; 155, 162; 156, identifier:uri; 157, subscript; 157, 158; 157, 159; 158, identifier:uris; 159, slice; 159, 160; 159, 161; 160, integer:1; 161, colon; 162, block; 162, 163; 162, 171; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:open_uri_cont; 168, argument_list; 168, 169; 168, 170; 169, identifier:uri; 170, identifier:load_file_bulk; 171, expression_statement; 171, 172; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:self; 175, identifier:update_pending; 176, argument_list | def open_uris(self, uris, chname=None, bulk_add=False):
if len(uris) == 0:
return
if chname is None:
channel = self.get_channel_info()
if channel is None:
return
chname = channel.name
channel = self.get_channel_on_demand(chname)
def show_dataobj_bulk(data_obj):
self.gui_do(channel.add_image, data_obj, bulk_add=True)
def load_file_bulk(filepath):
self.nongui_do(self.open_file_cont, filepath, show_dataobj_bulk)
def show_dataobj(data_obj):
self.gui_do(channel.add_image, data_obj, bulk_add=False)
def load_file(filepath):
self.nongui_do(self.open_file_cont, filepath, show_dataobj)
if bulk_add:
self.open_uri_cont(uris[0], load_file_bulk)
else:
self.open_uri_cont(uris[0], load_file)
self.update_pending()
for uri in uris[1:]:
self.open_uri_cont(uri, load_file_bulk)
self.update_pending() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:add_channel; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, identifier:chname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:workspace; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:num_images; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:settings; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:settings_template; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:settings_share; 20, None; 21, default_parameter; 21, 22; 21, 23; 22, identifier:share_keylist; 23, None; 24, block; 24, 25; 25, with_statement; 25, 26; 25, 31; 26, with_clause; 26, 27; 27, with_item; 27, 28; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:lock; 31, block; 31, 32; 31, 47; 31, 67; 31, 71; 31, 180; 31, 201; 31, 224; 31, 251; 31, 263; 31, 277; 31, 290; 31, 302; 31, 320; 31, 328; 31, 336; 31, 344; 31, 353; 31, 361; 31, 369; 31, 375; 31, 383; 31, 391; 31, 400; 31, 408; 31, 424; 31, 469; 31, 477; 32, if_statement; 32, 33; 32, 39; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:has_channel; 37, argument_list; 37, 38; 38, identifier:chname; 39, block; 39, 40; 40, return_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:get_channel; 45, argument_list; 45, 46; 46, identifier:chname; 47, if_statement; 47, 48; 47, 58; 48, comparison_operator:in; 48, 49; 48, 50; 49, identifier:chname; 50, call; 50, 51; 50, 56; 51, attribute; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:ds; 55, identifier:get_tabnames; 56, argument_list; 56, 57; 57, None; 58, block; 58, 59; 59, raise_statement; 59, 60; 60, call; 60, 61; 60, 62; 61, identifier:ValueError; 62, argument_list; 62, 63; 63, binary_operator:%; 63, 64; 63, 65; 64, string:"Tab name already in use: '%s'"; 65, parenthesized_expression; 65, 66; 66, identifier:chname; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:name; 70, identifier:chname; 71, if_statement; 71, 72; 71, 75; 72, comparison_operator:is; 72, 73; 72, 74; 73, identifier:settings; 74, None; 75, block; 75, 76; 75, 89; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:settings; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:prefs; 84, identifier:create_category; 85, argument_list; 85, 86; 86, binary_operator:+; 86, 87; 86, 88; 87, string:'channel_'; 88, identifier:name; 89, try_statement; 89, 90; 89, 100; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:settings; 95, identifier:load; 96, argument_list; 96, 97; 97, keyword_argument; 97, 98; 97, 99; 98, identifier:onError; 99, string:'raise'; 100, except_clause; 100, 101; 100, 105; 101, as_pattern; 101, 102; 101, 103; 102, identifier:Exception; 103, as_pattern_target; 103, 104; 104, identifier:e; 105, block; 105, 106; 105, 124; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 113; 108, attribute; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:logger; 112, identifier:warning; 113, argument_list; 113, 114; 114, binary_operator:%; 114, 115; 114, 118; 115, concatenated_string; 115, 116; 115, 117; 116, string:"no saved preferences found for channel "; 117, string:"'%s': %s"; 118, tuple; 118, 119; 118, 120; 119, identifier:name; 120, call; 120, 121; 120, 122; 121, identifier:str; 122, argument_list; 122, 123; 123, identifier:e; 124, if_statement; 124, 125; 124, 128; 124, 140; 125, comparison_operator:is; 125, 126; 125, 127; 126, identifier:settings_template; 127, None; 128, block; 128, 129; 128, 133; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:osettings; 132, identifier:settings_template; 133, expression_statement; 133, 134; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:osettings; 137, identifier:copy_settings; 138, argument_list; 138, 139; 139, identifier:settings; 140, else_clause; 140, 141; 141, block; 141, 142; 142, try_statement; 142, 143; 142, 176; 143, block; 143, 144; 143, 155; 143, 169; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:osettings; 147, call; 147, 148; 147, 153; 148, attribute; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:prefs; 152, identifier:get_settings; 153, argument_list; 153, 154; 154, string:'channel_Image'; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 162; 157, attribute; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:logger; 161, identifier:debug; 162, argument_list; 162, 163; 163, binary_operator:%; 163, 164; 163, 167; 164, concatenated_string; 164, 165; 164, 166; 165, string:"Copying settings from 'Image' to "; 166, string:"'%s'"; 167, parenthesized_expression; 167, 168; 168, identifier:name; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:osettings; 173, identifier:copy_settings; 174, argument_list; 174, 175; 175, identifier:settings; 176, except_clause; 176, 177; 176, 178; 177, identifier:KeyError; 178, block; 178, 179; 179, pass_statement; 180, if_statement; 180, 181; 180, 190; 181, boolean_operator:and; 181, 182; 181, 186; 182, parenthesized_expression; 182, 183; 183, comparison_operator:is; 183, 184; 183, 185; 184, identifier:share_keylist; 185, None; 186, parenthesized_expression; 186, 187; 187, comparison_operator:is; 187, 188; 187, 189; 188, identifier:settings_share; 189, None; 190, block; 190, 191; 191, expression_statement; 191, 192; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:settings_share; 195, identifier:share_settings; 196, argument_list; 196, 197; 196, 198; 197, identifier:settings; 198, keyword_argument; 198, 199; 198, 200; 199, identifier:keylist; 200, identifier:share_keylist; 201, if_statement; 201, 202; 201, 205; 202, comparison_operator:is; 202, 203; 202, 204; 203, identifier:num_images; 204, None; 205, block; 205, 206; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 209; 208, identifier:num_images; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:settings; 212, identifier:get; 213, argument_list; 213, 214; 213, 215; 214, string:'numImages'; 215, call; 215, 216; 215, 221; 216, attribute; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:self; 219, identifier:settings; 220, identifier:get; 221, argument_list; 221, 222; 221, 223; 222, string:'numImages'; 223, integer:1; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:settings; 228, identifier:set_defaults; 229, argument_list; 229, 230; 229, 233; 229, 236; 229, 239; 229, 242; 229, 245; 229, 248; 230, keyword_argument; 230, 231; 230, 232; 231, identifier:switchnew; 232, True; 233, keyword_argument; 233, 234; 233, 235; 234, identifier:numImages; 235, identifier:num_images; 236, keyword_argument; 236, 237; 236, 238; 237, identifier:raisenew; 238, True; 239, keyword_argument; 239, 240; 239, 241; 240, identifier:genthumb; 241, True; 242, keyword_argument; 242, 243; 242, 244; 243, identifier:focus_indicator; 244, False; 245, keyword_argument; 245, 246; 245, 247; 246, identifier:preload_images; 247, False; 248, keyword_argument; 248, 249; 248, 250; 249, identifier:sort_order; 250, string:'loadtime'; 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:logger; 257, identifier:debug; 258, argument_list; 258, 259; 259, binary_operator:%; 259, 260; 259, 261; 260, string:"Adding channel '%s'"; 261, parenthesized_expression; 261, 262; 262, identifier:chname; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:channel; 266, call; 266, 267; 266, 268; 267, identifier:Channel; 268, argument_list; 268, 269; 268, 270; 268, 271; 268, 274; 269, identifier:chname; 270, identifier:self; 271, keyword_argument; 271, 272; 271, 273; 272, identifier:datasrc; 273, None; 274, keyword_argument; 274, 275; 274, 276; 275, identifier:settings; 276, identifier:settings; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 280; 279, identifier:bnch; 280, call; 280, 281; 280, 284; 281, attribute; 281, 282; 281, 283; 282, identifier:self; 283, identifier:add_viewer; 284, argument_list; 284, 285; 284, 286; 284, 287; 285, identifier:chname; 286, identifier:settings; 287, keyword_argument; 287, 288; 287, 289; 288, identifier:workspace; 289, identifier:workspace; 290, expression_statement; 290, 291; 291, call; 291, 292; 291, 297; 292, attribute; 292, 293; 292, 296; 293, attribute; 293, 294; 293, 295; 294, identifier:bnch; 295, identifier:image_viewer; 296, identifier:set_name; 297, argument_list; 297, 298; 298, binary_operator:%; 298, 299; 298, 300; 299, string:'channel:%s'; 300, parenthesized_expression; 300, 301; 301, identifier:chname; 302, expression_statement; 302, 303; 303, assignment; 303, 304; 303, 305; 304, identifier:opmon; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:self; 308, identifier:get_plugin_manager; 309, argument_list; 309, 310; 309, 313; 309, 314; 309, 317; 310, attribute; 310, 311; 310, 312; 311, identifier:self; 312, identifier:logger; 313, identifier:self; 314, attribute; 314, 315; 314, 316; 315, identifier:self; 316, identifier:ds; 317, attribute; 317, 318; 317, 319; 318, identifier:self; 319, identifier:mm; 320, expression_statement; 320, 321; 321, assignment; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:channel; 324, identifier:widget; 325, attribute; 325, 326; 325, 327; 326, identifier:bnch; 327, identifier:widget; 328, expression_statement; 328, 329; 329, assignment; 329, 330; 329, 333; 330, attribute; 330, 331; 330, 332; 331, identifier:channel; 332, identifier:container; 333, attribute; 333, 334; 333, 335; 334, identifier:bnch; 335, identifier:container; 336, expression_statement; 336, 337; 337, assignment; 337, 338; 337, 341; 338, attribute; 338, 339; 338, 340; 339, identifier:channel; 340, identifier:workspace; 341, attribute; 341, 342; 341, 343; 342, identifier:bnch; 343, identifier:workspace; 344, expression_statement; 344, 345; 345, call; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:channel; 348, identifier:connect_viewer; 349, argument_list; 349, 350; 350, attribute; 350, 351; 350, 352; 351, identifier:bnch; 352, identifier:image_viewer; 353, expression_statement; 353, 354; 354, assignment; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:channel; 357, identifier:viewer; 358, attribute; 358, 359; 358, 360; 359, identifier:bnch; 360, identifier:image_viewer; 361, expression_statement; 361, 362; 362, assignment; 362, 363; 362, 366; 363, attribute; 363, 364; 363, 365; 364, identifier:channel; 365, identifier:fitsimage; 366, attribute; 366, 367; 366, 368; 367, identifier:bnch; 368, identifier:image_viewer; 369, expression_statement; 369, 370; 370, assignment; 370, 371; 370, 374; 371, attribute; 371, 372; 371, 373; 372, identifier:channel; 373, identifier:opmon; 374, identifier:opmon; 375, expression_statement; 375, 376; 376, assignment; 376, 377; 376, 378; 377, identifier:name; 378, call; 378, 379; 378, 382; 379, attribute; 379, 380; 379, 381; 380, identifier:chname; 381, identifier:lower; 382, argument_list; 383, expression_statement; 383, 384; 384, assignment; 384, 385; 384, 390; 385, subscript; 385, 386; 385, 389; 386, attribute; 386, 387; 386, 388; 387, identifier:self; 388, identifier:channel; 389, identifier:name; 390, identifier:channel; 391, expression_statement; 391, 392; 392, call; 392, 393; 392, 398; 393, attribute; 393, 394; 393, 397; 394, attribute; 394, 395; 394, 396; 395, identifier:self; 396, identifier:channel_names; 397, identifier:append; 398, argument_list; 398, 399; 399, identifier:chname; 400, expression_statement; 400, 401; 401, call; 401, 402; 401, 407; 402, attribute; 402, 403; 402, 406; 403, attribute; 403, 404; 403, 405; 404, identifier:self; 405, identifier:channel_names; 406, identifier:sort; 407, argument_list; 408, if_statement; 408, 409; 408, 417; 409, comparison_operator:==; 409, 410; 409, 416; 410, call; 410, 411; 410, 412; 411, identifier:len; 412, argument_list; 412, 413; 413, attribute; 413, 414; 413, 415; 414, identifier:self; 415, identifier:channel_names; 416, integer:1; 417, block; 417, 418; 418, expression_statement; 418, 419; 419, assignment; 419, 420; 419, 423; 420, attribute; 420, 421; 420, 422; 421, identifier:self; 422, identifier:cur_channel; 423, identifier:channel; 424, for_statement; 424, 425; 424, 426; 424, 431; 425, identifier:spec; 426, call; 426, 427; 426, 430; 427, attribute; 427, 428; 427, 429; 428, identifier:self; 429, identifier:get_plugins; 430, argument_list; 431, block; 431, 432; 431, 447; 432, expression_statement; 432, 433; 433, assignment; 433, 434; 433, 435; 434, identifier:opname; 435, call; 435, 436; 435, 439; 436, attribute; 436, 437; 436, 438; 437, identifier:spec; 438, identifier:get; 439, argument_list; 439, 440; 439, 441; 440, string:'klass'; 441, call; 441, 442; 441, 445; 442, attribute; 442, 443; 442, 444; 443, identifier:spec; 444, identifier:get; 445, argument_list; 445, 446; 446, string:'module'; 447, if_statement; 447, 448; 447, 457; 448, comparison_operator:==; 448, 449; 448, 456; 449, call; 449, 450; 449, 453; 450, attribute; 450, 451; 450, 452; 451, identifier:spec; 452, identifier:get; 453, argument_list; 453, 454; 453, 455; 454, string:'ptype'; 455, string:'global'; 456, string:'local'; 457, block; 457, 458; 458, expression_statement; 458, 459; 459, call; 459, 460; 459, 463; 460, attribute; 460, 461; 460, 462; 461, identifier:opmon; 462, identifier:load_plugin; 463, argument_list; 463, 464; 463, 465; 463, 466; 464, identifier:opname; 465, identifier:spec; 466, keyword_argument; 466, 467; 466, 468; 467, identifier:chinfo; 468, identifier:channel; 469, expression_statement; 469, 470; 470, call; 470, 471; 470, 474; 471, attribute; 471, 472; 471, 473; 472, identifier:self; 473, identifier:make_gui_callback; 474, argument_list; 474, 475; 474, 476; 475, string:'add-channel'; 476, identifier:channel; 477, return_statement; 477, 478; 478, identifier:channel | def add_channel(self, chname, workspace=None,
num_images=None, settings=None,
settings_template=None,
settings_share=None, share_keylist=None):
with self.lock:
if self.has_channel(chname):
return self.get_channel(chname)
if chname in self.ds.get_tabnames(None):
raise ValueError("Tab name already in use: '%s'" % (chname))
name = chname
if settings is None:
settings = self.prefs.create_category('channel_' + name)
try:
settings.load(onError='raise')
except Exception as e:
self.logger.warning("no saved preferences found for channel "
"'%s': %s" % (name, str(e)))
if settings_template is not None:
osettings = settings_template
osettings.copy_settings(settings)
else:
try:
osettings = self.prefs.get_settings('channel_Image')
self.logger.debug("Copying settings from 'Image' to "
"'%s'" % (name))
osettings.copy_settings(settings)
except KeyError:
pass
if (share_keylist is not None) and (settings_share is not None):
settings_share.share_settings(settings, keylist=share_keylist)
if num_images is None:
num_images = settings.get('numImages',
self.settings.get('numImages', 1))
settings.set_defaults(switchnew=True, numImages=num_images,
raisenew=True, genthumb=True,
focus_indicator=False,
preload_images=False, sort_order='loadtime')
self.logger.debug("Adding channel '%s'" % (chname))
channel = Channel(chname, self, datasrc=None,
settings=settings)
bnch = self.add_viewer(chname, settings,
workspace=workspace)
bnch.image_viewer.set_name('channel:%s' % (chname))
opmon = self.get_plugin_manager(self.logger, self,
self.ds, self.mm)
channel.widget = bnch.widget
channel.container = bnch.container
channel.workspace = bnch.workspace
channel.connect_viewer(bnch.image_viewer)
channel.viewer = bnch.image_viewer
channel.fitsimage = bnch.image_viewer
channel.opmon = opmon
name = chname.lower()
self.channel[name] = channel
self.channel_names.append(chname)
self.channel_names.sort()
if len(self.channel_names) == 1:
self.cur_channel = channel
for spec in self.get_plugins():
opname = spec.get('klass', spec.get('module'))
if spec.get('ptype', 'global') == 'local':
opmon.load_plugin(opname, spec, chinfo=channel)
self.make_gui_callback('add-channel', channel)
return channel |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mode_key_down; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:viewer; 6, identifier:keyname; 7, block; 7, 8; 7, 50; 7, 56; 7, 71; 7, 87; 7, 100; 7, 189; 8, if_statement; 8, 9; 8, 14; 8, 40; 9, comparison_operator:not; 9, 10; 9, 11; 10, identifier:keyname; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:mode_map; 14, block; 14, 15; 14, 32; 15, if_statement; 15, 16; 15, 29; 16, boolean_operator:or; 16, 17; 16, 23; 17, parenthesized_expression; 17, 18; 18, comparison_operator:not; 18, 19; 18, 20; 19, identifier:keyname; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:mode_tbl; 23, parenthesized_expression; 23, 24; 24, comparison_operator:!=; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:_kbdmode; 28, string:'meta'; 29, block; 29, 30; 30, return_statement; 30, 31; 31, False; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:bnch; 35, subscript; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:mode_tbl; 39, identifier:keyname; 40, else_clause; 40, 41; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:bnch; 45, subscript; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:mode_map; 49, identifier:keyname; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:mode_name; 53, attribute; 53, 54; 53, 55; 54, identifier:bnch; 55, identifier:name; 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:logger; 62, identifier:debug; 63, argument_list; 63, 64; 64, binary_operator:%; 64, 65; 64, 66; 65, string:"cur mode='%s' mode pressed='%s'"; 66, tuple; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:_kbdmode; 70, identifier:mode_name; 71, if_statement; 71, 72; 71, 77; 72, comparison_operator:==; 72, 73; 72, 74; 73, identifier:mode_name; 74, attribute; 74, 75; 74, 76; 75, identifier:self; 76, identifier:_kbdmode; 77, block; 77, 78; 77, 85; 78, expression_statement; 78, 79; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:reset_mode; 83, argument_list; 83, 84; 84, identifier:viewer; 85, return_statement; 85, 86; 86, True; 87, if_statement; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:_delayed_reset; 91, block; 91, 92; 91, 98; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:_delayed_reset; 97, False; 98, return_statement; 98, 99; 99, True; 100, if_statement; 100, 101; 100, 122; 101, parenthesized_expression; 101, 102; 102, boolean_operator:or; 102, 103; 102, 118; 103, boolean_operator:or; 103, 104; 103, 112; 104, parenthesized_expression; 104, 105; 105, comparison_operator:in; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:_kbdmode; 109, tuple; 109, 110; 109, 111; 110, None; 111, string:'meta'; 112, parenthesized_expression; 112, 113; 113, comparison_operator:!=; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:_kbdmode_type; 117, string:'locked'; 118, parenthesized_expression; 118, 119; 119, comparison_operator:==; 119, 120; 119, 121; 120, identifier:mode_name; 121, string:'meta'; 122, block; 122, 123; 122, 137; 123, if_statement; 123, 124; 123, 129; 124, comparison_operator:is; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:self; 127, identifier:_kbdmode; 128, None; 129, block; 129, 130; 130, expression_statement; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:reset_mode; 135, argument_list; 135, 136; 136, identifier:viewer; 137, if_statement; 137, 138; 137, 145; 138, comparison_operator:in; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:_kbdmode; 142, tuple; 142, 143; 142, 144; 143, None; 144, string:'meta'; 145, block; 145, 146; 145, 152; 145, 163; 145, 171; 145, 187; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:mode_type; 149, attribute; 149, 150; 149, 151; 150, identifier:bnch; 151, identifier:type; 152, if_statement; 152, 153; 152, 156; 153, comparison_operator:is; 153, 154; 153, 155; 154, identifier:mode_type; 155, None; 156, block; 156, 157; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:mode_type; 160, attribute; 160, 161; 160, 162; 161, identifier:self; 162, identifier:_kbdmode_type_default; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:set_mode; 168, argument_list; 168, 169; 168, 170; 169, identifier:mode_name; 170, identifier:mode_type; 171, if_statement; 171, 172; 171, 177; 172, comparison_operator:is; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:bnch; 175, identifier:msg; 176, None; 177, block; 177, 178; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:viewer; 182, identifier:onscreen_message; 183, argument_list; 183, 184; 184, attribute; 184, 185; 184, 186; 185, identifier:bnch; 186, identifier:msg; 187, return_statement; 187, 188; 188, True; 189, return_statement; 189, 190; 190, False | def mode_key_down(self, viewer, keyname):
if keyname not in self.mode_map:
if (keyname not in self.mode_tbl) or (self._kbdmode != 'meta'):
return False
bnch = self.mode_tbl[keyname]
else:
bnch = self.mode_map[keyname]
mode_name = bnch.name
self.logger.debug("cur mode='%s' mode pressed='%s'" % (
self._kbdmode, mode_name))
if mode_name == self._kbdmode:
self.reset_mode(viewer)
return True
if self._delayed_reset:
self._delayed_reset = False
return True
if ((self._kbdmode in (None, 'meta')) or
(self._kbdmode_type != 'locked') or (mode_name == 'meta')):
if self._kbdmode is not None:
self.reset_mode(viewer)
if self._kbdmode in (None, 'meta'):
mode_type = bnch.type
if mode_type is None:
mode_type = self._kbdmode_type_default
self.set_mode(mode_name, mode_type)
if bnch.msg is not None:
viewer.onscreen_message(bnch.msg)
return True
return False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:set_sort_cb; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:w; 6, identifier:index; 7, block; 7, 8; 7, 16; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:name; 11, subscript; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:sort_options; 15, identifier:index; 16, expression_statement; 16, 17; 17, call; 17, 18; 17, 23; 18, attribute; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:t_; 22, identifier:set; 23, argument_list; 23, 24; 24, keyword_argument; 24, 25; 24, 26; 25, identifier:sort_order; 26, identifier:name | def set_sort_cb(self, w, index):
name = self.sort_options[index]
self.t_.set(sort_order=name) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:redo; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 23; 5, 33; 5, 48; 5, 58; 5, 197; 5, 212; 5, 222; 5, 232; 5, 244; 5, 250; 5, 254; 5, 307; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:image; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:channel; 14, identifier:get_current_image; 15, argument_list; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:is; 17, 18; 17, 19; 18, identifier:image; 19, None; 20, block; 20, 21; 21, return_statement; 21, 22; 22, True; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:path; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:image; 29, identifier:get; 30, argument_list; 30, 31; 30, 32; 31, string:'path'; 32, None; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:is; 34, 35; 34, 36; 35, identifier:path; 36, None; 37, block; 37, 38; 37, 47; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 45; 40, attribute; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:fv; 44, identifier:show_error; 45, argument_list; 45, 46; 46, string:"Cannot open image: no value for metadata key 'path'"; 47, return_statement; 48, if_statement; 48, 49; 48, 55; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:path; 52, identifier:endswith; 53, argument_list; 53, 54; 54, string:'asdf'; 55, block; 55, 56; 56, return_statement; 56, 57; 57, True; 58, if_statement; 58, 59; 58, 64; 59, comparison_operator:!=; 59, 60; 59, 61; 60, identifier:path; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:img_path; 64, block; 64, 65; 64, 71; 64, 92; 64, 107; 64, 116; 64, 127; 64, 143; 64, 149; 64, 163; 64, 179; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:img_path; 70, identifier:path; 71, if_statement; 71, 72; 71, 77; 72, comparison_operator:is; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:file_obj; 76, None; 77, block; 77, 78; 78, try_statement; 78, 79; 78, 88; 79, block; 79, 80; 80, expression_statement; 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:file_obj; 86, identifier:close; 87, argument_list; 88, except_clause; 88, 89; 88, 90; 89, identifier:Exception; 90, block; 90, 91; 91, pass_statement; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:file_obj; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:io_fits; 100, identifier:get_fitsloader; 101, argument_list; 101, 102; 102, keyword_argument; 102, 103; 102, 104; 103, identifier:logger; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:logger; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 114; 109, attribute; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:self; 112, identifier:file_obj; 113, identifier:open_file; 114, argument_list; 114, 115; 115, identifier:path; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:upper; 119, binary_operator:-; 119, 120; 119, 126; 120, call; 120, 121; 120, 122; 121, identifier:len; 122, argument_list; 122, 123; 123, attribute; 123, 124; 123, 125; 124, identifier:self; 125, identifier:file_obj; 126, integer:1; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:self; 131, identifier:prep_hdu_menu; 132, argument_list; 132, 133; 132, 138; 133, attribute; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:self; 136, identifier:w; 137, identifier:hdu; 138, attribute; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:file_obj; 142, identifier:hdu_info; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:num_hdu; 148, identifier:upper; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 156; 151, attribute; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:logger; 155, identifier:debug; 156, argument_list; 156, 157; 157, binary_operator:%; 157, 158; 157, 159; 158, string:"there are %d hdus"; 159, parenthesized_expression; 159, 160; 160, binary_operator:+; 160, 161; 160, 162; 161, identifier:upper; 162, integer:1; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 172; 165, attribute; 165, 166; 165, 171; 166, attribute; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:self; 169, identifier:w; 170, identifier:numhdu; 171, identifier:set_text; 172, argument_list; 172, 173; 173, binary_operator:%; 173, 174; 173, 175; 174, string:"%d"; 175, parenthesized_expression; 175, 176; 176, binary_operator:+; 176, 177; 176, 178; 177, identifier:upper; 178, integer:1; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 188; 181, attribute; 181, 182; 181, 187; 182, attribute; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:self; 185, identifier:w; 186, identifier:hdu; 187, identifier:set_enabled; 188, argument_list; 188, 189; 189, comparison_operator:>; 189, 190; 189, 196; 190, call; 190, 191; 190, 192; 191, identifier:len; 192, argument_list; 192, 193; 193, attribute; 193, 194; 193, 195; 194, identifier:self; 195, identifier:file_obj; 196, integer:0; 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, identifier:image; 203, identifier:get; 204, argument_list; 204, 205; 204, 206; 205, string:'name'; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:iohelper; 209, identifier:name_image_from_path; 210, argument_list; 210, 211; 211, identifier:path; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:idx; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:image; 218, identifier:get; 219, argument_list; 219, 220; 219, 221; 220, string:'idx'; 221, None; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:match; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:re; 228, identifier:match; 229, argument_list; 229, 230; 229, 231; 230, string:r'^(.+)\[(.+)\]$'; 231, identifier:name; 232, if_statement; 232, 233; 232, 234; 233, identifier:match; 234, block; 234, 235; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:name; 238, call; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:match; 241, identifier:group; 242, argument_list; 242, 243; 243, integer:1; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, identifier:self; 248, identifier:name_pfx; 249, identifier:name; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:htype; 253, None; 254, if_statement; 254, 255; 254, 258; 255, comparison_operator:is; 255, 256; 255, 257; 256, identifier:idx; 257, None; 258, block; 258, 259; 258, 273; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 262; 261, identifier:info; 262, call; 262, 263; 262, 270; 263, attribute; 263, 264; 263, 269; 264, attribute; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:self; 267, identifier:file_obj; 268, identifier:hdu_db; 269, identifier:get; 270, argument_list; 270, 271; 270, 272; 271, identifier:idx; 272, None; 273, if_statement; 273, 274; 273, 277; 274, comparison_operator:is; 274, 275; 274, 276; 275, identifier:info; 276, None; 277, block; 277, 278; 277, 288; 277, 296; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:htype; 281, call; 281, 282; 281, 287; 282, attribute; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:info; 285, identifier:htype; 286, identifier:lower; 287, argument_list; 288, expression_statement; 288, 289; 289, assignment; 289, 290; 289, 291; 290, identifier:toc_ent; 291, binary_operator:%; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:self; 294, identifier:_toc_fmt; 295, identifier:info; 296, expression_statement; 296, 297; 297, call; 297, 298; 297, 305; 298, attribute; 298, 299; 298, 304; 299, attribute; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:self; 302, identifier:w; 303, identifier:hdu; 304, identifier:show_text; 305, argument_list; 305, 306; 306, identifier:toc_ent; 307, if_statement; 307, 308; 307, 313; 308, comparison_operator:!=; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:self; 311, identifier:img_name; 312, identifier:name; 313, block; 313, 314; 313, 320; 313, 326; 313, 334; 313, 416; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:self; 318, identifier:img_name; 319, identifier:name; 320, expression_statement; 320, 321; 321, assignment; 321, 322; 321, 323; 322, identifier:dims; 323, list:[0, 0]; 323, 324; 323, 325; 324, integer:0; 325, integer:0; 326, expression_statement; 326, 327; 327, assignment; 327, 328; 327, 329; 328, identifier:data; 329, call; 329, 330; 329, 333; 330, attribute; 330, 331; 330, 332; 331, identifier:image; 332, identifier:get_data; 333, argument_list; 334, if_statement; 334, 335; 334, 338; 334, 354; 334, 362; 334, 386; 335, comparison_operator:is; 335, 336; 335, 337; 336, identifier:data; 337, None; 338, block; 338, 339; 339, expression_statement; 339, 340; 340, call; 340, 341; 340, 346; 341, attribute; 341, 342; 341, 345; 342, attribute; 342, 343; 342, 344; 343, identifier:self; 344, identifier:logger; 345, identifier:warning; 346, argument_list; 346, 347; 347, binary_operator:%; 347, 348; 347, 349; 348, string:"Empty data part in HDU %s"; 349, parenthesized_expression; 349, 350; 350, call; 350, 351; 350, 352; 351, identifier:str; 352, argument_list; 352, 353; 353, identifier:idx; 354, elif_clause; 354, 355; 354, 360; 355, comparison_operator:in; 355, 356; 355, 357; 356, identifier:htype; 357, tuple; 357, 358; 357, 359; 358, string:'bintablehdu'; 359, string:'tablehdu'; 360, block; 360, 361; 361, pass_statement; 362, elif_clause; 362, 363; 362, 369; 363, comparison_operator:not; 363, 364; 363, 365; 364, identifier:htype; 365, tuple; 365, 366; 365, 367; 365, 368; 366, string:'imagehdu'; 367, string:'primaryhdu'; 368, string:'compimagehdu'; 369, block; 369, 370; 370, expression_statement; 370, 371; 371, call; 371, 372; 371, 377; 372, attribute; 372, 373; 372, 376; 373, attribute; 373, 374; 373, 375; 374, identifier:self; 375, identifier:logger; 376, identifier:warning; 377, argument_list; 377, 378; 378, binary_operator:%; 378, 379; 378, 380; 379, string:"HDU %s is not an image (%s)"; 380, tuple; 380, 381; 380, 385; 381, call; 381, 382; 381, 383; 382, identifier:str; 383, argument_list; 383, 384; 384, identifier:idx; 385, identifier:htype; 386, else_clause; 386, 387; 387, block; 387, 388; 387, 396; 388, expression_statement; 388, 389; 389, assignment; 389, 390; 389, 391; 390, identifier:mddata; 391, call; 391, 392; 391, 395; 392, attribute; 392, 393; 392, 394; 393, identifier:image; 394, identifier:get_mddata; 395, argument_list; 396, if_statement; 396, 397; 396, 400; 397, comparison_operator:is; 397, 398; 397, 399; 398, identifier:mddata; 399, None; 400, block; 400, 401; 400, 410; 401, expression_statement; 401, 402; 402, assignment; 402, 403; 402, 404; 403, identifier:dims; 404, call; 404, 405; 404, 406; 405, identifier:list; 406, argument_list; 406, 407; 407, attribute; 407, 408; 407, 409; 408, identifier:mddata; 409, identifier:shape; 410, expression_statement; 410, 411; 411, call; 411, 412; 411, 415; 412, attribute; 412, 413; 412, 414; 413, identifier:dims; 414, identifier:reverse; 415, argument_list; 416, expression_statement; 416, 417; 417, call; 417, 418; 417, 421; 418, attribute; 418, 419; 418, 420; 419, identifier:self; 420, identifier:build_naxis; 421, argument_list; 421, 422; 421, 423; 422, identifier:dims; 423, identifier:image | def redo(self):
image = self.channel.get_current_image()
if image is None:
return True
path = image.get('path', None)
if path is None:
self.fv.show_error(
"Cannot open image: no value for metadata key 'path'")
return
if path.endswith('asdf'):
return True
if path != self.img_path:
self.img_path = path
if self.file_obj is not None:
try:
self.file_obj.close()
except Exception:
pass
self.file_obj = io_fits.get_fitsloader(logger=self.logger)
self.file_obj.open_file(path)
upper = len(self.file_obj) - 1
self.prep_hdu_menu(self.w.hdu, self.file_obj.hdu_info)
self.num_hdu = upper
self.logger.debug("there are %d hdus" % (upper + 1))
self.w.numhdu.set_text("%d" % (upper + 1))
self.w.hdu.set_enabled(len(self.file_obj) > 0)
name = image.get('name', iohelper.name_image_from_path(path))
idx = image.get('idx', None)
match = re.match(r'^(.+)\[(.+)\]$', name)
if match:
name = match.group(1)
self.name_pfx = name
htype = None
if idx is not None:
info = self.file_obj.hdu_db.get(idx, None)
if info is not None:
htype = info.htype.lower()
toc_ent = self._toc_fmt % info
self.w.hdu.show_text(toc_ent)
if self.img_name != name:
self.img_name = name
dims = [0, 0]
data = image.get_data()
if data is None:
self.logger.warning("Empty data part in HDU %s" % (str(idx)))
elif htype in ('bintablehdu', 'tablehdu',):
pass
elif htype not in ('imagehdu', 'primaryhdu', 'compimagehdu'):
self.logger.warning("HDU %s is not an image (%s)" % (
str(idx), htype))
else:
mddata = image.get_mddata()
if mddata is not None:
dims = list(mddata.shape)
dims.reverse()
self.build_naxis(dims, image) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_download_rtd_zip; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:rtd_version; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 35; 9, 46; 9, 63; 9, 75; 9, 87; 9, 99; 9, 114; 9, 135; 9, 152; 9, 209; 9, 216; 9, 237; 10, if_statement; 10, 11; 10, 20; 11, not_operator; 11, 12; 12, call; 12, 13; 12, 18; 13, attribute; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:toolkit; 16, identifier:family; 17, identifier:startswith; 18, argument_list; 18, 19; 19, string:'qt'; 20, block; 20, 21; 21, raise_statement; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:ValueError; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 31; 26, attribute; 26, 27; 26, 30; 27, concatenated_string; 27, 28; 27, 29; 28, string:'Downloaded documentation not compatible with {} '; 29, string:'UI toolkit browser'; 30, identifier:format; 31, argument_list; 31, 32; 32, attribute; 32, 33; 32, 34; 33, identifier:toolkit; 34, identifier:family; 35, if_statement; 35, 36; 35, 39; 36, comparison_operator:is; 36, 37; 36, 38; 37, identifier:rtd_version; 38, None; 39, block; 39, 40; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:rtd_version; 43, call; 43, 44; 43, 45; 44, identifier:_find_rtd_version; 45, argument_list; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:data_path; 49, call; 49, 50; 49, 55; 50, attribute; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:os; 53, identifier:path; 54, identifier:dirname; 55, argument_list; 55, 56; 56, call; 56, 57; 56, 58; 57, identifier:_find_pkg_data_path; 58, argument_list; 58, 59; 58, 60; 59, string:'help.html'; 60, keyword_argument; 60, 61; 60, 62; 61, identifier:package; 62, string:'ginga.doc'; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:index_html; 66, call; 66, 67; 66, 72; 67, attribute; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:os; 70, identifier:path; 71, identifier:join; 72, argument_list; 72, 73; 72, 74; 73, identifier:data_path; 74, string:'index.html'; 75, if_statement; 75, 76; 75, 84; 76, call; 76, 77; 76, 82; 77, attribute; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:os; 80, identifier:path; 81, identifier:isfile; 82, argument_list; 82, 83; 83, identifier:index_html; 84, block; 84, 85; 85, return_statement; 85, 86; 86, identifier:index_html; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:url; 90, parenthesized_expression; 90, 91; 91, call; 91, 92; 91, 97; 92, attribute; 92, 93; 92, 96; 93, concatenated_string; 93, 94; 93, 95; 94, string:'https://readthedocs.org/projects/ginga/downloads/htmlzip/'; 95, string:'{}/'; 96, identifier:format; 97, argument_list; 97, 98; 98, identifier:rtd_version; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:local_path; 102, subscript; 102, 103; 102, 113; 103, call; 103, 104; 103, 109; 104, attribute; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:urllib; 107, identifier:request; 108, identifier:urlretrieve; 109, argument_list; 109, 110; 109, 111; 110, identifier:url; 111, dictionary_splat; 111, 112; 112, identifier:kwargs; 113, integer:0; 114, with_statement; 114, 115; 114, 127; 115, with_clause; 115, 116; 116, with_item; 116, 117; 117, as_pattern; 117, 118; 117, 125; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:zipfile; 121, identifier:ZipFile; 122, argument_list; 122, 123; 122, 124; 123, identifier:local_path; 124, string:'r'; 125, as_pattern_target; 125, 126; 126, identifier:zf; 127, block; 127, 128; 128, expression_statement; 128, 129; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:zf; 132, identifier:extractall; 133, argument_list; 133, 134; 134, identifier:data_path; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:subdir; 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:join; 144, argument_list; 144, 145; 144, 146; 145, identifier:data_path; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, string:'ginga-{}'; 149, identifier:format; 150, argument_list; 150, 151; 151, identifier:rtd_version; 152, for_statement; 152, 153; 152, 154; 152, 160; 153, identifier:s; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:os; 157, identifier:listdir; 158, argument_list; 158, 159; 159, identifier:subdir; 160, block; 160, 161; 160, 173; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:src; 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:subdir; 172, identifier:s; 173, if_statement; 173, 174; 173, 182; 173, 191; 174, call; 174, 175; 174, 180; 175, attribute; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:os; 178, identifier:path; 179, identifier:isfile; 180, argument_list; 180, 181; 181, identifier:src; 182, block; 182, 183; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:shutil; 187, identifier:copy; 188, argument_list; 188, 189; 188, 190; 189, identifier:src; 190, identifier:data_path; 191, else_clause; 191, 192; 192, block; 192, 193; 193, expression_statement; 193, 194; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:shutil; 197, identifier:copytree; 198, argument_list; 198, 199; 198, 200; 199, identifier:src; 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:data_path; 208, identifier:s; 209, expression_statement; 209, 210; 210, call; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:shutil; 213, identifier:rmtree; 214, argument_list; 214, 215; 215, identifier:subdir; 216, if_statement; 216, 217; 216, 226; 217, not_operator; 217, 218; 218, call; 218, 219; 218, 224; 219, attribute; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:os; 222, identifier:path; 223, identifier:isfile; 224, argument_list; 224, 225; 225, identifier:index_html; 226, block; 226, 227; 227, raise_statement; 227, 228; 228, call; 228, 229; 228, 230; 229, identifier:OSError; 230, argument_list; 230, 231; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, string:'{} is missing; Ginga doc download failed'; 234, identifier:format; 235, argument_list; 235, 236; 236, identifier:index_html; 237, return_statement; 237, 238; 238, identifier:index_html | def _download_rtd_zip(rtd_version=None, **kwargs):
if not toolkit.family.startswith('qt'):
raise ValueError('Downloaded documentation not compatible with {} '
'UI toolkit browser'.format(toolkit.family))
if rtd_version is None:
rtd_version = _find_rtd_version()
data_path = os.path.dirname(
_find_pkg_data_path('help.html', package='ginga.doc'))
index_html = os.path.join(data_path, 'index.html')
if os.path.isfile(index_html):
return index_html
url = ('https://readthedocs.org/projects/ginga/downloads/htmlzip/'
'{}/'.format(rtd_version))
local_path = urllib.request.urlretrieve(url, **kwargs)[0]
with zipfile.ZipFile(local_path, 'r') as zf:
zf.extractall(data_path)
subdir = os.path.join(data_path, 'ginga-{}'.format(rtd_version))
for s in os.listdir(subdir):
src = os.path.join(subdir, s)
if os.path.isfile(src):
shutil.copy(src, data_path)
else:
shutil.copytree(src, os.path.join(data_path, s))
shutil.rmtree(subdir)
if not os.path.isfile(index_html):
raise OSError(
'{} is missing; Ginga doc download failed'.format(index_html))
return index_html |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_doc; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:logger; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:plugin; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:reporthook; 12, None; 13, block; 13, 14; 13, 22; 13, 68; 13, 158; 14, import_from_statement; 14, 15; 14, 18; 14, 20; 15, dotted_name; 15, 16; 15, 17; 16, identifier:ginga; 17, identifier:GingaPlugin; 18, dotted_name; 18, 19; 19, identifier:GlobalPlugin; 20, dotted_name; 20, 21; 21, identifier:LocalPlugin; 22, if_statement; 22, 23; 22, 28; 22, 40; 22, 58; 23, call; 23, 24; 23, 25; 24, identifier:isinstance; 25, argument_list; 25, 26; 25, 27; 26, identifier:plugin; 27, identifier:GlobalPlugin; 28, block; 28, 29; 28, 33; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:plugin_page; 32, string:'plugins_global'; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:plugin_name; 36, call; 36, 37; 36, 38; 37, identifier:str; 38, argument_list; 38, 39; 39, identifier:plugin; 40, elif_clause; 40, 41; 40, 46; 41, call; 41, 42; 41, 43; 42, identifier:isinstance; 43, argument_list; 43, 44; 43, 45; 44, identifier:plugin; 45, identifier:LocalPlugin; 46, block; 46, 47; 46, 51; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:plugin_page; 50, string:'plugins_local'; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:plugin_name; 54, call; 54, 55; 54, 56; 55, identifier:str; 56, argument_list; 56, 57; 57, identifier:plugin; 58, else_clause; 58, 59; 59, block; 59, 60; 59, 64; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:plugin_page; 63, None; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:plugin_name; 67, None; 68, try_statement; 68, 69; 68, 79; 68, 135; 69, block; 69, 70; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:index_html; 73, call; 73, 74; 73, 75; 74, identifier:_download_rtd_zip; 75, argument_list; 75, 76; 76, keyword_argument; 76, 77; 76, 78; 77, identifier:reporthook; 78, identifier:reporthook; 79, except_clause; 79, 80; 79, 84; 80, as_pattern; 80, 81; 80, 82; 81, identifier:Exception; 82, as_pattern_target; 82, 83; 83, identifier:e; 84, block; 84, 85; 84, 89; 84, 120; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:url; 88, string:'https://ginga.readthedocs.io/en/latest/'; 89, if_statement; 89, 90; 89, 93; 90, comparison_operator:is; 90, 91; 90, 92; 91, identifier:plugin_name; 92, None; 93, block; 93, 94; 94, if_statement; 94, 95; 94, 103; 94, 108; 95, call; 95, 96; 95, 101; 96, attribute; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:toolkit; 99, identifier:family; 100, identifier:startswith; 101, argument_list; 101, 102; 102, string:'qt'; 103, block; 103, 104; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:url; 107, None; 108, else_clause; 108, 109; 109, block; 109, 110; 110, expression_statement; 110, 111; 111, augmented_assignment:+=; 111, 112; 111, 113; 112, identifier:url; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, string:'manual/{}/{}.html'; 116, identifier:format; 117, argument_list; 117, 118; 117, 119; 118, identifier:plugin_page; 119, identifier:plugin_name; 120, if_statement; 120, 121; 120, 124; 121, comparison_operator:is; 121, 122; 121, 123; 122, identifier:logger; 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:logger; 129, identifier:error; 130, argument_list; 130, 131; 131, call; 131, 132; 131, 133; 132, identifier:str; 133, argument_list; 133, 134; 134, identifier:e; 135, else_clause; 135, 136; 136, block; 136, 137; 136, 141; 136, 151; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:pfx; 140, string:'file:'; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:url; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, string:'{}{}'; 147, identifier:format; 148, argument_list; 148, 149; 148, 150; 149, identifier:pfx; 150, identifier:index_html; 151, if_statement; 151, 152; 151, 155; 151, 157; 152, comparison_operator:is; 152, 153; 152, 154; 153, identifier:plugin_name; 154, None; 155, ERROR; 155, 156; 156, identifier:url; 157, block:; 158, return_statement; 158, 159; 159, identifier:url | def get_doc(logger=None, plugin=None, reporthook=None):
from ginga.GingaPlugin import GlobalPlugin, LocalPlugin
if isinstance(plugin, GlobalPlugin):
plugin_page = 'plugins_global'
plugin_name = str(plugin)
elif isinstance(plugin, LocalPlugin):
plugin_page = 'plugins_local'
plugin_name = str(plugin)
else:
plugin_page = None
plugin_name = None
try:
index_html = _download_rtd_zip(reporthook=reporthook)
except Exception as e:
url = 'https://ginga.readthedocs.io/en/latest/'
if plugin_name is not None:
if toolkit.family.startswith('qt'):
url = None
else:
url += 'manual/{}/{}.html'.format(plugin_page, plugin_name)
if logger is not None:
logger.error(str(e))
else:
pfx = 'file:'
url = '{}{}'.format(pfx, index_html)
if plugin_name is not None:
url += '
return url |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:redo; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, block; 7, 8; 7, 15; 7, 27; 7, 35; 7, 43; 7, 54; 7, 67; 7, 73; 7, 99; 7, 321; 7, 330; 7, 337; 8, if_statement; 8, 9; 8, 13; 9, not_operator; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:gui_up; 13, block; 13, 14; 14, return_statement; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:mod_only; 18, call; 18, 19; 18, 26; 19, attribute; 19, 20; 19, 25; 20, attribute; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:w; 24, identifier:modified_only; 25, identifier:get_state; 26, argument_list; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:treedict; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:Bunch; 33, identifier:caselessDict; 34, argument_list; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 42; 37, attribute; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:treeview; 41, identifier:clear; 42, argument_list; 43, expression_statement; 43, 44; 44, call; 44, 45; 44, 52; 45, attribute; 45, 46; 45, 51; 46, attribute; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:w; 50, identifier:status; 51, identifier:set_text; 52, argument_list; 52, 53; 53, string:''; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:channel; 57, call; 57, 58; 57, 63; 58, attribute; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:fv; 62, identifier:get_channel; 63, argument_list; 63, 64; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:chname; 67, if_statement; 67, 68; 67, 71; 68, comparison_operator:is; 68, 69; 68, 70; 69, identifier:channel; 70, None; 71, block; 71, 72; 72, return_statement; 73, if_statement; 73, 74; 73, 75; 73, 89; 74, identifier:mod_only; 75, block; 75, 76; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:all_keys; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:channel; 83, identifier:datasrc; 84, identifier:keys; 85, argument_list; 85, 86; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:sort; 88, string:'alpha'; 89, else_clause; 89, 90; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:all_keys; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:channel; 97, identifier:get_image_names; 98, argument_list; 99, for_statement; 99, 100; 99, 101; 99, 102; 100, identifier:key; 101, identifier:all_keys; 102, block; 102, 103; 102, 112; 102, 121; 102, 130; 102, 139; 102, 199; 102, 204; 102, 212; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:iminfo; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:channel; 109, identifier:get_image_info; 110, argument_list; 110, 111; 111, identifier:key; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:path; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:iminfo; 118, identifier:get; 119, argument_list; 119, 120; 120, string:'path'; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:idx; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:iminfo; 127, identifier:get; 128, argument_list; 128, 129; 129, string:'idx'; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:t; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:iminfo; 136, identifier:get; 137, argument_list; 137, 138; 138, string:'time_modified'; 139, if_statement; 139, 140; 139, 143; 139, 152; 140, comparison_operator:is; 140, 141; 140, 142; 141, identifier:path; 142, None; 143, block; 143, 144; 143, 148; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:infile; 147, identifier:key; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:is_fits; 151, True; 152, else_clause; 152, 153; 153, block; 153, 154; 153, 165; 153, 178; 153, 186; 153, 190; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:infile; 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:basename; 163, argument_list; 163, 164; 164, identifier:path; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:infile_ext; 168, subscript; 168, 169; 168, 177; 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:splitext; 175, argument_list; 175, 176; 176, identifier:path; 177, integer:1; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:infile_ext; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:infile_ext; 184, identifier:lower; 185, argument_list; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:is_fits; 189, False; 190, if_statement; 190, 191; 190, 194; 191, comparison_operator:in; 191, 192; 191, 193; 192, string:'fit'; 193, identifier:infile_ext; 194, block; 194, 195; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 198; 197, identifier:is_fits; 198, True; 199, if_statement; 199, 200; 199, 202; 200, not_operator; 200, 201; 201, identifier:is_fits; 202, block; 202, 203; 203, continue_statement; 204, if_statement; 204, 205; 204, 210; 205, boolean_operator:and; 205, 206; 205, 207; 206, identifier:mod_only; 207, comparison_operator:is; 207, 208; 207, 209; 208, identifier:t; 209, None; 210, block; 210, 211; 211, continue_statement; 212, if_statement; 212, 213; 212, 216; 212, 263; 213, comparison_operator:in; 213, 214; 213, 215; 214, identifier:infile; 215, identifier:treedict; 216, block; 216, 217; 217, if_statement; 217, 218; 217, 221; 218, comparison_operator:is; 218, 219; 218, 220; 219, identifier:t; 220, None; 221, block; 221, 222; 221, 233; 221, 244; 222, expression_statement; 222, 223; 223, call; 223, 224; 223, 231; 224, attribute; 224, 225; 224, 230; 225, attribute; 225, 226; 225, 229; 226, subscript; 226, 227; 226, 228; 227, identifier:treedict; 228, identifier:infile; 229, identifier:extlist; 230, identifier:add; 231, argument_list; 231, 232; 232, identifier:idx; 233, expression_statement; 233, 234; 234, assignment; 234, 235; 234, 236; 235, identifier:elist; 236, call; 236, 237; 236, 238; 237, identifier:sorted; 238, argument_list; 238, 239; 239, attribute; 239, 240; 239, 243; 240, subscript; 240, 241; 240, 242; 241, identifier:treedict; 242, identifier:infile; 243, identifier:extlist; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 251; 246, attribute; 246, 247; 246, 250; 247, subscript; 247, 248; 247, 249; 248, identifier:treedict; 249, identifier:infile; 250, identifier:MODEXT; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, string:';'; 254, identifier:join; 255, argument_list; 255, 256; 256, call; 256, 257; 256, 258; 257, identifier:map; 258, argument_list; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:self; 261, identifier:_format_extname; 262, identifier:elist; 263, else_clause; 263, 264; 264, block; 264, 265; 264, 299; 265, if_statement; 265, 266; 265, 269; 265, 280; 266, comparison_operator:is; 266, 267; 266, 268; 267, identifier:t; 268, None; 269, block; 269, 270; 269, 274; 270, expression_statement; 270, 271; 271, assignment; 271, 272; 271, 273; 272, identifier:s; 273, string:''; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:extlist; 277, call; 277, 278; 277, 279; 278, identifier:set; 279, argument_list; 280, else_clause; 280, 281; 281, block; 281, 282; 281, 291; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:s; 285, call; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, identifier:self; 288, identifier:_format_extname; 289, argument_list; 289, 290; 290, identifier:idx; 291, expression_statement; 291, 292; 292, assignment; 292, 293; 292, 294; 293, identifier:extlist; 294, call; 294, 295; 294, 296; 295, identifier:set; 296, argument_list; 296, 297; 297, list:[idx]; 297, 298; 298, identifier:idx; 299, expression_statement; 299, 300; 300, assignment; 300, 301; 300, 304; 301, subscript; 301, 302; 301, 303; 302, identifier:treedict; 303, identifier:infile; 304, call; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:Bunch; 307, identifier:Bunch; 308, argument_list; 308, 309; 308, 312; 308, 315; 308, 318; 309, keyword_argument; 309, 310; 309, 311; 310, identifier:IMAGE; 311, identifier:infile; 312, keyword_argument; 312, 313; 312, 314; 313, identifier:MODEXT; 314, identifier:s; 315, keyword_argument; 315, 316; 315, 317; 316, identifier:extlist; 317, identifier:extlist; 318, keyword_argument; 318, 319; 318, 320; 319, identifier:path; 320, identifier:path; 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:self; 326, identifier:treeview; 327, identifier:set_tree; 328, argument_list; 328, 329; 329, identifier:treedict; 330, expression_statement; 330, 331; 331, assignment; 331, 332; 331, 333; 332, identifier:n_rows; 333, call; 333, 334; 333, 335; 334, identifier:len; 335, argument_list; 335, 336; 336, identifier:treedict; 337, if_statement; 337, 338; 337, 341; 337, 353; 338, comparison_operator:==; 338, 339; 338, 340; 339, identifier:n_rows; 340, integer:0; 341, block; 341, 342; 342, expression_statement; 342, 343; 343, call; 343, 344; 343, 351; 344, attribute; 344, 345; 344, 350; 345, attribute; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:self; 348, identifier:w; 349, identifier:status; 350, identifier:set_text; 351, argument_list; 351, 352; 352, string:'Nothing available for saving'; 353, elif_clause; 353, 354; 353, 365; 354, comparison_operator:<; 354, 355; 354, 356; 355, identifier:n_rows; 356, call; 356, 357; 356, 362; 357, attribute; 357, 358; 357, 361; 358, attribute; 358, 359; 358, 360; 359, identifier:self; 360, identifier:settings; 361, identifier:get; 362, argument_list; 362, 363; 362, 364; 363, string:'max_rows_for_col_resize'; 364, integer:5000; 365, block; 365, 366; 365, 374; 366, expression_statement; 366, 367; 367, call; 367, 368; 367, 373; 368, attribute; 368, 369; 368, 372; 369, attribute; 369, 370; 369, 371; 370, identifier:self; 371, identifier:treeview; 372, identifier:set_optimal_column_widths; 373, argument_list; 374, expression_statement; 374, 375; 375, call; 375, 376; 375, 381; 376, attribute; 376, 377; 376, 380; 377, attribute; 377, 378; 377, 379; 378, identifier:self; 379, identifier:logger; 380, identifier:debug; 381, argument_list; 381, 382; 382, call; 382, 383; 382, 386; 383, attribute; 383, 384; 383, 385; 384, string:'Resized columns for {0} row(s)'; 385, identifier:format; 386, argument_list; 386, 387; 387, identifier:n_rows | def redo(self, *args):
if not self.gui_up:
return
mod_only = self.w.modified_only.get_state()
treedict = Bunch.caselessDict()
self.treeview.clear()
self.w.status.set_text('')
channel = self.fv.get_channel(self.chname)
if channel is None:
return
if mod_only:
all_keys = channel.datasrc.keys(sort='alpha')
else:
all_keys = channel.get_image_names()
for key in all_keys:
iminfo = channel.get_image_info(key)
path = iminfo.get('path')
idx = iminfo.get('idx')
t = iminfo.get('time_modified')
if path is None:
infile = key
is_fits = True
else:
infile = os.path.basename(path)
infile_ext = os.path.splitext(path)[1]
infile_ext = infile_ext.lower()
is_fits = False
if 'fit' in infile_ext:
is_fits = True
if not is_fits:
continue
if mod_only and t is None:
continue
if infile in treedict:
if t is not None:
treedict[infile].extlist.add(idx)
elist = sorted(treedict[infile].extlist)
treedict[infile].MODEXT = ';'.join(
map(self._format_extname, elist))
else:
if t is None:
s = ''
extlist = set()
else:
s = self._format_extname(idx)
extlist = set([idx])
treedict[infile] = Bunch.Bunch(
IMAGE=infile, MODEXT=s, extlist=extlist, path=path)
self.treeview.set_tree(treedict)
n_rows = len(treedict)
if n_rows == 0:
self.w.status.set_text('Nothing available for saving')
elif n_rows < self.settings.get('max_rows_for_col_resize', 5000):
self.treeview.set_optimal_column_widths()
self.logger.debug('Resized columns for {0} row(s)'.format(n_rows)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_imload; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:filepath; 6, identifier:kwds; 7, block; 7, 8; 7, 16; 7, 27; 7, 35; 7, 46; 7, 59; 7, 63; 7, 170; 7, 323; 7, 360; 7, 373; 7, 381; 7, 396; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:start_time; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:time; 14, identifier:time; 15, argument_list; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 21; 18, pattern_list; 18, 19; 18, 20; 19, identifier:typ; 20, identifier:enc; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:mimetypes; 24, identifier:guess_type; 25, argument_list; 25, 26; 26, identifier:filepath; 27, if_statement; 27, 28; 27, 30; 28, not_operator; 28, 29; 29, identifier:typ; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:typ; 34, string:'image/jpeg'; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 40; 37, pattern_list; 37, 38; 37, 39; 38, identifier:typ; 39, identifier:subtyp; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:typ; 43, identifier:split; 44, argument_list; 44, 45; 45, string:'/'; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 53; 48, attribute; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:logger; 52, identifier:debug; 53, argument_list; 53, 54; 54, binary_operator:%; 54, 55; 54, 56; 55, string:"MIME type is %s/%s"; 56, tuple; 56, 57; 56, 58; 57, identifier:typ; 58, identifier:subtyp; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:data_loaded; 62, False; 63, if_statement; 63, 64; 63, 70; 64, boolean_operator:and; 64, 65; 64, 66; 65, identifier:have_opencv; 66, comparison_operator:not; 66, 67; 66, 68; 67, identifier:subtyp; 68, list:['gif']; 68, 69; 69, string:'gif'; 70, block; 70, 71; 70, 75; 70, 91; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:means; 74, string:'opencv'; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:data_np; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:cv2; 81, identifier:imread; 82, argument_list; 82, 83; 82, 84; 83, identifier:filepath; 84, binary_operator:+; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:cv2; 87, identifier:IMREAD_ANYDEPTH; 88, attribute; 88, 89; 88, 90; 89, identifier:cv2; 90, identifier:IMREAD_ANYCOLOR; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:is; 92, 93; 92, 94; 93, identifier:data_np; 94, None; 95, block; 95, 96; 95, 100; 95, 129; 95, 137; 95, 143; 95, 149; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:data_loaded; 99, True; 100, if_statement; 100, 101; 100, 117; 101, boolean_operator:and; 101, 102; 101, 110; 102, comparison_operator:>=; 102, 103; 102, 109; 103, call; 103, 104; 103, 105; 104, identifier:len; 105, argument_list; 105, 106; 106, attribute; 106, 107; 106, 108; 107, identifier:data_np; 108, identifier:shape; 109, integer:3; 110, comparison_operator:>=; 110, 111; 110, 116; 111, subscript; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:data_np; 114, identifier:shape; 115, integer:2; 116, integer:3; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 121; 120, identifier:data_np; 121, subscript; 121, 122; 121, 123; 121, 124; 122, identifier:data_np; 123, ellipsis:...; 124, slice; 124, 125; 124, 126; 124, 127; 125, colon; 126, colon; 127, unary_operator:-; 127, 128; 128, integer:1; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:self; 133, identifier:piexif_getexif; 134, argument_list; 134, 135; 134, 136; 135, identifier:filepath; 136, identifier:kwds; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 142; 139, subscript; 139, 140; 139, 141; 140, identifier:kwds; 141, string:'Orientation'; 142, integer:1; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, subscript; 145, 146; 145, 147; 146, identifier:kwds; 147, string:'Image Orientation'; 148, integer:1; 149, if_statement; 149, 150; 149, 157; 150, call; 150, 151; 150, 156; 151, attribute; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:clr_mgr; 155, identifier:can_profile; 156, argument_list; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:data_np; 161, call; 161, 162; 161, 167; 162, attribute; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:self; 165, identifier:clr_mgr; 166, identifier:profile_to_working_numpy; 167, argument_list; 167, 168; 167, 169; 168, identifier:data_np; 169, identifier:kwds; 170, if_statement; 170, 171; 170, 175; 171, boolean_operator:and; 171, 172; 171, 174; 172, not_operator; 172, 173; 173, identifier:data_loaded; 174, identifier:have_pil; 175, block; 175, 176; 175, 180; 175, 189; 175, 284; 175, 305; 175, 314; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:means; 179, string:'PIL'; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:image; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:PILimage; 186, identifier:open; 187, argument_list; 187, 188; 188, identifier:filepath; 189, try_statement; 189, 190; 189, 263; 190, block; 190, 191; 191, if_statement; 191, 192; 191, 197; 191, 237; 191, 252; 192, call; 192, 193; 192, 194; 193, identifier:hasattr; 194, argument_list; 194, 195; 194, 196; 195, identifier:image; 196, string:'_getexif'; 197, block; 197, 198; 197, 206; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:info; 201, call; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:image; 204, identifier:_getexif; 205, argument_list; 206, if_statement; 206, 207; 206, 210; 207, comparison_operator:is; 207, 208; 207, 209; 208, identifier:info; 209, None; 210, block; 210, 211; 211, for_statement; 211, 212; 211, 215; 211, 220; 212, pattern_list; 212, 213; 212, 214; 213, identifier:tag; 214, identifier:value; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:info; 218, identifier:items; 219, argument_list; 220, block; 220, 221; 220, 231; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:kwd; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:TAGS; 227, identifier:get; 228, argument_list; 228, 229; 228, 230; 229, identifier:tag; 230, identifier:tag; 231, expression_statement; 231, 232; 232, assignment; 232, 233; 232, 236; 233, subscript; 233, 234; 233, 235; 234, identifier:kwds; 235, identifier:kwd; 236, identifier:value; 237, elif_clause; 237, 238; 237, 239; 238, identifier:have_exif; 239, block; 239, 240; 240, expression_statement; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:self; 244, identifier:piexif_getexif; 245, argument_list; 245, 246; 245, 251; 246, subscript; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:image; 249, identifier:info; 250, string:"exif"; 251, identifier:kwds; 252, else_clause; 252, 253; 253, block; 253, 254; 254, expression_statement; 254, 255; 255, call; 255, 256; 255, 261; 256, attribute; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:self; 259, identifier:logger; 260, identifier:warning; 261, argument_list; 261, 262; 262, string:"Please install 'piexif' module to get image metadata"; 263, except_clause; 263, 264; 263, 268; 264, as_pattern; 264, 265; 264, 266; 265, identifier:Exception; 266, as_pattern_target; 266, 267; 267, identifier:e; 268, block; 268, 269; 269, expression_statement; 269, 270; 270, call; 270, 271; 270, 276; 271, attribute; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:self; 274, identifier:logger; 275, identifier:warning; 276, argument_list; 276, 277; 277, binary_operator:%; 277, 278; 277, 279; 278, string:"Failed to get image metadata: %s"; 279, parenthesized_expression; 279, 280; 280, call; 280, 281; 280, 282; 281, identifier:str; 282, argument_list; 282, 283; 283, identifier:e; 284, if_statement; 284, 285; 284, 292; 285, call; 285, 286; 285, 291; 286, attribute; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:self; 289, identifier:clr_mgr; 290, identifier:can_profile; 291, argument_list; 292, block; 292, 293; 293, expression_statement; 293, 294; 294, assignment; 294, 295; 294, 296; 295, identifier:image; 296, call; 296, 297; 296, 302; 297, attribute; 297, 298; 297, 301; 298, attribute; 298, 299; 298, 300; 299, identifier:self; 300, identifier:clr_mgr; 301, identifier:profile_to_working_pil; 302, argument_list; 302, 303; 302, 304; 303, identifier:image; 304, identifier:kwds; 305, expression_statement; 305, 306; 306, assignment; 306, 307; 306, 308; 307, identifier:data_np; 308, call; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:np; 311, identifier:array; 312, argument_list; 312, 313; 313, identifier:image; 314, if_statement; 314, 315; 314, 318; 315, comparison_operator:is; 315, 316; 315, 317; 316, identifier:data_np; 317, None; 318, block; 318, 319; 319, expression_statement; 319, 320; 320, assignment; 320, 321; 320, 322; 321, identifier:data_loaded; 322, True; 323, if_statement; 323, 324; 323, 339; 324, parenthesized_expression; 324, 325; 325, boolean_operator:and; 325, 326; 325, 333; 326, boolean_operator:and; 326, 327; 326, 329; 327, not_operator; 327, 328; 328, identifier:data_loaded; 329, parenthesized_expression; 329, 330; 330, comparison_operator:==; 330, 331; 330, 332; 331, identifier:typ; 332, string:'image'; 333, parenthesized_expression; 333, 334; 334, comparison_operator:in; 334, 335; 334, 336; 335, identifier:subtyp; 336, tuple; 336, 337; 336, 338; 337, string:'x-portable-pixmap'; 338, string:'x-portable-greymap'; 339, block; 339, 340; 339, 344; 339, 351; 340, expression_statement; 340, 341; 341, assignment; 341, 342; 341, 343; 342, identifier:means; 343, string:'built-in'; 344, expression_statement; 344, 345; 345, assignment; 345, 346; 345, 347; 346, identifier:data_np; 347, call; 347, 348; 347, 349; 348, identifier:open_ppm; 349, argument_list; 349, 350; 350, identifier:filepath; 351, if_statement; 351, 352; 351, 355; 352, comparison_operator:is; 352, 353; 352, 354; 353, identifier:data_np; 354, None; 355, block; 355, 356; 356, expression_statement; 356, 357; 357, assignment; 357, 358; 357, 359; 358, identifier:data_loaded; 359, True; 360, if_statement; 360, 361; 360, 363; 361, not_operator; 361, 362; 362, identifier:data_loaded; 363, block; 363, 364; 364, raise_statement; 364, 365; 365, call; 365, 366; 365, 367; 366, identifier:ImageError; 367, argument_list; 367, 368; 368, binary_operator:%; 368, 369; 368, 370; 369, string:"No way to load image format '%s/%s'"; 370, tuple; 370, 371; 370, 372; 371, identifier:typ; 372, identifier:subtyp; 373, expression_statement; 373, 374; 374, assignment; 374, 375; 374, 376; 375, identifier:end_time; 376, call; 376, 377; 376, 380; 377, attribute; 377, 378; 377, 379; 378, identifier:time; 379, identifier:time; 380, argument_list; 381, expression_statement; 381, 382; 382, call; 382, 383; 382, 388; 383, attribute; 383, 384; 383, 387; 384, attribute; 384, 385; 384, 386; 385, identifier:self; 386, identifier:logger; 387, identifier:debug; 388, argument_list; 388, 389; 389, binary_operator:%; 389, 390; 389, 391; 390, string:"loading (%s) time %.4f sec"; 391, tuple; 391, 392; 391, 393; 392, identifier:means; 393, binary_operator:-; 393, 394; 393, 395; 394, identifier:end_time; 395, identifier:start_time; 396, return_statement; 396, 397; 397, identifier:data_np | def _imload(self, filepath, kwds):
start_time = time.time()
typ, enc = mimetypes.guess_type(filepath)
if not typ:
typ = 'image/jpeg'
typ, subtyp = typ.split('/')
self.logger.debug("MIME type is %s/%s" % (typ, subtyp))
data_loaded = False
if have_opencv and subtyp not in ['gif']:
means = 'opencv'
data_np = cv2.imread(filepath,
cv2.IMREAD_ANYDEPTH + cv2.IMREAD_ANYCOLOR)
if data_np is not None:
data_loaded = True
if len(data_np.shape) >= 3 and data_np.shape[2] >= 3:
data_np = data_np[..., :: -1]
self.piexif_getexif(filepath, kwds)
kwds['Orientation'] = 1
kwds['Image Orientation'] = 1
if self.clr_mgr.can_profile():
data_np = self.clr_mgr.profile_to_working_numpy(data_np, kwds)
if not data_loaded and have_pil:
means = 'PIL'
image = PILimage.open(filepath)
try:
if hasattr(image, '_getexif'):
info = image._getexif()
if info is not None:
for tag, value in info.items():
kwd = TAGS.get(tag, tag)
kwds[kwd] = value
elif have_exif:
self.piexif_getexif(image.info["exif"], kwds)
else:
self.logger.warning("Please install 'piexif' module to get image metadata")
except Exception as e:
self.logger.warning("Failed to get image metadata: %s" % (str(e)))
if self.clr_mgr.can_profile():
image = self.clr_mgr.profile_to_working_pil(image, kwds)
data_np = np.array(image)
if data_np is not None:
data_loaded = True
if (not data_loaded and (typ == 'image') and
(subtyp in ('x-portable-pixmap', 'x-portable-greymap'))):
means = 'built-in'
data_np = open_ppm(filepath)
if data_np is not None:
data_loaded = True
if not data_loaded:
raise ImageError("No way to load image format '%s/%s'" % (
typ, subtyp))
end_time = time.time()
self.logger.debug("loading (%s) time %.4f sec" % (
means, end_time - start_time))
return data_np |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_coord_system_name; 3, parameters; 3, 4; 4, identifier:header; 5, block; 5, 6; 5, 77; 5, 87; 5, 92; 5, 102; 5, 107; 5, 117; 5, 197; 5, 207; 5, 212; 5, 222; 5, 227; 5, 237; 5, 242; 5, 252; 5, 257; 6, try_statement; 6, 7; 6, 22; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:ctype; 11, call; 11, 12; 11, 21; 12, attribute; 12, 13; 12, 20; 13, call; 13, 14; 13, 19; 14, attribute; 14, 15; 14, 18; 15, subscript; 15, 16; 15, 17; 16, identifier:header; 17, string:'CTYPE1'; 18, identifier:strip; 19, argument_list; 20, identifier:upper; 21, argument_list; 22, except_clause; 22, 23; 22, 24; 23, identifier:KeyError; 24, block; 24, 25; 25, try_statement; 25, 26; 25, 72; 26, block; 26, 27; 26, 33; 26, 66; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:ra; 30, subscript; 30, 31; 30, 32; 31, identifier:header; 32, string:'RA'; 33, try_statement; 33, 34; 33, 59; 34, block; 34, 35; 34, 44; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:equinox; 38, call; 38, 39; 38, 40; 39, identifier:float; 40, argument_list; 40, 41; 41, subscript; 41, 42; 41, 43; 42, identifier:header; 43, string:'EQUINOX'; 44, if_statement; 44, 45; 44, 48; 44, 53; 45, comparison_operator:<; 45, 46; 45, 47; 46, identifier:equinox; 47, float:1984.0; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:radecsys; 52, string:'FK4'; 53, else_clause; 53, 54; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:radecsys; 58, string:'FK5'; 59, except_clause; 59, 60; 59, 61; 60, identifier:KeyError; 61, block; 61, 62; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:radecsys; 65, string:'ICRS'; 66, return_statement; 66, 67; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:radecsys; 70, identifier:lower; 71, argument_list; 72, except_clause; 72, 73; 72, 74; 73, identifier:KeyError; 74, block; 74, 75; 75, return_statement; 75, 76; 76, string:'raw'; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:match; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:re; 83, identifier:match; 84, argument_list; 84, 85; 84, 86; 85, string:r'^GLON\-.*$'; 86, identifier:ctype; 87, if_statement; 87, 88; 87, 89; 88, identifier:match; 89, block; 89, 90; 90, return_statement; 90, 91; 91, string:'galactic'; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:match; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:re; 98, identifier:match; 99, argument_list; 99, 100; 99, 101; 100, string:r'^ELON\-.*$'; 101, identifier:ctype; 102, if_statement; 102, 103; 102, 104; 103, identifier:match; 104, block; 104, 105; 105, return_statement; 105, 106; 106, string:'ecliptic'; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:match; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:re; 113, identifier:match; 114, argument_list; 114, 115; 114, 116; 115, string:r'^RA\-\-\-.*$'; 116, identifier:ctype; 117, if_statement; 117, 118; 117, 119; 118, identifier:match; 119, block; 119, 120; 119, 124; 119, 183; 119, 191; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:hdkey; 123, string:'RADECSYS'; 124, try_statement; 124, 125; 124, 132; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:radecsys; 129, subscript; 129, 130; 129, 131; 130, identifier:header; 131, identifier:hdkey; 132, except_clause; 132, 133; 132, 134; 133, identifier:KeyError; 134, block; 134, 135; 135, try_statement; 135, 136; 135, 147; 136, block; 136, 137; 136, 141; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:hdkey; 140, string:'RADESYS'; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:radecsys; 144, subscript; 144, 145; 144, 146; 145, identifier:header; 146, identifier:hdkey; 147, except_clause; 147, 148; 147, 149; 148, identifier:KeyError; 149, block; 149, 150; 150, try_statement; 150, 151; 150, 176; 151, block; 151, 152; 151, 161; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:equinox; 155, call; 155, 156; 155, 157; 156, identifier:float; 157, argument_list; 157, 158; 158, subscript; 158, 159; 158, 160; 159, identifier:header; 160, string:'EQUINOX'; 161, if_statement; 161, 162; 161, 165; 161, 170; 162, comparison_operator:<; 162, 163; 162, 164; 163, identifier:equinox; 164, float:1984.0; 165, block; 165, 166; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 169; 168, identifier:radecsys; 169, string:'FK4'; 170, else_clause; 170, 171; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:radecsys; 175, string:'FK5'; 176, except_clause; 176, 177; 176, 178; 177, identifier:KeyError; 178, block; 178, 179; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:radecsys; 182, string:'ICRS'; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 186; 185, identifier:radecsys; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:radecsys; 189, identifier:strip; 190, argument_list; 191, return_statement; 191, 192; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:radecsys; 195, identifier:lower; 196, argument_list; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:match; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:re; 203, identifier:match; 204, argument_list; 204, 205; 204, 206; 205, string:r'^HPLN\-.*$'; 206, identifier:ctype; 207, if_statement; 207, 208; 207, 209; 208, identifier:match; 209, block; 209, 210; 210, return_statement; 210, 211; 211, string:'helioprojective'; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:match; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:re; 218, identifier:match; 219, argument_list; 219, 220; 219, 221; 220, string:r'^HGLT\-.*$'; 221, identifier:ctype; 222, if_statement; 222, 223; 222, 224; 223, identifier:match; 224, block; 224, 225; 225, return_statement; 225, 226; 226, string:'heliographicstonyhurst'; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:match; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:re; 233, identifier:match; 234, argument_list; 234, 235; 234, 236; 235, string:r'^PIXEL$'; 236, identifier:ctype; 237, if_statement; 237, 238; 237, 239; 238, identifier:match; 239, block; 239, 240; 240, return_statement; 240, 241; 241, string:'pixel'; 242, expression_statement; 242, 243; 243, assignment; 243, 244; 243, 245; 244, identifier:match; 245, call; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, identifier:re; 248, identifier:match; 249, argument_list; 249, 250; 249, 251; 250, string:r'^LINEAR$'; 251, identifier:ctype; 252, if_statement; 252, 253; 252, 254; 253, identifier:match; 254, block; 254, 255; 255, return_statement; 255, 256; 256, string:'pixel'; 257, return_statement; 257, 258; 258, string:'icrs' | def get_coord_system_name(header):
try:
ctype = header['CTYPE1'].strip().upper()
except KeyError:
try:
ra = header['RA']
try:
equinox = float(header['EQUINOX'])
if equinox < 1984.0:
radecsys = 'FK4'
else:
radecsys = 'FK5'
except KeyError:
radecsys = 'ICRS'
return radecsys.lower()
except KeyError:
return 'raw'
match = re.match(r'^GLON\-.*$', ctype)
if match:
return 'galactic'
match = re.match(r'^ELON\-.*$', ctype)
if match:
return 'ecliptic'
match = re.match(r'^RA\-\-\-.*$', ctype)
if match:
hdkey = 'RADECSYS'
try:
radecsys = header[hdkey]
except KeyError:
try:
hdkey = 'RADESYS'
radecsys = header[hdkey]
except KeyError:
try:
equinox = float(header['EQUINOX'])
if equinox < 1984.0:
radecsys = 'FK4'
else:
radecsys = 'FK5'
except KeyError:
radecsys = 'ICRS'
radecsys = radecsys.strip()
return radecsys.lower()
match = re.match(r'^HPLN\-.*$', ctype)
if match:
return 'helioprojective'
match = re.match(r'^HGLT\-.*$', ctype)
if match:
return 'heliographicstonyhurst'
match = re.match(r'^PIXEL$', ctype)
if match:
return 'pixel'
match = re.match(r'^LINEAR$', ctype)
if match:
return 'pixel'
return 'icrs' |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_do_info; 3, parameters; 3, 4; 3, 5; 4, identifier:bz; 5, identifier:opt; 6, block; 6, 7; 6, 43; 6, 58; 6, 64; 6, 76; 6, 86; 6, 97; 6, 119; 6, 136; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:_filter_components; 9, parameters; 9, 10; 10, identifier:compdetails; 11, block; 11, 12; 11, 16; 11, 41; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:ret; 15, dictionary; 16, for_statement; 16, 17; 16, 20; 16, 25; 17, pattern_list; 17, 18; 17, 19; 18, identifier:k; 19, identifier:v; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:compdetails; 23, identifier:items; 24, argument_list; 25, block; 25, 26; 26, if_statement; 26, 27; 26, 34; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:v; 30, identifier:get; 31, argument_list; 31, 32; 31, 33; 32, string:"is_active"; 33, True; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 40; 37, subscript; 37, 38; 37, 39; 38, identifier:ret; 39, identifier:k; 40, identifier:v; 41, return_statement; 41, 42; 42, identifier:ret; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:productname; 46, parenthesized_expression; 46, 47; 47, boolean_operator:or; 47, 48; 47, 55; 48, boolean_operator:or; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:opt; 51, identifier:components; 52, attribute; 52, 53; 52, 54; 53, identifier:opt; 54, identifier:component_owners; 55, attribute; 55, 56; 55, 57; 56, identifier:opt; 57, identifier:versions; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:include_fields; 61, list:["name", "id"]; 61, 62; 61, 63; 62, string:"name"; 63, string:"id"; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:fastcomponents; 67, parenthesized_expression; 67, 68; 68, boolean_operator:and; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:opt; 71, identifier:components; 72, not_operator; 72, 73; 73, attribute; 73, 74; 73, 75; 74, identifier:opt; 75, identifier:active_components; 76, if_statement; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:opt; 79, identifier:versions; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, augmented_assignment:+=; 82, 83; 82, 84; 83, identifier:include_fields; 84, list:["versions"]; 84, 85; 85, string:"versions"; 86, if_statement; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:opt; 89, identifier:component_owners; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, augmented_assignment:+=; 92, 93; 92, 94; 93, identifier:include_fields; 94, list:[
"components.default_assigned_to",
"components.name",
]; 94, 95; 94, 96; 95, string:"components.default_assigned_to"; 96, string:"components.name"; 97, if_statement; 97, 98; 97, 113; 98, parenthesized_expression; 98, 99; 99, boolean_operator:and; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:opt; 102, identifier:active_components; 103, call; 103, 104; 103, 105; 104, identifier:any; 105, argument_list; 105, 106; 106, list_comprehension; 106, 107; 106, 110; 107, comparison_operator:in; 107, 108; 107, 109; 108, string:"components"; 109, identifier:i; 110, for_in_clause; 110, 111; 110, 112; 111, identifier:i; 112, identifier:include_fields; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, augmented_assignment:+=; 115, 116; 115, 117; 116, identifier:include_fields; 117, list:["components.is_active"]; 117, 118; 118, string:"components.is_active"; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:bz; 123, identifier:refresh_products; 124, argument_list; 124, 125; 124, 133; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:names; 127, boolean_operator:or; 127, 128; 127, 132; 128, boolean_operator:and; 128, 129; 128, 130; 129, identifier:productname; 130, list:[productname]; 130, 131; 131, identifier:productname; 132, None; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:include_fields; 135, identifier:include_fields; 136, if_statement; 136, 137; 136, 140; 136, 163; 136, 183; 136, 212; 136, 243; 137, attribute; 137, 138; 137, 139; 138, identifier:opt; 139, identifier:products; 140, block; 140, 141; 141, for_statement; 141, 142; 141, 143; 141, 157; 142, identifier:name; 143, call; 143, 144; 143, 145; 144, identifier:sorted; 145, argument_list; 145, 146; 146, list_comprehension; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:p; 149, string:"name"; 150, for_in_clause; 150, 151; 150, 152; 151, identifier:p; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:bz; 155, identifier:getproducts; 156, argument_list; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, call; 159, 160; 159, 161; 160, identifier:print; 161, argument_list; 161, 162; 162, identifier:name; 163, elif_clause; 163, 164; 163, 165; 164, identifier:fastcomponents; 165, block; 165, 166; 166, for_statement; 166, 167; 166, 168; 166, 177; 167, identifier:name; 168, call; 168, 169; 168, 170; 169, identifier:sorted; 170, argument_list; 170, 171; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:bz; 174, identifier:getcomponents; 175, argument_list; 175, 176; 176, identifier:productname; 177, block; 177, 178; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 181; 180, identifier:print; 181, argument_list; 181, 182; 182, identifier:name; 183, elif_clause; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:opt; 186, identifier:components; 187, block; 187, 188; 187, 197; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 191; 190, identifier:details; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:bz; 194, identifier:getcomponentsdetails; 195, argument_list; 195, 196; 196, identifier:productname; 197, for_statement; 197, 198; 197, 199; 197, 206; 198, identifier:name; 199, call; 199, 200; 199, 201; 200, identifier:sorted; 201, argument_list; 201, 202; 202, call; 202, 203; 202, 204; 203, identifier:_filter_components; 204, argument_list; 204, 205; 205, identifier:details; 206, block; 206, 207; 207, expression_statement; 207, 208; 208, call; 208, 209; 208, 210; 209, identifier:print; 210, argument_list; 210, 211; 211, identifier:name; 212, elif_clause; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:opt; 215, identifier:versions; 216, block; 216, 217; 216, 227; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:proddict; 220, subscript; 220, 221; 220, 226; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:bz; 224, identifier:getproducts; 225, argument_list; 226, integer:0; 227, for_statement; 227, 228; 227, 229; 227, 232; 228, identifier:v; 229, subscript; 229, 230; 229, 231; 230, identifier:proddict; 231, string:'versions'; 232, block; 232, 233; 233, expression_statement; 233, 234; 234, call; 234, 235; 234, 236; 235, identifier:print; 236, argument_list; 236, 237; 237, call; 237, 238; 237, 239; 238, identifier:to_encoding; 239, argument_list; 239, 240; 240, subscript; 240, 241; 240, 242; 241, identifier:v; 242, string:"name"; 243, elif_clause; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:opt; 246, identifier:component_owners; 247, block; 247, 248; 247, 257; 248, expression_statement; 248, 249; 249, assignment; 249, 250; 249, 251; 250, identifier:details; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:bz; 254, identifier:getcomponentsdetails; 255, argument_list; 255, 256; 256, identifier:productname; 257, for_statement; 257, 258; 257, 259; 257, 266; 258, identifier:c; 259, call; 259, 260; 259, 261; 260, identifier:sorted; 261, argument_list; 261, 262; 262, call; 262, 263; 262, 264; 263, identifier:_filter_components; 264, argument_list; 264, 265; 265, identifier:details; 266, block; 266, 267; 267, expression_statement; 267, 268; 268, call; 268, 269; 268, 270; 269, identifier:print; 270, argument_list; 270, 271; 271, call; 271, 272; 271, 273; 272, identifier:to_encoding; 273, argument_list; 273, 274; 274, binary_operator:%; 274, 275; 274, 276; 275, string:u"%s: %s"; 276, tuple; 276, 277; 276, 278; 277, identifier:c; 278, subscript; 278, 279; 278, 282; 279, subscript; 279, 280; 279, 281; 280, identifier:details; 281, identifier:c; 282, string:'default_assigned_to' | def _do_info(bz, opt):
def _filter_components(compdetails):
ret = {}
for k, v in compdetails.items():
if v.get("is_active", True):
ret[k] = v
return ret
productname = (opt.components or opt.component_owners or opt.versions)
include_fields = ["name", "id"]
fastcomponents = (opt.components and not opt.active_components)
if opt.versions:
include_fields += ["versions"]
if opt.component_owners:
include_fields += [
"components.default_assigned_to",
"components.name",
]
if (opt.active_components and
any(["components" in i for i in include_fields])):
include_fields += ["components.is_active"]
bz.refresh_products(names=productname and [productname] or None,
include_fields=include_fields)
if opt.products:
for name in sorted([p["name"] for p in bz.getproducts()]):
print(name)
elif fastcomponents:
for name in sorted(bz.getcomponents(productname)):
print(name)
elif opt.components:
details = bz.getcomponentsdetails(productname)
for name in sorted(_filter_components(details)):
print(name)
elif opt.versions:
proddict = bz.getproducts()[0]
for v in proddict['versions']:
print(to_encoding(v["name"]))
elif opt.component_owners:
details = bz.getcomponentsdetails(productname)
for c in sorted(_filter_components(details)):
print(to_encoding(u"%s: %s" % (c,
details[c]['default_assigned_to']))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:login; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:user; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:password; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:restrict_login; 13, None; 14, block; 14, 15; 14, 25; 14, 34; 14, 43; 14, 54; 14, 65; 14, 75; 15, if_statement; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:api_key; 19, block; 19, 20; 20, raise_statement; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:ValueError; 23, argument_list; 23, 24; 24, string:"cannot login when using an API key"; 25, if_statement; 25, 26; 25, 27; 26, identifier:user; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:user; 33, identifier:user; 34, if_statement; 34, 35; 34, 36; 35, identifier:password; 36, block; 36, 37; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:password; 42, identifier:password; 43, if_statement; 43, 44; 43, 48; 44, not_operator; 44, 45; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:user; 48, block; 48, 49; 49, raise_statement; 49, 50; 50, call; 50, 51; 50, 52; 51, identifier:ValueError; 52, argument_list; 52, 53; 53, string:"missing username"; 54, if_statement; 54, 55; 54, 59; 55, not_operator; 55, 56; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:password; 59, block; 59, 60; 60, raise_statement; 60, 61; 61, call; 61, 62; 61, 63; 62, identifier:ValueError; 63, argument_list; 63, 64; 64, string:"missing password"; 65, if_statement; 65, 66; 65, 67; 66, identifier:restrict_login; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:log; 72, identifier:info; 73, argument_list; 73, 74; 74, string:"logging in with restrict_login=True"; 75, try_statement; 75, 76; 75, 110; 76, block; 76, 77; 76, 92; 76, 98; 76, 108; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:ret; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:_login; 84, argument_list; 84, 85; 84, 88; 84, 91; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:user; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:password; 91, identifier:restrict_login; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:password; 97, string:''; 98, expression_statement; 98, 99; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:log; 102, identifier:info; 103, argument_list; 103, 104; 103, 105; 104, string:"login successful for user=%s"; 105, attribute; 105, 106; 105, 107; 106, identifier:self; 107, identifier:user; 108, return_statement; 108, 109; 109, identifier:ret; 110, except_clause; 110, 111; 110, 115; 111, as_pattern; 111, 112; 111, 113; 112, identifier:Fault; 113, as_pattern_target; 113, 114; 114, identifier:e; 115, block; 115, 116; 116, raise_statement; 116, 117; 117, call; 117, 118; 117, 119; 118, identifier:BugzillaError; 119, argument_list; 119, 120; 120, binary_operator:%; 120, 121; 120, 122; 121, string:"Login failed: %s"; 122, call; 122, 123; 122, 124; 123, identifier:str; 124, argument_list; 124, 125; 125, attribute; 125, 126; 125, 127; 126, identifier:e; 127, identifier:faultString | def login(self, user=None, password=None, restrict_login=None):
if self.api_key:
raise ValueError("cannot login when using an API key")
if user:
self.user = user
if password:
self.password = password
if not self.user:
raise ValueError("missing username")
if not self.password:
raise ValueError("missing password")
if restrict_login:
log.info("logging in with restrict_login=True")
try:
ret = self._login(self.user, self.password, restrict_login)
self.password = ''
log.info("login successful for user=%s", self.user)
return ret
except Fault as e:
raise BugzillaError("Login failed: %s" % str(e.faultString)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_process_include_fields; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:include_fields; 6, identifier:exclude_fields; 7, identifier:extra_fields; 8, block; 8, 9; 8, 56; 8, 60; 8, 113; 8, 130; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:_convert_fields; 11, parameters; 11, 12; 12, identifier:_in; 13, block; 13, 14; 13, 20; 13, 54; 14, if_statement; 14, 15; 14, 17; 15, not_operator; 15, 16; 16, identifier:_in; 17, block; 17, 18; 18, return_statement; 18, 19; 19, identifier:_in; 20, for_statement; 20, 21; 20, 24; 20, 29; 21, pattern_list; 21, 22; 21, 23; 22, identifier:newname; 23, identifier:oldname; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:_get_api_aliases; 28, argument_list; 29, block; 29, 30; 30, if_statement; 30, 31; 30, 34; 31, comparison_operator:in; 31, 32; 31, 33; 32, identifier:oldname; 33, identifier:_in; 34, block; 34, 35; 34, 42; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:_in; 39, identifier:remove; 40, argument_list; 40, 41; 41, identifier:oldname; 42, if_statement; 42, 43; 42, 46; 43, comparison_operator:not; 43, 44; 43, 45; 44, identifier:newname; 45, identifier:_in; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:_in; 51, identifier:append; 52, argument_list; 52, 53; 53, identifier:newname; 54, return_statement; 54, 55; 55, identifier:_in; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:ret; 59, dictionary; 60, if_statement; 60, 61; 60, 68; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:_check_version; 65, argument_list; 65, 66; 65, 67; 66, integer:4; 67, integer:0; 68, block; 68, 69; 68, 97; 69, if_statement; 69, 70; 69, 71; 70, identifier:include_fields; 71, block; 71, 72; 71, 79; 71, 91; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:include_fields; 75, call; 75, 76; 75, 77; 76, identifier:_convert_fields; 77, argument_list; 77, 78; 78, identifier:include_fields; 79, if_statement; 79, 80; 79, 83; 80, comparison_operator:not; 80, 81; 80, 82; 81, string:"id"; 82, identifier:include_fields; 83, block; 83, 84; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:include_fields; 88, identifier:append; 89, argument_list; 89, 90; 90, string:"id"; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 96; 93, subscript; 93, 94; 93, 95; 94, identifier:ret; 95, string:"include_fields"; 96, identifier:include_fields; 97, if_statement; 97, 98; 97, 99; 98, identifier:exclude_fields; 99, block; 99, 100; 99, 107; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:exclude_fields; 103, call; 103, 104; 103, 105; 104, identifier:_convert_fields; 105, argument_list; 105, 106; 106, identifier:exclude_fields; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 112; 109, subscript; 109, 110; 109, 111; 110, identifier:ret; 111, string:"exclude_fields"; 112, identifier:exclude_fields; 113, if_statement; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:_supports_getbug_extra_fields; 117, block; 117, 118; 118, if_statement; 118, 119; 118, 120; 119, identifier:extra_fields; 120, block; 120, 121; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 126; 123, subscript; 123, 124; 123, 125; 124, identifier:ret; 125, string:"extra_fields"; 126, call; 126, 127; 126, 128; 127, identifier:_convert_fields; 128, argument_list; 128, 129; 129, identifier:extra_fields; 130, return_statement; 130, 131; 131, identifier:ret | def _process_include_fields(self, include_fields, exclude_fields,
extra_fields):
def _convert_fields(_in):
if not _in:
return _in
for newname, oldname in self._get_api_aliases():
if oldname in _in:
_in.remove(oldname)
if newname not in _in:
_in.append(newname)
return _in
ret = {}
if self._check_version(4, 0):
if include_fields:
include_fields = _convert_fields(include_fields)
if "id" not in include_fields:
include_fields.append("id")
ret["include_fields"] = include_fields
if exclude_fields:
exclude_fields = _convert_fields(exclude_fields)
ret["exclude_fields"] = exclude_fields
if self._supports_getbug_extra_fields:
if extra_fields:
ret["extra_fields"] = _convert_fields(extra_fields)
return ret |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:_getbugs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:idlist; 6, identifier:permissive; 7, default_parameter; 7, 8; 7, 9; 8, identifier:include_fields; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:exclude_fields; 12, None; 13, default_parameter; 13, 14; 13, 15; 14, identifier:extra_fields; 15, None; 16, block; 16, 17; 16, 21; 16, 25; 16, 51; 16, 62; 16, 68; 16, 75; 16, 84; 16, 98; 16, 111; 16, 158; 16, 162; 16, 219; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:oldidlist; 20, identifier:idlist; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:idlist; 24, list:[]; 25, for_statement; 25, 26; 25, 27; 25, 28; 26, identifier:i; 27, identifier:oldidlist; 28, block; 28, 29; 29, try_statement; 29, 30; 29, 41; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:idlist; 35, identifier:append; 36, argument_list; 36, 37; 37, call; 37, 38; 37, 39; 38, identifier:int; 39, argument_list; 39, 40; 40, identifier:i; 41, except_clause; 41, 42; 41, 43; 42, identifier:ValueError; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:idlist; 48, identifier:append; 49, argument_list; 49, 50; 50, identifier:i; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:extra_fields; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:_listify; 58, argument_list; 58, 59; 59, boolean_operator:or; 59, 60; 59, 61; 60, identifier:extra_fields; 61, list:[]; 62, expression_statement; 62, 63; 63, augmented_assignment:+=; 63, 64; 63, 65; 64, identifier:extra_fields; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:_getbug_extra_fields; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:getbugdata; 71, dictionary; 71, 72; 72, pair; 72, 73; 72, 74; 73, string:"ids"; 74, identifier:idlist; 75, if_statement; 75, 76; 75, 77; 76, identifier:permissive; 77, block; 77, 78; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 83; 80, subscript; 80, 81; 80, 82; 81, identifier:getbugdata; 82, string:"permissive"; 83, integer:1; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:getbugdata; 88, identifier:update; 89, argument_list; 89, 90; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:_process_include_fields; 94, argument_list; 94, 95; 94, 96; 94, 97; 95, identifier:include_fields; 96, identifier:exclude_fields; 97, identifier:extra_fields; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:r; 101, call; 101, 102; 101, 109; 102, attribute; 102, 103; 102, 108; 103, attribute; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:_proxy; 107, identifier:Bug; 108, identifier:get; 109, argument_list; 109, 110; 110, identifier:getbugdata; 111, if_statement; 111, 112; 111, 119; 111, 137; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:self; 115, identifier:_check_version; 116, argument_list; 116, 117; 116, 118; 117, integer:4; 118, integer:0; 119, block; 119, 120; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:bugdict; 123, call; 123, 124; 123, 125; 124, identifier:dict; 125, argument_list; 125, 126; 126, list_comprehension; 126, 127; 126, 132; 127, tuple; 127, 128; 127, 131; 128, subscript; 128, 129; 128, 130; 129, identifier:b; 130, string:'id'; 131, identifier:b; 132, for_in_clause; 132, 133; 132, 134; 133, identifier:b; 134, subscript; 134, 135; 134, 136; 135, identifier:r; 136, string:'bugs'; 137, else_clause; 137, 138; 138, block; 138, 139; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:bugdict; 142, call; 142, 143; 142, 144; 143, identifier:dict; 144, argument_list; 144, 145; 145, list_comprehension; 145, 146; 145, 153; 146, tuple; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:b; 149, string:'id'; 150, subscript; 150, 151; 150, 152; 151, identifier:b; 152, string:'internals'; 153, for_in_clause; 153, 154; 153, 155; 154, identifier:b; 155, subscript; 155, 156; 155, 157; 156, identifier:r; 157, string:'bugs'; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:ret; 161, list:[]; 162, for_statement; 162, 163; 162, 164; 162, 165; 163, identifier:i; 164, identifier:idlist; 165, block; 165, 166; 165, 170; 165, 212; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 169; 168, identifier:found; 169, None; 170, if_statement; 170, 171; 170, 174; 170, 181; 171, comparison_operator:in; 171, 172; 171, 173; 172, identifier:i; 173, identifier:bugdict; 174, block; 174, 175; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:found; 178, subscript; 178, 179; 178, 180; 179, identifier:bugdict; 180, identifier:i; 181, else_clause; 181, 182; 182, block; 182, 183; 183, for_statement; 183, 184; 183, 185; 183, 190; 184, identifier:valdict; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:bugdict; 188, identifier:values; 189, argument_list; 190, block; 190, 191; 191, if_statement; 191, 192; 191, 206; 192, comparison_operator:in; 192, 193; 192, 194; 193, identifier:i; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:self; 197, identifier:_listify; 198, argument_list; 198, 199; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:valdict; 202, identifier:get; 203, argument_list; 203, 204; 203, 205; 204, string:"alias"; 205, None; 206, block; 206, 207; 206, 211; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 210; 209, identifier:found; 210, identifier:valdict; 211, break_statement; 212, expression_statement; 212, 213; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:ret; 216, identifier:append; 217, argument_list; 217, 218; 218, identifier:found; 219, return_statement; 219, 220; 220, identifier:ret | def _getbugs(self, idlist, permissive,
include_fields=None, exclude_fields=None, extra_fields=None):
oldidlist = idlist
idlist = []
for i in oldidlist:
try:
idlist.append(int(i))
except ValueError:
idlist.append(i)
extra_fields = self._listify(extra_fields or [])
extra_fields += self._getbug_extra_fields
getbugdata = {"ids": idlist}
if permissive:
getbugdata["permissive"] = 1
getbugdata.update(self._process_include_fields(
include_fields, exclude_fields, extra_fields))
r = self._proxy.Bug.get(getbugdata)
if self._check_version(4, 0):
bugdict = dict([(b['id'], b) for b in r['bugs']])
else:
bugdict = dict([(b['id'], b['internals']) for b in r['bugs']])
ret = []
for i in idlist:
found = None
if i in bugdict:
found = bugdict[i]
else:
for valdict in bugdict.values():
if i in self._listify(valdict.get("alias", None)):
found = valdict
break
ret.append(found)
return ret |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:attachfile; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:idlist; 6, identifier:attachfile; 7, identifier:description; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 44; 10, 60; 10, 76; 10, 92; 10, 108; 10, 114; 10, 122; 10, 143; 10, 152; 10, 163; 10, 189; 10, 227; 10, 240; 10, 273; 10, 293; 11, if_statement; 11, 12; 11, 17; 11, 26; 11, 37; 12, call; 12, 13; 12, 14; 13, identifier:isinstance; 14, argument_list; 14, 15; 14, 16; 15, identifier:attachfile; 16, identifier:str; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:f; 21, call; 21, 22; 21, 23; 22, identifier:open; 23, argument_list; 23, 24; 23, 25; 24, identifier:attachfile; 25, string:"rb"; 26, elif_clause; 26, 27; 26, 32; 27, call; 27, 28; 27, 29; 28, identifier:hasattr; 29, argument_list; 29, 30; 29, 31; 30, identifier:attachfile; 31, string:'read'; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:f; 36, identifier:attachfile; 37, else_clause; 37, 38; 38, block; 38, 39; 39, raise_statement; 39, 40; 40, call; 40, 41; 40, 42; 41, identifier:TypeError; 42, argument_list; 42, 43; 43, string:"attachfile must be filename or file-like object"; 44, if_statement; 44, 45; 44, 48; 45, comparison_operator:in; 45, 46; 45, 47; 46, string:"contenttype"; 47, identifier:kwargs; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 54; 51, subscript; 51, 52; 51, 53; 52, identifier:kwargs; 53, string:"content_type"; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:kwargs; 57, identifier:pop; 58, argument_list; 58, 59; 59, string:"contenttype"; 60, if_statement; 60, 61; 60, 64; 61, comparison_operator:in; 61, 62; 61, 63; 62, string:"ispatch"; 63, identifier:kwargs; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:kwargs; 69, string:"is_patch"; 70, call; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:kwargs; 73, identifier:pop; 74, argument_list; 74, 75; 75, string:"ispatch"; 76, if_statement; 76, 77; 76, 80; 77, comparison_operator:in; 77, 78; 77, 79; 78, string:"isprivate"; 79, identifier:kwargs; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 86; 83, subscript; 83, 84; 83, 85; 84, identifier:kwargs; 85, string:"is_private"; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:kwargs; 89, identifier:pop; 90, argument_list; 90, 91; 91, string:"isprivate"; 92, if_statement; 92, 93; 92, 96; 93, comparison_operator:in; 93, 94; 93, 95; 94, string:"filename"; 95, identifier:kwargs; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 102; 99, subscript; 99, 100; 99, 101; 100, identifier:kwargs; 101, string:"file_name"; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:kwargs; 105, identifier:pop; 106, argument_list; 106, 107; 107, string:"filename"; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 113; 110, subscript; 110, 111; 110, 112; 111, identifier:kwargs; 112, string:'summary'; 113, identifier:description; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:data; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:f; 120, identifier:read; 121, argument_list; 122, if_statement; 122, 123; 122, 129; 123, not_operator; 123, 124; 124, call; 124, 125; 124, 126; 125, identifier:isinstance; 126, argument_list; 126, 127; 126, 128; 127, identifier:data; 128, identifier:bytes; 129, block; 129, 130; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:data; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:data; 136, identifier:encode; 137, argument_list; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:locale; 141, identifier:getpreferredencoding; 142, argument_list; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, subscript; 145, 146; 145, 147; 146, identifier:kwargs; 147, string:'data'; 148, call; 148, 149; 148, 150; 149, identifier:Binary; 150, argument_list; 150, 151; 151, identifier:data; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 157; 154, subscript; 154, 155; 154, 156; 155, identifier:kwargs; 156, string:'ids'; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:_listify; 161, argument_list; 161, 162; 162, identifier:idlist; 163, if_statement; 163, 164; 163, 173; 164, boolean_operator:and; 164, 165; 164, 168; 165, comparison_operator:not; 165, 166; 165, 167; 166, string:'file_name'; 167, identifier:kwargs; 168, call; 168, 169; 168, 170; 169, identifier:hasattr; 170, argument_list; 170, 171; 170, 172; 171, identifier:f; 172, string:"name"; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 179; 176, subscript; 176, 177; 176, 178; 177, identifier:kwargs; 178, string:'file_name'; 179, call; 179, 180; 179, 185; 180, attribute; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:os; 183, identifier:path; 184, identifier:basename; 185, argument_list; 185, 186; 186, attribute; 186, 187; 186, 188; 187, identifier:f; 188, identifier:name; 189, if_statement; 189, 190; 189, 193; 190, comparison_operator:not; 190, 191; 190, 192; 191, string:'content_type'; 192, identifier:kwargs; 193, block; 193, 194; 193, 198; 193, 219; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:ctype; 197, None; 198, if_statement; 198, 199; 198, 202; 199, subscript; 199, 200; 199, 201; 200, identifier:kwargs; 201, string:'file_name'; 202, block; 202, 203; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:ctype; 206, subscript; 206, 207; 206, 218; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:mimetypes; 210, identifier:guess_type; 211, argument_list; 211, 212; 211, 215; 212, subscript; 212, 213; 212, 214; 213, identifier:kwargs; 214, string:'file_name'; 215, keyword_argument; 215, 216; 215, 217; 216, identifier:strict; 217, False; 218, integer:0; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 224; 221, subscript; 221, 222; 221, 223; 222, identifier:kwargs; 223, string:'content_type'; 224, boolean_operator:or; 224, 225; 224, 226; 225, identifier:ctype; 226, string:'application/octet-stream'; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:ret; 230, call; 230, 231; 230, 238; 231, attribute; 231, 232; 231, 237; 232, attribute; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:self; 235, identifier:_proxy; 236, identifier:Bug; 237, identifier:add_attachment; 238, argument_list; 238, 239; 239, identifier:kwargs; 240, if_statement; 240, 241; 240, 244; 240, 262; 241, comparison_operator:in; 241, 242; 241, 243; 242, string:"attachments"; 243, identifier:ret; 244, block; 244, 245; 245, expression_statement; 245, 246; 246, assignment; 246, 247; 246, 248; 247, identifier:ret; 248, list_comprehension; 248, 249; 248, 253; 249, call; 249, 250; 249, 251; 250, identifier:int; 251, argument_list; 251, 252; 252, identifier:k; 253, for_in_clause; 253, 254; 253, 255; 254, identifier:k; 255, call; 255, 256; 255, 261; 256, attribute; 256, 257; 256, 260; 257, subscript; 257, 258; 257, 259; 258, identifier:ret; 259, string:"attachments"; 260, identifier:keys; 261, argument_list; 262, elif_clause; 262, 263; 262, 266; 263, comparison_operator:in; 263, 264; 263, 265; 264, string:"ids"; 265, identifier:ret; 266, block; 266, 267; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:ret; 270, subscript; 270, 271; 270, 272; 271, identifier:ret; 272, string:"ids"; 273, if_statement; 273, 274; 273, 286; 274, boolean_operator:and; 274, 275; 274, 280; 275, call; 275, 276; 275, 277; 276, identifier:isinstance; 277, argument_list; 277, 278; 277, 279; 278, identifier:ret; 279, identifier:list; 280, comparison_operator:==; 280, 281; 280, 285; 281, call; 281, 282; 281, 283; 282, identifier:len; 283, argument_list; 283, 284; 284, identifier:ret; 285, integer:1; 286, block; 286, 287; 287, expression_statement; 287, 288; 288, assignment; 288, 289; 288, 290; 289, identifier:ret; 290, subscript; 290, 291; 290, 292; 291, identifier:ret; 292, integer:0; 293, return_statement; 293, 294; 294, identifier:ret | def attachfile(self, idlist, attachfile, description, **kwargs):
if isinstance(attachfile, str):
f = open(attachfile, "rb")
elif hasattr(attachfile, 'read'):
f = attachfile
else:
raise TypeError("attachfile must be filename or file-like object")
if "contenttype" in kwargs:
kwargs["content_type"] = kwargs.pop("contenttype")
if "ispatch" in kwargs:
kwargs["is_patch"] = kwargs.pop("ispatch")
if "isprivate" in kwargs:
kwargs["is_private"] = kwargs.pop("isprivate")
if "filename" in kwargs:
kwargs["file_name"] = kwargs.pop("filename")
kwargs['summary'] = description
data = f.read()
if not isinstance(data, bytes):
data = data.encode(locale.getpreferredencoding())
kwargs['data'] = Binary(data)
kwargs['ids'] = self._listify(idlist)
if 'file_name' not in kwargs and hasattr(f, "name"):
kwargs['file_name'] = os.path.basename(f.name)
if 'content_type' not in kwargs:
ctype = None
if kwargs['file_name']:
ctype = mimetypes.guess_type(
kwargs['file_name'], strict=False)[0]
kwargs['content_type'] = ctype or 'application/octet-stream'
ret = self._proxy.Bug.add_attachment(kwargs)
if "attachments" in ret:
ret = [int(k) for k in ret["attachments"].keys()]
elif "ids" in ret:
ret = ret["ids"]
if isinstance(ret, list) and len(ret) == 1:
ret = ret[0]
return ret |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:pre_translation; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:query; 6, block; 6, 7; 6, 15; 6, 57; 6, 85; 6, 95; 6, 123; 6, 139; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:old; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:query; 13, identifier:copy; 14, argument_list; 15, if_statement; 15, 16; 15, 19; 16, comparison_operator:in; 16, 17; 16, 18; 17, string:'bug_id'; 18, identifier:query; 19, block; 19, 20; 19, 53; 20, if_statement; 20, 21; 20, 29; 20, 43; 21, not_operator; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:isinstance; 24, argument_list; 24, 25; 24, 28; 25, subscript; 25, 26; 25, 27; 26, identifier:query; 27, string:'bug_id'; 28, identifier:list; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 35; 32, subscript; 32, 33; 32, 34; 33, identifier:query; 34, string:'id'; 35, call; 35, 36; 35, 41; 36, attribute; 36, 37; 36, 40; 37, subscript; 37, 38; 37, 39; 38, identifier:query; 39, string:'bug_id'; 40, identifier:split; 41, argument_list; 41, 42; 42, string:','; 43, else_clause; 43, 44; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 50; 47, subscript; 47, 48; 47, 49; 48, identifier:query; 49, string:'id'; 50, subscript; 50, 51; 50, 52; 51, identifier:query; 52, string:'bug_id'; 53, delete_statement; 53, 54; 54, subscript; 54, 55; 54, 56; 55, identifier:query; 56, string:'bug_id'; 57, if_statement; 57, 58; 57, 61; 58, comparison_operator:in; 58, 59; 58, 60; 59, string:'component'; 60, identifier:query; 61, block; 61, 62; 62, if_statement; 62, 63; 62, 71; 63, not_operator; 63, 64; 64, call; 64, 65; 64, 66; 65, identifier:isinstance; 66, argument_list; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:query; 69, string:'component'; 70, identifier:list; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 77; 74, subscript; 74, 75; 74, 76; 75, identifier:query; 76, string:'component'; 77, call; 77, 78; 77, 83; 78, attribute; 78, 79; 78, 82; 79, subscript; 79, 80; 79, 81; 80, identifier:query; 81, string:'component'; 82, identifier:split; 83, argument_list; 83, 84; 84, string:','; 85, if_statement; 85, 86; 85, 93; 86, boolean_operator:and; 86, 87; 86, 90; 87, comparison_operator:not; 87, 88; 87, 89; 88, string:'include_fields'; 89, identifier:query; 90, comparison_operator:not; 90, 91; 90, 92; 91, string:'column_list'; 92, identifier:query; 93, block; 93, 94; 94, return_statement; 95, if_statement; 95, 96; 95, 99; 96, comparison_operator:not; 96, 97; 96, 98; 97, string:'include_fields'; 98, identifier:query; 99, block; 99, 100; 99, 106; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 105; 102, subscript; 102, 103; 102, 104; 103, identifier:query; 104, string:'include_fields'; 105, list:[]; 106, if_statement; 106, 107; 106, 110; 107, comparison_operator:in; 107, 108; 107, 109; 108, string:'column_list'; 109, identifier:query; 110, block; 110, 111; 110, 119; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 116; 113, subscript; 113, 114; 113, 115; 114, identifier:query; 115, string:'include_fields'; 116, subscript; 116, 117; 116, 118; 117, identifier:query; 118, string:'column_list'; 119, delete_statement; 119, 120; 120, subscript; 120, 121; 120, 122; 121, identifier:query; 122, string:'column_list'; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:query; 127, identifier:update; 128, argument_list; 128, 129; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:self; 132, identifier:_process_include_fields; 133, argument_list; 133, 134; 133, 137; 133, 138; 134, subscript; 134, 135; 134, 136; 135, identifier:query; 136, string:"include_fields"; 137, None; 138, None; 139, if_statement; 139, 140; 139, 143; 140, comparison_operator:!=; 140, 141; 140, 142; 141, identifier:old; 142, identifier:query; 143, block; 143, 144; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:log; 148, identifier:debug; 149, argument_list; 149, 150; 149, 151; 150, string:"RHBugzilla pretranslated query to: %s"; 151, identifier:query | def pre_translation(self, query):
old = query.copy()
if 'bug_id' in query:
if not isinstance(query['bug_id'], list):
query['id'] = query['bug_id'].split(',')
else:
query['id'] = query['bug_id']
del query['bug_id']
if 'component' in query:
if not isinstance(query['component'], list):
query['component'] = query['component'].split(',')
if 'include_fields' not in query and 'column_list' not in query:
return
if 'include_fields' not in query:
query['include_fields'] = []
if 'column_list' in query:
query['include_fields'] = query['column_list']
del query['column_list']
query.update(self._process_include_fields(query["include_fields"],
None, None))
if old != query:
log.debug("RHBugzilla pretranslated query to: %s", query) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check_differences; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 29; 5, 45; 5, 63; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logger; 10, identifier:info; 11, argument_list; 11, 12; 12, string:"Check that mail differences are within the limits."; 13, if_statement; 13, 14; 13, 21; 14, comparison_operator:<; 14, 15; 14, 20; 15, attribute; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:conf; 19, identifier:size_threshold; 20, integer:0; 21, block; 21, 22; 22, expression_statement; 22, 23; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:logger; 26, identifier:info; 27, argument_list; 27, 28; 28, string:"Skip checking for size differences."; 29, if_statement; 29, 30; 29, 37; 30, comparison_operator:<; 30, 31; 30, 36; 31, attribute; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:conf; 35, identifier:content_threshold; 36, integer:0; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:logger; 42, identifier:info; 43, argument_list; 43, 44; 44, string:"Skip checking for content differences."; 45, if_statement; 45, 46; 45, 61; 46, boolean_operator:and; 46, 47; 46, 54; 47, comparison_operator:<; 47, 48; 47, 53; 48, attribute; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:conf; 52, identifier:size_threshold; 53, integer:0; 54, comparison_operator:<; 54, 55; 54, 60; 55, attribute; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:conf; 59, identifier:content_threshold; 60, integer:0; 61, block; 61, 62; 62, return_statement; 63, for_statement; 63, 64; 63, 67; 63, 74; 64, pattern_list; 64, 65; 64, 66; 65, identifier:mail_a; 66, identifier:mail_b; 67, call; 67, 68; 67, 69; 68, identifier:combinations; 69, argument_list; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:pool; 73, integer:2; 74, block; 74, 75; 74, 123; 75, if_statement; 75, 76; 75, 84; 76, comparison_operator:>; 76, 77; 76, 82; 77, attribute; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:conf; 81, identifier:size_threshold; 82, unary_operator:-; 82, 83; 83, integer:1; 84, block; 84, 85; 84, 98; 84, 112; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:size_difference; 88, call; 88, 89; 88, 90; 89, identifier:abs; 90, argument_list; 90, 91; 91, binary_operator:-; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:mail_a; 94, identifier:size; 95, attribute; 95, 96; 95, 97; 96, identifier:mail_b; 97, identifier:size; 98, expression_statement; 98, 99; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:logger; 102, identifier:debug; 103, argument_list; 103, 104; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, string:"{} and {} differs by {} bytes in size."; 107, identifier:format; 108, argument_list; 108, 109; 108, 110; 108, 111; 109, identifier:mail_a; 110, identifier:mail_b; 111, identifier:size_difference; 112, if_statement; 112, 113; 112, 120; 113, comparison_operator:>; 113, 114; 113, 115; 114, identifier:size_difference; 115, attribute; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:conf; 119, identifier:size_threshold; 120, block; 120, 121; 121, raise_statement; 121, 122; 122, identifier:SizeDiffAboveThreshold; 123, if_statement; 123, 124; 123, 132; 124, comparison_operator:>; 124, 125; 124, 130; 125, attribute; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:conf; 129, identifier:content_threshold; 130, unary_operator:-; 130, 131; 131, integer:1; 132, block; 132, 133; 132, 143; 132, 157; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:content_difference; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:diff; 140, argument_list; 140, 141; 140, 142; 141, identifier:mail_a; 142, identifier:mail_b; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:logger; 147, identifier:debug; 148, argument_list; 148, 149; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, string:"{} and {} differs by {} bytes in content."; 152, identifier:format; 153, argument_list; 153, 154; 153, 155; 153, 156; 154, identifier:mail_a; 155, identifier:mail_b; 156, identifier:content_difference; 157, if_statement; 157, 158; 157, 165; 158, comparison_operator:>; 158, 159; 158, 160; 159, identifier:content_difference; 160, attribute; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:conf; 164, identifier:content_threshold; 165, block; 165, 166; 165, 186; 166, if_statement; 166, 167; 166, 172; 167, attribute; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:conf; 171, identifier:show_diff; 172, block; 172, 173; 173, expression_statement; 173, 174; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:logger; 177, identifier:info; 178, argument_list; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:pretty_diff; 183, argument_list; 183, 184; 183, 185; 184, identifier:mail_a; 185, identifier:mail_b; 186, raise_statement; 186, 187; 187, identifier:ContentDiffAboveThreshold | def check_differences(self):
logger.info("Check that mail differences are within the limits.")
if self.conf.size_threshold < 0:
logger.info("Skip checking for size differences.")
if self.conf.content_threshold < 0:
logger.info("Skip checking for content differences.")
if self.conf.size_threshold < 0 and self.conf.content_threshold < 0:
return
for mail_a, mail_b in combinations(self.pool, 2):
if self.conf.size_threshold > -1:
size_difference = abs(mail_a.size - mail_b.size)
logger.debug("{} and {} differs by {} bytes in size.".format(
mail_a, mail_b, size_difference))
if size_difference > self.conf.size_threshold:
raise SizeDiffAboveThreshold
if self.conf.content_threshold > -1:
content_difference = self.diff(mail_a, mail_b)
logger.debug(
"{} and {} differs by {} bytes in content.".format(
mail_a, mail_b, content_difference))
if content_difference > self.conf.content_threshold:
if self.conf.show_diff:
logger.info(self.pretty_diff(mail_a, mail_b))
raise ContentDiffAboveThreshold |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:filecache; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:seconds_of_validity; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:fail_silently; 9, False; 10, block; 10, 11; 10, 13; 10, 231; 10, 254; 11, expression_statement; 11, 12; 12, string:'''
filecache is called and the decorator should be returned.
'''; 13, function_definition; 13, 14; 13, 15; 13, 17; 14, function_name:filecache_decorator; 15, parameters; 15, 16; 16, identifier:function; 17, block; 17, 18; 17, 161; 17, 229; 18, decorated_definition; 18, 19; 18, 26; 19, decorator; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:_functools; 23, identifier:wraps; 24, argument_list; 24, 25; 25, identifier:function; 26, function_definition; 26, 27; 26, 28; 26, 33; 27, function_name:function_with_cache; 28, parameters; 28, 29; 28, 31; 29, list_splat_pattern; 29, 30; 30, identifier:args; 31, dictionary_splat_pattern; 31, 32; 32, identifier:kwargs; 33, block; 33, 34; 33, 102; 33, 112; 33, 159; 34, try_statement; 34, 35; 34, 81; 35, block; 35, 36; 35, 45; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:key; 39, call; 39, 40; 39, 41; 40, identifier:_args_key; 41, argument_list; 41, 42; 41, 43; 41, 44; 42, identifier:function; 43, identifier:args; 44, identifier:kwargs; 45, if_statement; 45, 46; 45, 51; 46, comparison_operator:in; 46, 47; 46, 48; 47, identifier:key; 48, attribute; 48, 49; 48, 50; 49, identifier:function; 50, identifier:_db; 51, block; 51, 52; 51, 60; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:rv; 55, subscript; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:function; 58, identifier:_db; 59, identifier:key; 60, if_statement; 60, 61; 60, 76; 61, boolean_operator:or; 61, 62; 61, 65; 62, comparison_operator:is; 62, 63; 62, 64; 63, identifier:seconds_of_validity; 64, None; 65, comparison_operator:<; 65, 66; 65, 75; 66, binary_operator:-; 66, 67; 66, 72; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:_time; 70, identifier:time; 71, argument_list; 72, attribute; 72, 73; 72, 74; 73, identifier:rv; 74, identifier:timesig; 75, identifier:seconds_of_validity; 76, block; 76, 77; 77, return_statement; 77, 78; 78, attribute; 78, 79; 78, 80; 79, identifier:rv; 80, identifier:data; 81, except_clause; 81, 82; 81, 83; 82, identifier:Exception; 83, block; 83, 84; 83, 92; 83, 97; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:error_str; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:_traceback; 90, identifier:format_exc; 91, argument_list; 92, expression_statement; 92, 93; 93, call; 93, 94; 93, 95; 94, identifier:_log_error; 95, argument_list; 95, 96; 96, identifier:error_str; 97, if_statement; 97, 98; 97, 100; 98, not_operator; 98, 99; 99, identifier:fail_silently; 100, block; 100, 101; 101, raise_statement; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:retval; 105, call; 105, 106; 105, 107; 106, identifier:function; 107, argument_list; 107, 108; 107, 110; 108, list_splat; 108, 109; 109, identifier:args; 110, dictionary_splat; 110, 111; 111, identifier:kwargs; 112, try_statement; 112, 113; 112, 138; 113, block; 113, 114; 113, 130; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 121; 116, subscript; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:function; 119, identifier:_db; 120, identifier:key; 121, call; 121, 122; 121, 123; 122, identifier:_retval; 123, argument_list; 123, 124; 123, 129; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:_time; 127, identifier:time; 128, argument_list; 129, identifier:retval; 130, expression_statement; 130, 131; 131, call; 131, 132; 131, 137; 132, attribute; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:function; 135, identifier:_db; 136, identifier:sync; 137, argument_list; 138, except_clause; 138, 139; 138, 140; 139, identifier:Exception; 140, block; 140, 141; 140, 149; 140, 154; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:error_str; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:_traceback; 147, identifier:format_exc; 148, argument_list; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 152; 151, identifier:_log_error; 152, argument_list; 152, 153; 153, identifier:error_str; 154, if_statement; 154, 155; 154, 157; 155, not_operator; 155, 156; 156, identifier:fail_silently; 157, block; 157, 158; 158, raise_statement; 159, return_statement; 159, 160; 160, identifier:retval; 161, if_statement; 161, 162; 161, 168; 162, not_operator; 162, 163; 163, call; 163, 164; 163, 165; 164, identifier:hasattr; 165, argument_list; 165, 166; 165, 167; 166, identifier:function; 167, string:'_db'; 168, block; 168, 169; 168, 176; 168, 221; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:cache_name; 172, call; 172, 173; 172, 174; 173, identifier:_get_cache_name; 174, argument_list; 174, 175; 175, identifier:function; 176, if_statement; 176, 177; 176, 180; 176, 189; 177, comparison_operator:in; 177, 178; 177, 179; 178, identifier:cache_name; 179, identifier:OPEN_DBS; 180, block; 180, 181; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:function; 185, identifier:_db; 186, subscript; 186, 187; 186, 188; 187, identifier:OPEN_DBS; 188, identifier:cache_name; 189, else_clause; 189, 190; 190, block; 190, 191; 190, 202; 190, 210; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:function; 195, identifier:_db; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:_shelve; 199, identifier:open; 200, argument_list; 200, 201; 201, identifier:cache_name; 202, expression_statement; 202, 203; 203, assignment; 203, 204; 203, 207; 204, subscript; 204, 205; 204, 206; 205, identifier:OPEN_DBS; 206, identifier:cache_name; 207, attribute; 207, 208; 207, 209; 208, identifier:function; 209, identifier:_db; 210, expression_statement; 210, 211; 211, call; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:atexit; 214, identifier:register; 215, argument_list; 215, 216; 216, attribute; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:function; 219, identifier:_db; 220, identifier:close; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:function_with_cache; 225, identifier:_db; 226, attribute; 226, 227; 226, 228; 227, identifier:function; 228, identifier:_db; 229, return_statement; 229, 230; 230, identifier:function_with_cache; 231, if_statement; 231, 232; 231, 240; 232, comparison_operator:==; 232, 233; 232, 237; 233, call; 233, 234; 233, 235; 234, identifier:type; 235, argument_list; 235, 236; 236, identifier:seconds_of_validity; 237, attribute; 237, 238; 237, 239; 238, identifier:types; 239, identifier:FunctionType; 240, block; 240, 241; 240, 245; 240, 249; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:func; 244, identifier:seconds_of_validity; 245, expression_statement; 245, 246; 246, assignment; 246, 247; 246, 248; 247, identifier:seconds_of_validity; 248, None; 249, return_statement; 249, 250; 250, call; 250, 251; 250, 252; 251, identifier:filecache_decorator; 252, argument_list; 252, 253; 253, identifier:func; 254, return_statement; 254, 255; 255, identifier:filecache_decorator | def filecache(seconds_of_validity=None, fail_silently=False):
'''
filecache is called and the decorator should be returned.
'''
def filecache_decorator(function):
@_functools.wraps(function)
def function_with_cache(*args, **kwargs):
try:
key = _args_key(function, args, kwargs)
if key in function._db:
rv = function._db[key]
if seconds_of_validity is None or _time.time() - rv.timesig < seconds_of_validity:
return rv.data
except Exception:
error_str = _traceback.format_exc()
_log_error(error_str)
if not fail_silently:
raise
retval = function(*args, **kwargs)
try:
function._db[key] = _retval(_time.time(), retval)
function._db.sync()
except Exception:
error_str = _traceback.format_exc()
_log_error(error_str)
if not fail_silently:
raise
return retval
if not hasattr(function, '_db'):
cache_name = _get_cache_name(function)
if cache_name in OPEN_DBS:
function._db = OPEN_DBS[cache_name]
else:
function._db = _shelve.open(cache_name)
OPEN_DBS[cache_name] = function._db
atexit.register(function._db.close)
function_with_cache._db = function._db
return function_with_cache
if type(seconds_of_validity) == types.FunctionType:
func = seconds_of_validity
seconds_of_validity = None
return filecache_decorator(func)
return filecache_decorator |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:connect; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 17; 9, 255; 10, expression_statement; 10, 11; 11, await; 11, 12; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:disconnect; 16, argument_list; 17, if_statement; 17, 18; 17, 28; 17, 74; 18, boolean_operator:and; 18, 19; 18, 22; 19, comparison_operator:not; 19, 20; 19, 21; 20, string:'endpoint'; 21, identifier:kwargs; 22, comparison_operator:<; 22, 23; 22, 27; 23, call; 23, 24; 23, 25; 24, identifier:len; 25, argument_list; 25, 26; 26, identifier:args; 27, integer:2; 28, block; 28, 29; 28, 62; 29, if_statement; 29, 30; 29, 35; 29, 41; 29, 50; 30, boolean_operator:and; 30, 31; 30, 32; 31, identifier:args; 32, comparison_operator:in; 32, 33; 32, 34; 33, string:'model_name'; 34, identifier:kwargs; 35, block; 35, 36; 36, raise_statement; 36, 37; 37, call; 37, 38; 37, 39; 38, identifier:TypeError; 39, argument_list; 39, 40; 40, string:'connect() got multiple values for model_name'; 41, elif_clause; 41, 42; 41, 43; 42, identifier:args; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:model_name; 47, subscript; 47, 48; 47, 49; 48, identifier:args; 49, integer:0; 50, else_clause; 50, 51; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:model_name; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:kwargs; 58, identifier:pop; 59, argument_list; 59, 60; 59, 61; 60, string:'model_name'; 61, None; 62, expression_statement; 62, 63; 63, await; 63, 64; 64, call; 64, 65; 64, 70; 65, attribute; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:_connector; 69, identifier:connect_model; 70, argument_list; 70, 71; 70, 72; 71, identifier:model_name; 72, dictionary_splat; 72, 73; 73, identifier:kwargs; 74, else_clause; 74, 75; 75, block; 75, 76; 75, 88; 75, 100; 75, 117; 75, 136; 75, 156; 75, 168; 75, 181; 75, 198; 75, 216; 75, 244; 76, if_statement; 76, 77; 76, 80; 77, comparison_operator:in; 77, 78; 77, 79; 78, string:'model_name'; 79, identifier:kwargs; 80, block; 80, 81; 81, raise_statement; 81, 82; 82, call; 82, 83; 82, 84; 83, identifier:TypeError; 84, argument_list; 84, 85; 85, concatenated_string; 85, 86; 85, 87; 86, string:'connect() got values for both '; 87, string:'model_name and endpoint'; 88, if_statement; 88, 89; 88, 94; 89, boolean_operator:and; 89, 90; 89, 91; 90, identifier:args; 91, comparison_operator:in; 91, 92; 91, 93; 92, string:'endpoint'; 93, identifier:kwargs; 94, block; 94, 95; 95, raise_statement; 95, 96; 96, call; 96, 97; 96, 98; 97, identifier:TypeError; 98, argument_list; 98, 99; 99, string:'connect() got multiple values for endpoint'; 100, if_statement; 100, 101; 100, 111; 101, boolean_operator:and; 101, 102; 101, 108; 102, comparison_operator:<; 102, 103; 102, 107; 103, call; 103, 104; 103, 105; 104, identifier:len; 105, argument_list; 105, 106; 106, identifier:args; 107, integer:2; 108, comparison_operator:not; 108, 109; 108, 110; 109, string:'uuid'; 110, identifier:kwargs; 111, block; 111, 112; 112, raise_statement; 112, 113; 113, call; 113, 114; 113, 115; 114, identifier:TypeError; 115, argument_list; 115, 116; 116, string:'connect() missing value for uuid'; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:has_userpass; 120, parenthesized_expression; 120, 121; 121, boolean_operator:or; 121, 122; 121, 128; 122, comparison_operator:>=; 122, 123; 122, 127; 123, call; 123, 124; 123, 125; 124, identifier:len; 125, argument_list; 125, 126; 126, identifier:args; 127, integer:4; 128, call; 128, 129; 128, 134; 129, attribute; 129, 130; 129, 133; 130, set; 130, 131; 130, 132; 131, string:'username'; 132, string:'password'; 133, identifier:issubset; 134, argument_list; 134, 135; 135, identifier:kwargs; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:has_macaroons; 139, parenthesized_expression; 139, 140; 140, boolean_operator:or; 140, 141; 140, 147; 141, comparison_operator:>=; 141, 142; 141, 146; 142, call; 142, 143; 142, 144; 143, identifier:len; 144, argument_list; 144, 145; 145, identifier:args; 146, integer:6; 147, not_operator; 147, 148; 148, call; 148, 149; 148, 154; 149, attribute; 149, 150; 149, 153; 150, set; 150, 151; 150, 152; 151, string:'bakery_client'; 152, string:'macaroons'; 153, identifier:isdisjoint; 154, argument_list; 154, 155; 155, identifier:kwargs; 156, if_statement; 156, 157; 156, 162; 157, not_operator; 157, 158; 158, parenthesized_expression; 158, 159; 159, boolean_operator:or; 159, 160; 159, 161; 160, identifier:has_userpass; 161, identifier:has_macaroons; 162, block; 162, 163; 163, raise_statement; 163, 164; 164, call; 164, 165; 164, 166; 165, identifier:TypeError; 166, argument_list; 166, 167; 167, string:'connect() missing auth params'; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:arg_names; 171, list:[
'endpoint',
'uuid',
'username',
'password',
'cacert',
'bakery_client',
'macaroons',
'loop',
'max_frame_size',
]; 171, 172; 171, 173; 171, 174; 171, 175; 171, 176; 171, 177; 171, 178; 171, 179; 171, 180; 172, string:'endpoint'; 173, string:'uuid'; 174, string:'username'; 175, string:'password'; 176, string:'cacert'; 177, string:'bakery_client'; 178, string:'macaroons'; 179, string:'loop'; 180, string:'max_frame_size'; 181, for_statement; 181, 182; 181, 185; 181, 189; 182, pattern_list; 182, 183; 182, 184; 183, identifier:i; 184, identifier:arg; 185, call; 185, 186; 185, 187; 186, identifier:enumerate; 187, argument_list; 187, 188; 188, identifier:args; 189, block; 189, 190; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 197; 192, subscript; 192, 193; 192, 194; 193, identifier:kwargs; 194, subscript; 194, 195; 194, 196; 195, identifier:arg_names; 196, identifier:i; 197, identifier:arg; 198, if_statement; 198, 199; 198, 208; 199, not_operator; 199, 200; 200, call; 200, 201; 200, 206; 201, attribute; 201, 202; 201, 205; 202, set; 202, 203; 202, 204; 203, string:'endpoint'; 204, string:'uuid'; 205, identifier:issubset; 206, argument_list; 206, 207; 207, identifier:kwargs; 208, block; 208, 209; 209, raise_statement; 209, 210; 210, call; 210, 211; 210, 212; 211, identifier:ValueError; 212, argument_list; 212, 213; 213, concatenated_string; 213, 214; 213, 215; 214, string:'endpoint and uuid are required '; 215, string:'if model_name not given'; 216, if_statement; 216, 217; 216, 236; 217, not_operator; 217, 218; 218, parenthesized_expression; 218, 219; 219, boolean_operator:or; 219, 220; 219, 228; 220, call; 220, 221; 220, 226; 221, attribute; 221, 222; 221, 225; 222, set; 222, 223; 222, 224; 223, string:'username'; 224, string:'password'; 225, identifier:issubset; 226, argument_list; 226, 227; 227, identifier:kwargs; 228, call; 228, 229; 228, 234; 229, attribute; 229, 230; 229, 233; 230, set; 230, 231; 230, 232; 231, string:'bakery_client'; 232, string:'macaroons'; 233, identifier:intersection; 234, argument_list; 234, 235; 235, identifier:kwargs; 236, block; 236, 237; 237, raise_statement; 237, 238; 238, call; 238, 239; 238, 240; 239, identifier:ValueError; 240, argument_list; 240, 241; 241, concatenated_string; 241, 242; 241, 243; 242, string:'Authentication parameters are required '; 243, string:'if model_name not given'; 244, expression_statement; 244, 245; 245, await; 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:_connector; 251, identifier:connect; 252, argument_list; 252, 253; 253, dictionary_splat; 253, 254; 254, identifier:kwargs; 255, expression_statement; 255, 256; 256, await; 256, 257; 257, call; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:self; 260, identifier:_after_connect; 261, argument_list | async def connect(self, *args, **kwargs):
await self.disconnect()
if 'endpoint' not in kwargs and len(args) < 2:
if args and 'model_name' in kwargs:
raise TypeError('connect() got multiple values for model_name')
elif args:
model_name = args[0]
else:
model_name = kwargs.pop('model_name', None)
await self._connector.connect_model(model_name, **kwargs)
else:
if 'model_name' in kwargs:
raise TypeError('connect() got values for both '
'model_name and endpoint')
if args and 'endpoint' in kwargs:
raise TypeError('connect() got multiple values for endpoint')
if len(args) < 2 and 'uuid' not in kwargs:
raise TypeError('connect() missing value for uuid')
has_userpass = (len(args) >= 4 or
{'username', 'password'}.issubset(kwargs))
has_macaroons = (len(args) >= 6 or not
{'bakery_client', 'macaroons'}.isdisjoint(kwargs))
if not (has_userpass or has_macaroons):
raise TypeError('connect() missing auth params')
arg_names = [
'endpoint',
'uuid',
'username',
'password',
'cacert',
'bakery_client',
'macaroons',
'loop',
'max_frame_size',
]
for i, arg in enumerate(args):
kwargs[arg_names[i]] = arg
if not {'endpoint', 'uuid'}.issubset(kwargs):
raise ValueError('endpoint and uuid are required '
'if model_name not given')
if not ({'username', 'password'}.issubset(kwargs) or
{'bakery_client', 'macaroons'}.intersection(kwargs)):
raise ValueError('Authentication parameters are required '
'if model_name not given')
await self._connector.connect(**kwargs)
await self._after_connect() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_watch; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 283; 5, 290; 5, 298; 5, 306; 5, 314; 6, function_definition; 6, 7; 6, 8; 6, 9; 7, function_name:_all_watcher; 8, parameters; 9, block; 9, 10; 10, try_statement; 10, 11; 10, 258; 10, 262; 10, 273; 11, block; 11, 12; 11, 27; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:allwatcher; 15, call; 15, 16; 15, 21; 16, attribute; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:client; 19, identifier:AllWatcherFacade; 20, identifier:from_connection; 21, argument_list; 21, 22; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:connection; 26, argument_list; 27, while_statement; 27, 28; 27, 36; 28, not_operator; 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:_watch_stopping; 34, identifier:is_set; 35, argument_list; 36, block; 36, 37; 36, 169; 36, 194; 36, 250; 37, try_statement; 37, 38; 37, 63; 37, 100; 38, block; 38, 39; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:results; 42, await; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:utils; 46, identifier:run_with_interrupt; 47, argument_list; 47, 48; 47, 53; 47, 56; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:allwatcher; 51, identifier:Next; 52, argument_list; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:_watch_stopping; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:loop; 58, attribute; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:_connector; 62, identifier:loop; 63, except_clause; 63, 64; 63, 68; 64, as_pattern; 64, 65; 64, 66; 65, identifier:JujuAPIError; 66, as_pattern_target; 66, 67; 67, identifier:e; 68, block; 68, 69; 68, 78; 68, 88; 68, 95; 68, 99; 69, if_statement; 69, 70; 69, 76; 70, comparison_operator:not; 70, 71; 70, 72; 71, string:'watcher was stopped'; 72, call; 72, 73; 72, 74; 73, identifier:str; 74, argument_list; 74, 75; 75, identifier:e; 76, block; 76, 77; 77, raise_statement; 78, if_statement; 78, 79; 78, 86; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:_watch_stopping; 84, identifier:is_set; 85, argument_list; 86, block; 86, 87; 87, break_statement; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:log; 92, identifier:warning; 93, argument_list; 93, 94; 94, string:'Watcher: watcher stopped, restarting'; 95, delete_statement; 95, 96; 96, attribute; 96, 97; 96, 98; 97, identifier:allwatcher; 98, identifier:Id; 99, continue_statement; 100, except_clause; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:websockets; 103, identifier:ConnectionClosed; 104, block; 104, 105; 104, 115; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:monitor; 108, attribute; 108, 109; 108, 114; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:self; 112, identifier:connection; 113, argument_list; 114, identifier:monitor; 115, if_statement; 115, 116; 115, 123; 115, 166; 116, comparison_operator:==; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:monitor; 119, identifier:status; 120, attribute; 120, 121; 120, 122; 121, identifier:monitor; 122, identifier:ERROR; 123, block; 123, 124; 123, 131; 123, 142; 123, 161; 123, 165; 124, expression_statement; 124, 125; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:log; 128, identifier:warning; 129, argument_list; 129, 130; 130, string:'Watcher: connection closed, reopening'; 131, expression_statement; 131, 132; 132, await; 132, 133; 133, call; 133, 134; 133, 141; 134, attribute; 134, 135; 134, 140; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:connection; 139, argument_list; 140, identifier:reconnect; 141, argument_list; 142, if_statement; 142, 143; 142, 150; 143, comparison_operator:!=; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:monitor; 146, identifier:status; 147, attribute; 147, 148; 147, 149; 148, identifier:monitor; 149, identifier:CONNECTED; 150, block; 150, 151; 150, 160; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:log; 155, identifier:error; 156, argument_list; 156, 157; 157, concatenated_string; 157, 158; 157, 159; 158, string:'Watcher: automatic reconnect '; 159, string:'failed; stopping watcher'; 160, break_statement; 161, delete_statement; 161, 162; 162, attribute; 162, 163; 162, 164; 163, identifier:allwatcher; 164, identifier:Id; 165, continue_statement; 166, else_clause; 166, 167; 167, block; 167, 168; 168, break_statement; 169, if_statement; 169, 170; 169, 177; 170, call; 170, 171; 170, 176; 171, attribute; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:self; 174, identifier:_watch_stopping; 175, identifier:is_set; 176, argument_list; 177, block; 177, 178; 177, 193; 178, try_statement; 178, 179; 178, 187; 179, block; 179, 180; 180, expression_statement; 180, 181; 181, await; 181, 182; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:allwatcher; 185, identifier:Stop; 186, argument_list; 187, except_clause; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:websockets; 190, identifier:ConnectionClosed; 191, block; 191, 192; 192, pass_statement; 193, break_statement; 194, for_statement; 194, 195; 194, 196; 194, 199; 195, identifier:delta; 196, attribute; 196, 197; 196, 198; 197, identifier:results; 198, identifier:deltas; 199, block; 199, 200; 200, try_statement; 200, 201; 200, 232; 201, block; 201, 202; 201, 209; 201, 222; 202, expression_statement; 202, 203; 203, assignment; 203, 204; 203, 205; 204, identifier:delta; 205, call; 205, 206; 205, 207; 206, identifier:get_entity_delta; 207, argument_list; 207, 208; 208, identifier:delta; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 214; 211, pattern_list; 211, 212; 211, 213; 212, identifier:old_obj; 213, identifier:new_obj; 214, call; 214, 215; 214, 220; 215, attribute; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:self; 218, identifier:state; 219, identifier:apply_delta; 220, argument_list; 220, 221; 221, identifier:delta; 222, expression_statement; 222, 223; 223, await; 223, 224; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:self; 227, identifier:_notify_observers; 228, argument_list; 228, 229; 228, 230; 228, 231; 229, identifier:delta; 230, identifier:old_obj; 231, identifier:new_obj; 232, except_clause; 232, 233; 232, 237; 233, as_pattern; 233, 234; 233, 235; 234, identifier:KeyError; 235, as_pattern_target; 235, 236; 236, identifier:e; 237, block; 237, 238; 238, expression_statement; 238, 239; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:log; 242, identifier:debug; 243, argument_list; 243, 244; 243, 245; 244, string:"unknown delta type: %s"; 245, subscript; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, identifier:e; 248, identifier:args; 249, integer:0; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 257; 252, attribute; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:self; 255, identifier:_watch_received; 256, identifier:set; 257, argument_list; 258, except_clause; 258, 259; 258, 260; 259, identifier:CancelledError; 260, block; 260, 261; 261, pass_statement; 262, except_clause; 262, 263; 262, 264; 263, identifier:Exception; 264, block; 264, 265; 264, 272; 265, expression_statement; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:log; 269, identifier:exception; 270, argument_list; 270, 271; 271, string:'Error in watcher'; 272, raise_statement; 273, finally_clause; 273, 274; 274, block; 274, 275; 275, expression_statement; 275, 276; 276, call; 276, 277; 276, 282; 277, attribute; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, identifier:self; 280, identifier:_watch_stopped; 281, identifier:set; 282, argument_list; 283, expression_statement; 283, 284; 284, call; 284, 285; 284, 288; 285, attribute; 285, 286; 285, 287; 286, identifier:log; 287, identifier:debug; 288, argument_list; 288, 289; 289, string:'Starting watcher task'; 290, expression_statement; 290, 291; 291, call; 291, 292; 291, 297; 292, attribute; 292, 293; 292, 296; 293, attribute; 293, 294; 293, 295; 294, identifier:self; 295, identifier:_watch_received; 296, identifier:clear; 297, argument_list; 298, expression_statement; 298, 299; 299, call; 299, 300; 299, 305; 300, attribute; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:self; 303, identifier:_watch_stopping; 304, identifier:clear; 305, argument_list; 306, expression_statement; 306, 307; 307, call; 307, 308; 307, 313; 308, attribute; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:self; 311, identifier:_watch_stopped; 312, identifier:clear; 313, argument_list; 314, expression_statement; 314, 315; 315, call; 315, 316; 315, 323; 316, attribute; 316, 317; 316, 322; 317, attribute; 317, 318; 317, 321; 318, attribute; 318, 319; 318, 320; 319, identifier:self; 320, identifier:_connector; 321, identifier:loop; 322, identifier:create_task; 323, argument_list; 323, 324; 324, call; 324, 325; 324, 326; 325, identifier:_all_watcher; 326, argument_list | def _watch(self):
async def _all_watcher():
try:
allwatcher = client.AllWatcherFacade.from_connection(
self.connection())
while not self._watch_stopping.is_set():
try:
results = await utils.run_with_interrupt(
allwatcher.Next(),
self._watch_stopping,
loop=self._connector.loop)
except JujuAPIError as e:
if 'watcher was stopped' not in str(e):
raise
if self._watch_stopping.is_set():
break
log.warning(
'Watcher: watcher stopped, restarting')
del allwatcher.Id
continue
except websockets.ConnectionClosed:
monitor = self.connection().monitor
if monitor.status == monitor.ERROR:
log.warning(
'Watcher: connection closed, reopening')
await self.connection().reconnect()
if monitor.status != monitor.CONNECTED:
log.error('Watcher: automatic reconnect '
'failed; stopping watcher')
break
del allwatcher.Id
continue
else:
break
if self._watch_stopping.is_set():
try:
await allwatcher.Stop()
except websockets.ConnectionClosed:
pass
break
for delta in results.deltas:
try:
delta = get_entity_delta(delta)
old_obj, new_obj = self.state.apply_delta(delta)
await self._notify_observers(delta, old_obj, new_obj)
except KeyError as e:
log.debug("unknown delta type: %s", e.args[0])
self._watch_received.set()
except CancelledError:
pass
except Exception:
log.exception('Error in watcher')
raise
finally:
self._watch_stopped.set()
log.debug('Starting watcher task')
self._watch_received.clear()
self._watch_stopping.clear()
self._watch_stopped.clear()
self._connector.loop.create_task(_all_watcher()) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:add_machine; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:spec; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:constraints; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:disks; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:series; 16, None; 17, block; 17, 18; 17, 26; 17, 105; 17, 112; 17, 128; 17, 148; 17, 157; 17, 172; 17, 183; 17, 193; 17, 205; 17, 215; 17, 242; 17, 250; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:params; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:client; 24, identifier:AddMachineParams; 25, argument_list; 26, if_statement; 26, 27; 26, 28; 27, identifier:spec; 28, block; 28, 29; 29, if_statement; 29, 30; 29, 36; 29, 85; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:spec; 33, identifier:startswith; 34, argument_list; 34, 35; 35, string:"ssh:"; 36, block; 36, 37; 36, 49; 36, 60; 36, 77; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 43; 39, pattern_list; 39, 40; 39, 41; 39, 42; 40, identifier:placement; 41, identifier:target; 42, identifier:private_key_path; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:spec; 46, identifier:split; 47, argument_list; 47, 48; 48, string:":"; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 54; 51, pattern_list; 51, 52; 51, 53; 52, identifier:user; 53, identifier:host; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:target; 57, identifier:split; 58, argument_list; 58, 59; 59, string:"@"; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:sshProvisioner; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:provisioner; 66, identifier:SSHProvisioner; 67, argument_list; 67, 68; 67, 71; 67, 74; 68, keyword_argument; 68, 69; 68, 70; 69, identifier:host; 70, identifier:host; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:user; 73, identifier:user; 74, keyword_argument; 74, 75; 74, 76; 75, identifier:private_key_path; 76, identifier:private_key_path; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:params; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:sshProvisioner; 83, identifier:provision_machine; 84, argument_list; 85, else_clause; 85, 86; 86, block; 86, 87; 86, 94; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:placement; 90, call; 90, 91; 90, 92; 91, identifier:parse_placement; 92, argument_list; 92, 93; 93, identifier:spec; 94, if_statement; 94, 95; 94, 96; 95, identifier:placement; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:params; 101, identifier:placement; 102, subscript; 102, 103; 102, 104; 103, identifier:placement; 104, integer:0; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:params; 109, identifier:jobs; 110, list:['JobHostUnits']; 110, 111; 111, string:'JobHostUnits'; 112, if_statement; 112, 113; 112, 114; 113, identifier:constraints; 114, block; 114, 115; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:params; 119, identifier:constraints; 120, call; 120, 121; 120, 126; 121, attribute; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:client; 124, identifier:Value; 125, identifier:from_json; 126, argument_list; 126, 127; 127, identifier:constraints; 128, if_statement; 128, 129; 128, 130; 129, identifier:disks; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:params; 135, identifier:disks; 136, list_comprehension; 136, 137; 136, 145; 137, call; 137, 138; 137, 143; 138, attribute; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:client; 141, identifier:Constraints; 142, identifier:from_json; 143, argument_list; 143, 144; 144, identifier:o; 145, for_in_clause; 145, 146; 145, 147; 146, identifier:o; 147, identifier:disks; 148, if_statement; 148, 149; 148, 150; 149, identifier:series; 150, block; 150, 151; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:params; 155, identifier:series; 156, identifier:series; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:client_facade; 160, call; 160, 161; 160, 166; 161, attribute; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:client; 164, identifier:ClientFacade; 165, identifier:from_connection; 166, argument_list; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:connection; 171, argument_list; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:results; 175, await; 175, 176; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:client_facade; 179, identifier:AddMachines; 180, argument_list; 180, 181; 181, list:[params]; 181, 182; 182, identifier:params; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 186; 185, identifier:error; 186, attribute; 186, 187; 186, 192; 187, subscript; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:results; 190, identifier:machines; 191, integer:0; 192, identifier:error; 193, if_statement; 193, 194; 193, 195; 194, identifier:error; 195, block; 195, 196; 196, raise_statement; 196, 197; 197, call; 197, 198; 197, 199; 198, identifier:ValueError; 199, argument_list; 199, 200; 200, binary_operator:%; 200, 201; 200, 202; 201, string:"Error adding machine: %s"; 202, attribute; 202, 203; 202, 204; 203, identifier:error; 204, identifier:message; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:machine_id; 208, attribute; 208, 209; 208, 214; 209, subscript; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:results; 212, identifier:machines; 213, integer:0; 214, identifier:machine; 215, if_statement; 215, 216; 215, 217; 216, identifier:spec; 217, block; 217, 218; 218, if_statement; 218, 219; 218, 225; 219, call; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:spec; 222, identifier:startswith; 223, argument_list; 223, 224; 224, string:"ssh:"; 225, block; 225, 226; 226, expression_statement; 226, 227; 227, await; 227, 228; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:sshProvisioner; 231, identifier:install_agent; 232, argument_list; 232, 233; 232, 238; 232, 241; 233, call; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:self; 236, identifier:connection; 237, argument_list; 238, attribute; 238, 239; 238, 240; 239, identifier:params; 240, identifier:nonce; 241, identifier:machine_id; 242, expression_statement; 242, 243; 243, call; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:log; 246, identifier:debug; 247, argument_list; 247, 248; 247, 249; 248, string:'Added new machine %s'; 249, identifier:machine_id; 250, return_statement; 250, 251; 251, await; 251, 252; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:self; 255, identifier:_wait_for_new; 256, argument_list; 256, 257; 256, 258; 257, string:'machine'; 258, identifier:machine_id | async def add_machine(
self, spec=None, constraints=None, disks=None, series=None):
params = client.AddMachineParams()
if spec:
if spec.startswith("ssh:"):
placement, target, private_key_path = spec.split(":")
user, host = target.split("@")
sshProvisioner = provisioner.SSHProvisioner(
host=host,
user=user,
private_key_path=private_key_path,
)
params = sshProvisioner.provision_machine()
else:
placement = parse_placement(spec)
if placement:
params.placement = placement[0]
params.jobs = ['JobHostUnits']
if constraints:
params.constraints = client.Value.from_json(constraints)
if disks:
params.disks = [
client.Constraints.from_json(o) for o in disks]
if series:
params.series = series
client_facade = client.ClientFacade.from_connection(self.connection())
results = await client_facade.AddMachines([params])
error = results.machines[0].error
if error:
raise ValueError("Error adding machine: %s" % error.message)
machine_id = results.machines[0].machine
if spec:
if spec.startswith("ssh:"):
await sshProvisioner.install_agent(
self.connection(),
params.nonce,
machine_id,
)
log.debug('Added new machine %s', machine_id)
return await self._wait_for_new('machine', machine_id) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_action_output; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:action_uuid; 6, default_parameter; 6, 7; 6, 8; 7, identifier:wait; 8, None; 9, block; 9, 10; 9, 25; 9, 38; 9, 79; 9, 92; 9, 102; 9, 129; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:action_facade; 13, call; 13, 14; 13, 19; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:client; 17, identifier:ActionFacade; 18, identifier:from_connection; 19, argument_list; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:connection; 24, argument_list; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:entity; 28, list:[{'tag': tag.action(action_uuid)}]; 28, 29; 29, dictionary; 29, 30; 30, pair; 30, 31; 30, 32; 31, string:'tag'; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:tag; 35, identifier:action; 36, argument_list; 36, 37; 37, identifier:action_uuid; 38, function_definition; 38, 39; 38, 40; 38, 41; 39, function_name:_wait_for_action_status; 40, parameters; 41, block; 41, 42; 42, while_statement; 42, 43; 42, 44; 43, True; 44, block; 44, 45; 44, 55; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:action_output; 48, await; 48, 49; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:action_facade; 52, identifier:Actions; 53, argument_list; 53, 54; 54, identifier:entity; 55, if_statement; 55, 56; 55, 67; 55, 69; 56, comparison_operator:in; 56, 57; 56, 64; 57, attribute; 57, 58; 57, 63; 58, subscript; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:action_output; 61, identifier:results; 62, integer:0; 63, identifier:status; 64, tuple; 64, 65; 64, 66; 65, string:'completed'; 66, string:'failed'; 67, block; 67, 68; 68, return_statement; 69, else_clause; 69, 70; 70, block; 70, 71; 71, expression_statement; 71, 72; 72, await; 72, 73; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:asyncio; 76, identifier:sleep; 77, argument_list; 77, 78; 78, integer:1; 79, expression_statement; 79, 80; 80, await; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:asyncio; 84, identifier:wait_for; 85, argument_list; 85, 86; 85, 89; 86, call; 86, 87; 86, 88; 87, identifier:_wait_for_action_status; 88, argument_list; 89, keyword_argument; 89, 90; 89, 91; 90, identifier:timeout; 91, identifier:wait; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:action_output; 95, await; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:action_facade; 99, identifier:Actions; 100, argument_list; 100, 101; 101, identifier:entity; 102, if_statement; 102, 103; 102, 112; 102, 117; 103, comparison_operator:is; 103, 104; 103, 111; 104, attribute; 104, 105; 104, 110; 105, subscript; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:action_output; 108, identifier:results; 109, integer:0; 110, identifier:output; 111, None; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:output; 116, dictionary; 117, else_clause; 117, 118; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:output; 122, attribute; 122, 123; 122, 128; 123, subscript; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:action_output; 126, identifier:results; 127, integer:0; 128, identifier:output; 129, return_statement; 129, 130; 130, identifier:output | async def get_action_output(self, action_uuid, wait=None):
action_facade = client.ActionFacade.from_connection(
self.connection()
)
entity = [{'tag': tag.action(action_uuid)}]
async def _wait_for_action_status():
while True:
action_output = await action_facade.Actions(entity)
if action_output.results[0].status in ('completed', 'failed'):
return
else:
await asyncio.sleep(1)
await asyncio.wait_for(
_wait_for_action_status(),
timeout=wait)
action_output = await action_facade.Actions(entity)
if action_output.results[0].output is None:
output = {}
else:
output = action_output.results[0].output
return output |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:connect; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 17; 10, expression_statement; 10, 11; 11, await; 11, 12; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:disconnect; 16, argument_list; 17, if_statement; 17, 18; 17, 28; 17, 76; 18, boolean_operator:and; 18, 19; 18, 22; 19, comparison_operator:not; 19, 20; 19, 21; 20, string:'endpoint'; 21, identifier:kwargs; 22, comparison_operator:<; 22, 23; 22, 27; 23, call; 23, 24; 23, 25; 24, identifier:len; 25, argument_list; 25, 26; 26, identifier:args; 27, integer:2; 28, block; 28, 29; 28, 64; 29, if_statement; 29, 30; 29, 35; 29, 43; 29, 52; 30, boolean_operator:and; 30, 31; 30, 32; 31, identifier:args; 32, comparison_operator:in; 32, 33; 32, 34; 33, string:'model_name'; 34, identifier:kwargs; 35, block; 35, 36; 36, raise_statement; 36, 37; 37, call; 37, 38; 37, 39; 38, identifier:TypeError; 39, argument_list; 39, 40; 40, concatenated_string; 40, 41; 40, 42; 41, string:'connect() got multiple values for '; 42, string:'controller_name'; 43, elif_clause; 43, 44; 43, 45; 44, identifier:args; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:controller_name; 49, subscript; 49, 50; 49, 51; 50, identifier:args; 51, integer:0; 52, else_clause; 52, 53; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:controller_name; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:kwargs; 60, identifier:pop; 61, argument_list; 61, 62; 61, 63; 62, string:'controller_name'; 63, None; 64, expression_statement; 64, 65; 65, await; 65, 66; 66, call; 66, 67; 66, 72; 67, attribute; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:_connector; 71, identifier:connect_controller; 72, argument_list; 72, 73; 72, 74; 73, identifier:controller_name; 74, dictionary_splat; 74, 75; 75, identifier:kwargs; 76, else_clause; 76, 77; 77, block; 77, 78; 77, 90; 77, 102; 77, 121; 77, 141; 77, 153; 77, 165; 77, 182; 77, 194; 77, 222; 78, if_statement; 78, 79; 78, 82; 79, comparison_operator:in; 79, 80; 79, 81; 80, string:'controller_name'; 81, identifier:kwargs; 82, block; 82, 83; 83, raise_statement; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:TypeError; 86, argument_list; 86, 87; 87, concatenated_string; 87, 88; 87, 89; 88, string:'connect() got values for both '; 89, string:'controller_name and endpoint'; 90, if_statement; 90, 91; 90, 96; 91, boolean_operator:and; 91, 92; 91, 93; 92, identifier:args; 93, comparison_operator:in; 93, 94; 93, 95; 94, string:'endpoint'; 95, identifier:kwargs; 96, block; 96, 97; 97, raise_statement; 97, 98; 98, call; 98, 99; 98, 100; 99, identifier:TypeError; 100, argument_list; 100, 101; 101, string:'connect() got multiple values for endpoint'; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:has_userpass; 105, parenthesized_expression; 105, 106; 106, boolean_operator:or; 106, 107; 106, 113; 107, comparison_operator:>=; 107, 108; 107, 112; 108, call; 108, 109; 108, 110; 109, identifier:len; 110, argument_list; 110, 111; 111, identifier:args; 112, integer:3; 113, call; 113, 114; 113, 119; 114, attribute; 114, 115; 114, 118; 115, set; 115, 116; 115, 117; 116, string:'username'; 117, string:'password'; 118, identifier:issubset; 119, argument_list; 119, 120; 120, identifier:kwargs; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:has_macaroons; 124, parenthesized_expression; 124, 125; 125, boolean_operator:or; 125, 126; 125, 132; 126, comparison_operator:>=; 126, 127; 126, 131; 127, call; 127, 128; 127, 129; 128, identifier:len; 129, argument_list; 129, 130; 130, identifier:args; 131, integer:5; 132, not_operator; 132, 133; 133, call; 133, 134; 133, 139; 134, attribute; 134, 135; 134, 138; 135, set; 135, 136; 135, 137; 136, string:'bakery_client'; 137, string:'macaroons'; 138, identifier:isdisjoint; 139, argument_list; 139, 140; 140, identifier:kwargs; 141, if_statement; 141, 142; 141, 147; 142, not_operator; 142, 143; 143, parenthesized_expression; 143, 144; 144, boolean_operator:or; 144, 145; 144, 146; 145, identifier:has_userpass; 146, identifier:has_macaroons; 147, block; 147, 148; 148, raise_statement; 148, 149; 149, call; 149, 150; 149, 151; 150, identifier:TypeError; 151, argument_list; 151, 152; 152, string:'connect() missing auth params'; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:arg_names; 156, list:[
'endpoint',
'username',
'password',
'cacert',
'bakery_client',
'macaroons',
'loop',
'max_frame_size',
]; 156, 157; 156, 158; 156, 159; 156, 160; 156, 161; 156, 162; 156, 163; 156, 164; 157, string:'endpoint'; 158, string:'username'; 159, string:'password'; 160, string:'cacert'; 161, string:'bakery_client'; 162, string:'macaroons'; 163, string:'loop'; 164, string:'max_frame_size'; 165, for_statement; 165, 166; 165, 169; 165, 173; 166, pattern_list; 166, 167; 166, 168; 167, identifier:i; 168, identifier:arg; 169, call; 169, 170; 169, 171; 170, identifier:enumerate; 171, argument_list; 171, 172; 172, identifier:args; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 181; 176, subscript; 176, 177; 176, 178; 177, identifier:kwargs; 178, subscript; 178, 179; 178, 180; 179, identifier:arg_names; 180, identifier:i; 181, identifier:arg; 182, if_statement; 182, 183; 182, 186; 183, comparison_operator:not; 183, 184; 183, 185; 184, string:'endpoint'; 185, identifier:kwargs; 186, block; 186, 187; 187, raise_statement; 187, 188; 188, call; 188, 189; 188, 190; 189, identifier:ValueError; 190, argument_list; 190, 191; 191, concatenated_string; 191, 192; 191, 193; 192, string:'endpoint is required '; 193, string:'if controller_name not given'; 194, if_statement; 194, 195; 194, 214; 195, not_operator; 195, 196; 196, parenthesized_expression; 196, 197; 197, boolean_operator:or; 197, 198; 197, 206; 198, call; 198, 199; 198, 204; 199, attribute; 199, 200; 199, 203; 200, set; 200, 201; 200, 202; 201, string:'username'; 202, string:'password'; 203, identifier:issubset; 204, argument_list; 204, 205; 205, identifier:kwargs; 206, call; 206, 207; 206, 212; 207, attribute; 207, 208; 207, 211; 208, set; 208, 209; 208, 210; 209, string:'bakery_client'; 210, string:'macaroons'; 211, identifier:intersection; 212, argument_list; 212, 213; 213, identifier:kwargs; 214, block; 214, 215; 215, raise_statement; 215, 216; 216, call; 216, 217; 216, 218; 217, identifier:ValueError; 218, argument_list; 218, 219; 219, concatenated_string; 219, 220; 219, 221; 220, string:'Authentication parameters are required '; 221, string:'if controller_name not given'; 222, expression_statement; 222, 223; 223, await; 223, 224; 224, call; 224, 225; 224, 230; 225, attribute; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:self; 228, identifier:_connector; 229, identifier:connect; 230, argument_list; 230, 231; 231, dictionary_splat; 231, 232; 232, identifier:kwargs | async def connect(self, *args, **kwargs):
await self.disconnect()
if 'endpoint' not in kwargs and len(args) < 2:
if args and 'model_name' in kwargs:
raise TypeError('connect() got multiple values for '
'controller_name')
elif args:
controller_name = args[0]
else:
controller_name = kwargs.pop('controller_name', None)
await self._connector.connect_controller(controller_name, **kwargs)
else:
if 'controller_name' in kwargs:
raise TypeError('connect() got values for both '
'controller_name and endpoint')
if args and 'endpoint' in kwargs:
raise TypeError('connect() got multiple values for endpoint')
has_userpass = (len(args) >= 3 or
{'username', 'password'}.issubset(kwargs))
has_macaroons = (len(args) >= 5 or not
{'bakery_client', 'macaroons'}.isdisjoint(kwargs))
if not (has_userpass or has_macaroons):
raise TypeError('connect() missing auth params')
arg_names = [
'endpoint',
'username',
'password',
'cacert',
'bakery_client',
'macaroons',
'loop',
'max_frame_size',
]
for i, arg in enumerate(args):
kwargs[arg_names[i]] = arg
if 'endpoint' not in kwargs:
raise ValueError('endpoint is required '
'if controller_name not given')
if not ({'username', 'password'}.issubset(kwargs) or
{'bakery_client', 'macaroons'}.intersection(kwargs)):
raise ValueError('Authentication parameters are required '
'if controller_name not given')
await self._connector.connect(**kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:add_credential; 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:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:credential; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:cloud; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:owner; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:force; 19, False; 20, block; 20, 21; 20, 34; 20, 52; 20, 65; 20, 102; 20, 182; 20, 190; 20, 205; 20, 233; 20, 263; 21, if_statement; 21, 22; 21, 24; 22, not_operator; 22, 23; 23, identifier:cloud; 24, block; 24, 25; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:cloud; 28, await; 28, 29; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:get_cloud; 33, argument_list; 34, if_statement; 34, 35; 34, 37; 35, not_operator; 35, 36; 36, identifier:owner; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:owner; 41, subscript; 41, 42; 41, 51; 42, subscript; 42, 43; 42, 50; 43, attribute; 43, 44; 43, 49; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:connection; 48, argument_list; 49, identifier:info; 50, string:'user-info'; 51, string:'identity'; 52, if_statement; 52, 53; 52, 57; 53, boolean_operator:and; 53, 54; 53, 55; 54, identifier:credential; 55, not_operator; 55, 56; 56, identifier:name; 57, block; 57, 58; 58, raise_statement; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:errors; 62, identifier:JujuError; 63, argument_list; 63, 64; 64, string:'Name must be provided for credential'; 65, if_statement; 65, 66; 65, 68; 66, not_operator; 66, 67; 67, identifier:credential; 68, block; 68, 69; 68, 85; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 74; 71, pattern_list; 71, 72; 71, 73; 72, identifier:name; 73, identifier:credential; 74, call; 74, 75; 74, 82; 75, attribute; 75, 76; 75, 81; 76, attribute; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:_connector; 80, identifier:jujudata; 81, identifier:load_credential; 82, argument_list; 82, 83; 82, 84; 83, identifier:cloud; 84, identifier:name; 85, if_statement; 85, 86; 85, 89; 86, comparison_operator:is; 86, 87; 86, 88; 87, identifier:credential; 88, None; 89, block; 89, 90; 90, raise_statement; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:errors; 94, identifier:JujuError; 95, argument_list; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, string:'Unable to find credential: {}'; 99, identifier:format; 100, argument_list; 100, 101; 101, identifier:name; 102, if_statement; 102, 103; 102, 114; 103, boolean_operator:and; 103, 104; 103, 109; 104, comparison_operator:==; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:credential; 107, identifier:auth_type; 108, string:'jsonfile'; 109, comparison_operator:in; 109, 110; 109, 111; 110, string:'file'; 111, attribute; 111, 112; 111, 113; 112, identifier:credential; 113, identifier:attrs; 114, block; 114, 115; 115, try_statement; 115, 116; 115, 128; 116, block; 116, 117; 117, expression_statement; 117, 118; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:json; 121, identifier:loads; 122, argument_list; 122, 123; 123, subscript; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:credential; 126, identifier:attrs; 127, string:'file'; 128, except_clause; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:json; 131, identifier:JSONDecodeError; 132, block; 132, 133; 132, 144; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:cred_path; 136, call; 136, 137; 136, 138; 137, identifier:Path; 138, argument_list; 138, 139; 139, subscript; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:credential; 142, identifier:attrs; 143, string:'file'; 144, if_statement; 144, 145; 144, 150; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:cred_path; 148, identifier:exists; 149, argument_list; 150, block; 150, 151; 150, 159; 150, 170; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:cred_json; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:credential; 157, identifier:to_json; 158, argument_list; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:credential; 162, call; 162, 163; 162, 168; 163, attribute; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:client; 166, identifier:CloudCredential; 167, identifier:from_json; 168, argument_list; 168, 169; 169, identifier:cred_json; 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:credential; 175, identifier:attrs; 176, string:'file'; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:cred_path; 180, identifier:read_text; 181, argument_list; 182, expression_statement; 182, 183; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:log; 186, identifier:debug; 187, argument_list; 187, 188; 187, 189; 188, string:'Uploading credential %s'; 189, identifier:name; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:cloud_facade; 193, call; 193, 194; 193, 199; 194, attribute; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:client; 197, identifier:CloudFacade; 198, identifier:from_connection; 199, argument_list; 199, 200; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:self; 203, identifier:connection; 204, argument_list; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:tagged_credentials; 208, list:[
client.UpdateCloudCredential(
tag=tag.credential(cloud, tag.untag('user-', owner), name),
credential=credential,
)]; 208, 209; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:client; 212, identifier:UpdateCloudCredential; 213, argument_list; 213, 214; 213, 230; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:tag; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:tag; 219, identifier:credential; 220, argument_list; 220, 221; 220, 222; 220, 229; 221, identifier:cloud; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:tag; 225, identifier:untag; 226, argument_list; 226, 227; 226, 228; 227, string:'user-'; 228, identifier:owner; 229, identifier:name; 230, keyword_argument; 230, 231; 230, 232; 231, identifier:credential; 232, identifier:credential; 233, if_statement; 233, 234; 233, 239; 233, 253; 234, comparison_operator:>=; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:cloud_facade; 237, identifier:version; 238, integer:3; 239, block; 239, 240; 240, expression_statement; 240, 241; 241, await; 241, 242; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:cloud_facade; 245, identifier:UpdateCredentialsCheckModels; 246, argument_list; 246, 247; 246, 250; 247, keyword_argument; 247, 248; 247, 249; 248, identifier:credentials; 249, identifier:tagged_credentials; 250, keyword_argument; 250, 251; 250, 252; 251, identifier:force; 252, identifier:force; 253, else_clause; 253, 254; 254, block; 254, 255; 255, expression_statement; 255, 256; 256, await; 256, 257; 257, call; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:cloud_facade; 260, identifier:UpdateCredentials; 261, argument_list; 261, 262; 262, identifier:tagged_credentials; 263, return_statement; 263, 264; 264, identifier:name | async def add_credential(self, name=None, credential=None, cloud=None,
owner=None, force=False):
if not cloud:
cloud = await self.get_cloud()
if not owner:
owner = self.connection().info['user-info']['identity']
if credential and not name:
raise errors.JujuError('Name must be provided for credential')
if not credential:
name, credential = self._connector.jujudata.load_credential(cloud,
name)
if credential is None:
raise errors.JujuError(
'Unable to find credential: {}'.format(name))
if credential.auth_type == 'jsonfile' and 'file' in credential.attrs:
try:
json.loads(credential.attrs['file'])
except json.JSONDecodeError:
cred_path = Path(credential.attrs['file'])
if cred_path.exists():
cred_json = credential.to_json()
credential = client.CloudCredential.from_json(cred_json)
credential.attrs['file'] = cred_path.read_text()
log.debug('Uploading credential %s', name)
cloud_facade = client.CloudFacade.from_connection(self.connection())
tagged_credentials = [
client.UpdateCloudCredential(
tag=tag.credential(cloud, tag.untag('user-', owner), name),
credential=credential,
)]
if cloud_facade.version >= 3:
await cloud_facade.UpdateCredentialsCheckModels(
credentials=tagged_credentials, force=force,
)
else:
await cloud_facade.UpdateCredentials(tagged_credentials)
return name |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:matches; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:specs; 7, block; 7, 8; 7, 67; 8, for_statement; 8, 9; 8, 10; 8, 11; 9, identifier:spec; 10, identifier:specs; 11, block; 11, 12; 11, 38; 12, if_statement; 12, 13; 12, 16; 12, 28; 13, comparison_operator:in; 13, 14; 13, 15; 14, string:':'; 15, identifier:spec; 16, block; 16, 17; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 22; 19, pattern_list; 19, 20; 19, 21; 20, identifier:app_name; 21, identifier:endpoint_name; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:spec; 25, identifier:split; 26, argument_list; 26, 27; 27, string:':'; 28, else_clause; 28, 29; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 35; 32, pattern_list; 32, 33; 32, 34; 33, identifier:app_name; 34, identifier:endpoint_name; 35, expression_list; 35, 36; 35, 37; 36, identifier:spec; 37, None; 38, for_statement; 38, 39; 38, 40; 38, 43; 38, 63; 39, identifier:endpoint; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:endpoints; 43, block; 43, 44; 44, if_statement; 44, 45; 44, 61; 45, boolean_operator:and; 45, 46; 45, 53; 45, 54; 46, comparison_operator:==; 46, 47; 46, 48; 47, identifier:app_name; 48, attribute; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:endpoint; 51, identifier:application; 52, identifier:name; 53, line_continuation:\; 54, comparison_operator:in; 54, 55; 54, 56; 55, identifier:endpoint_name; 56, tuple; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:endpoint; 59, identifier:name; 60, None; 61, block; 61, 62; 62, break_statement; 63, else_clause; 63, 64; 64, block; 64, 65; 65, return_statement; 65, 66; 66, False; 67, return_statement; 67, 68; 68, True | def matches(self, *specs):
for spec in specs:
if ':' in spec:
app_name, endpoint_name = spec.split(':')
else:
app_name, endpoint_name = spec, None
for endpoint in self.endpoints:
if app_name == endpoint.application.name and \
endpoint_name in (endpoint.name, None):
break
else:
return False
return True |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:source; 5, default_parameter; 5, 6; 5, 7; 6, identifier:requirement_files; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:force; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, identifier:keep_wheels; 13, False; 14, default_parameter; 14, 15; 14, 16; 15, identifier:archive_destination_dir; 16, string:'.'; 17, default_parameter; 17, 18; 17, 19; 18, identifier:python_versions; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:validate_archive; 22, False; 23, default_parameter; 23, 24; 23, 25; 24, identifier:wheel_args; 25, string:''; 26, default_parameter; 26, 27; 26, 28; 27, identifier:archive_format; 28, string:'zip'; 29, default_parameter; 29, 30; 29, 31; 30, identifier:build_tag; 31, string:''; 32, block; 32, 33; 32, 40; 32, 48; 32, 55; 32, 89; 32, 98; 32, 106; 32, 118; 32, 130; 32, 159; 32, 166; 32, 179; 32, 186; 32, 204; 32, 215; 32, 227; 32, 233; 32, 246; 32, 253; 32, 274; 32, 282; 32, 290; 33, if_statement; 33, 34; 33, 35; 34, identifier:validate_archive; 35, block; 35, 36; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 39; 38, identifier:_assert_virtualenv_is_installed; 39, argument_list; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:logger; 44, identifier:info; 45, argument_list; 45, 46; 45, 47; 46, string:'Creating archive for %s...'; 47, identifier:source; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:processed_source; 51, call; 51, 52; 51, 53; 52, identifier:get_source; 53, argument_list; 53, 54; 54, identifier:source; 55, if_statement; 55, 56; 55, 83; 56, boolean_operator:and; 56, 57; 56, 65; 57, call; 57, 58; 57, 63; 58, attribute; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:os; 61, identifier:path; 62, identifier:isdir; 63, argument_list; 63, 64; 64, identifier:processed_source; 65, not_operator; 65, 66; 65, 67; 66, line_continuation:\; 67, call; 67, 68; 67, 73; 68, attribute; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:os; 71, identifier:path; 72, identifier:isfile; 73, argument_list; 73, 74; 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:join; 80, argument_list; 80, 81; 80, 82; 81, identifier:processed_source; 82, string:'setup.py'; 83, block; 83, 84; 84, raise_statement; 84, 85; 85, call; 85, 86; 85, 87; 86, identifier:WagonError; 87, argument_list; 87, 88; 88, string:'Source directory must contain a setup.py file'; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 94; 91, pattern_list; 91, 92; 91, 93; 92, identifier:package_name; 93, identifier:package_version; 94, call; 94, 95; 94, 96; 95, identifier:get_source_name_and_version; 96, argument_list; 96, 97; 97, identifier:processed_source; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:tempdir; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:tempfile; 104, identifier:mkdtemp; 105, argument_list; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:workdir; 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:tempdir; 117, identifier:package_name; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 121; 120, identifier:wheels_path; 121, call; 121, 122; 121, 127; 122, attribute; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:os; 125, identifier:path; 126, identifier:join; 127, argument_list; 127, 128; 127, 129; 128, identifier:workdir; 129, identifier:DEFAULT_WHEELS_PATH; 130, try_statement; 130, 131; 130, 142; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:wheels; 135, call; 135, 136; 135, 137; 136, identifier:wheel; 137, argument_list; 137, 138; 137, 139; 137, 140; 137, 141; 138, identifier:processed_source; 139, identifier:requirement_files; 140, identifier:wheels_path; 141, identifier:wheel_args; 142, finally_clause; 142, 143; 143, block; 143, 144; 144, if_statement; 144, 145; 144, 148; 145, comparison_operator:!=; 145, 146; 145, 147; 146, identifier:processed_source; 147, identifier:source; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:shutil; 153, identifier:rmtree; 154, argument_list; 154, 155; 154, 156; 155, identifier:processed_source; 156, keyword_argument; 156, 157; 156, 158; 157, identifier:ignore_errors; 158, True; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:platform; 162, call; 162, 163; 162, 164; 163, identifier:_get_platform_for_set_of_wheels; 164, argument_list; 164, 165; 165, identifier:wheels_path; 166, if_statement; 166, 167; 166, 170; 167, call; 167, 168; 167, 169; 168, identifier:is_verbose; 169, argument_list; 170, block; 170, 171; 171, expression_statement; 171, 172; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:logger; 175, identifier:debug; 176, argument_list; 176, 177; 176, 178; 177, string:'Platform is: %s'; 178, identifier:platform; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:python_versions; 182, call; 182, 183; 182, 184; 183, identifier:_set_python_versions; 184, argument_list; 184, 185; 185, identifier:python_versions; 186, if_statement; 186, 187; 186, 196; 187, not_operator; 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:isdir; 194, argument_list; 194, 195; 195, identifier:archive_destination_dir; 196, block; 196, 197; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:os; 201, identifier:makedirs; 202, argument_list; 202, 203; 203, identifier:archive_destination_dir; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 207; 206, identifier:archive_name; 207, call; 207, 208; 207, 209; 208, identifier:_set_archive_name; 209, argument_list; 209, 210; 209, 211; 209, 212; 209, 213; 209, 214; 210, identifier:package_name; 211, identifier:package_version; 212, identifier:python_versions; 213, identifier:platform; 214, identifier:build_tag; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:archive_path; 218, call; 218, 219; 218, 224; 219, attribute; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:os; 222, identifier:path; 223, identifier:join; 224, argument_list; 224, 225; 224, 226; 225, identifier:archive_destination_dir; 226, identifier:archive_name; 227, expression_statement; 227, 228; 228, call; 228, 229; 228, 230; 229, identifier:_handle_output_file; 230, argument_list; 230, 231; 230, 232; 231, identifier:archive_path; 232, identifier:force; 233, expression_statement; 233, 234; 234, call; 234, 235; 234, 236; 235, identifier:_generate_metadata_file; 236, argument_list; 236, 237; 236, 238; 236, 239; 236, 240; 236, 241; 236, 242; 236, 243; 236, 244; 236, 245; 237, identifier:workdir; 238, identifier:archive_name; 239, identifier:platform; 240, identifier:python_versions; 241, identifier:package_name; 242, identifier:package_version; 243, identifier:build_tag; 244, identifier:source; 245, identifier:wheels; 246, expression_statement; 246, 247; 247, call; 247, 248; 247, 249; 248, identifier:_create_wagon_archive; 249, argument_list; 249, 250; 249, 251; 249, 252; 250, identifier:workdir; 251, identifier:archive_path; 252, identifier:archive_format; 253, if_statement; 253, 254; 253, 256; 254, not_operator; 254, 255; 255, identifier:keep_wheels; 256, block; 256, 257; 256, 264; 257, expression_statement; 257, 258; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:logger; 261, identifier:debug; 262, argument_list; 262, 263; 263, string:'Removing work directory...'; 264, expression_statement; 264, 265; 265, call; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:shutil; 268, identifier:rmtree; 269, argument_list; 269, 270; 269, 271; 270, identifier:tempdir; 271, keyword_argument; 271, 272; 271, 273; 272, identifier:ignore_errors; 273, True; 274, if_statement; 274, 275; 274, 276; 275, identifier:validate_archive; 276, block; 276, 277; 277, expression_statement; 277, 278; 278, call; 278, 279; 278, 280; 279, identifier:validate; 280, argument_list; 280, 281; 281, identifier:archive_path; 282, expression_statement; 282, 283; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:logger; 286, identifier:info; 287, argument_list; 287, 288; 287, 289; 288, string:'Wagon created successfully at: %s'; 289, identifier:archive_path; 290, return_statement; 290, 291; 291, identifier:archive_path | def create(source,
requirement_files=None,
force=False,
keep_wheels=False,
archive_destination_dir='.',
python_versions=None,
validate_archive=False,
wheel_args='',
archive_format='zip',
build_tag=''):
if validate_archive:
_assert_virtualenv_is_installed()
logger.info('Creating archive for %s...', source)
processed_source = get_source(source)
if os.path.isdir(processed_source) and not \
os.path.isfile(os.path.join(processed_source, 'setup.py')):
raise WagonError(
'Source directory must contain a setup.py file')
package_name, package_version = get_source_name_and_version(
processed_source)
tempdir = tempfile.mkdtemp()
workdir = os.path.join(tempdir, package_name)
wheels_path = os.path.join(workdir, DEFAULT_WHEELS_PATH)
try:
wheels = wheel(
processed_source,
requirement_files,
wheels_path,
wheel_args)
finally:
if processed_source != source:
shutil.rmtree(processed_source, ignore_errors=True)
platform = _get_platform_for_set_of_wheels(wheels_path)
if is_verbose():
logger.debug('Platform is: %s', platform)
python_versions = _set_python_versions(python_versions)
if not os.path.isdir(archive_destination_dir):
os.makedirs(archive_destination_dir)
archive_name = _set_archive_name(
package_name, package_version, python_versions, platform, build_tag)
archive_path = os.path.join(archive_destination_dir, archive_name)
_handle_output_file(archive_path, force)
_generate_metadata_file(
workdir,
archive_name,
platform,
python_versions,
package_name,
package_version,
build_tag,
source,
wheels)
_create_wagon_archive(workdir, archive_path, archive_format)
if not keep_wheels:
logger.debug('Removing work directory...')
shutil.rmtree(tempdir, ignore_errors=True)
if validate_archive:
validate(archive_path)
logger.info('Wagon created successfully at: %s', archive_path)
return archive_path |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:build_trading_timeline; 3, parameters; 3, 4; 3, 5; 4, identifier:start; 5, identifier:end; 6, block; 6, 7; 6, 9; 6, 26; 6, 41; 6, 324; 7, expression_statement; 7, 8; 8, string:''' Build the daily-based index we will trade on '''; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:EMPTY_DATES; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:pd; 15, identifier:date_range; 16, argument_list; 16, 17; 16, 18; 16, 21; 17, string:'2000/01/01'; 18, keyword_argument; 18, 19; 18, 20; 19, identifier:periods; 20, integer:0; 21, keyword_argument; 21, 22; 21, 23; 22, identifier:tz; 23, attribute; 23, 24; 23, 25; 24, identifier:pytz; 25, identifier:utc; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:now; 29, call; 29, 30; 29, 35; 30, attribute; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:dt; 33, identifier:datetime; 34, identifier:now; 35, argument_list; 35, 36; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:tz; 38, attribute; 38, 39; 38, 40; 39, identifier:pytz; 40, identifier:utc; 41, if_statement; 41, 42; 41, 44; 41, 133; 42, not_operator; 42, 43; 43, identifier:start; 44, block; 44, 45; 45, if_statement; 45, 46; 45, 48; 45, 70; 46, not_operator; 46, 47; 47, identifier:end; 48, block; 48, 49; 48, 53; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:bt_dates; 52, identifier:EMPTY_DATES; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:live_dates; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:pd; 59, identifier:date_range; 60, argument_list; 60, 61; 60, 64; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:start; 63, identifier:now; 64, keyword_argument; 64, 65; 64, 66; 65, identifier:end; 66, call; 66, 67; 66, 68; 67, identifier:normalize_date_format; 68, argument_list; 68, 69; 69, string:'23h59'; 70, else_clause; 70, 71; 71, block; 71, 72; 71, 79; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:end; 75, call; 75, 76; 75, 77; 76, identifier:normalize_date_format; 77, argument_list; 77, 78; 78, identifier:end; 79, if_statement; 79, 80; 79, 83; 79, 110; 80, comparison_operator:<; 80, 81; 80, 82; 81, identifier:end; 82, identifier:now; 83, block; 83, 84; 83, 106; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:bt_dates; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:pd; 90, identifier:date_range; 91, argument_list; 91, 92; 91, 103; 92, keyword_argument; 92, 93; 92, 94; 93, identifier:start; 94, binary_operator:-; 94, 95; 94, 96; 95, identifier:end; 96, binary_operator:*; 96, 97; 96, 98; 97, integer:360; 98, attribute; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:pd; 101, identifier:datetools; 102, identifier:day; 103, keyword_argument; 103, 104; 103, 105; 104, identifier:end; 105, identifier:end; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:live_dates; 109, identifier:EMPTY_DATES; 110, elif_clause; 110, 111; 110, 114; 111, comparison_operator:>; 111, 112; 111, 113; 112, identifier:end; 113, identifier:now; 114, block; 114, 115; 114, 119; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:bt_dates; 118, identifier:EMPTY_DATES; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:live_dates; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:pd; 125, identifier:date_range; 126, argument_list; 126, 127; 126, 130; 127, keyword_argument; 127, 128; 127, 129; 128, identifier:start; 129, identifier:now; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:end; 132, identifier:end; 133, else_clause; 133, 134; 134, block; 134, 135; 134, 142; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:start; 138, call; 138, 139; 138, 140; 139, identifier:normalize_date_format; 140, argument_list; 140, 141; 141, identifier:start; 142, if_statement; 142, 143; 142, 146; 142, 267; 143, comparison_operator:<; 143, 144; 143, 145; 144, identifier:start; 145, identifier:now; 146, block; 146, 147; 147, if_statement; 147, 148; 147, 150; 147, 196; 148, not_operator; 148, 149; 149, identifier:end; 150, block; 150, 151; 150, 163; 150, 178; 150, 182; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:end; 154, binary_operator:+; 154, 155; 154, 156; 155, identifier:start; 156, binary_operator:*; 156, 157; 156, 158; 157, integer:360; 158, attribute; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:pd; 161, identifier:datetools; 162, identifier:day; 163, if_statement; 163, 164; 163, 167; 164, comparison_operator:>; 164, 165; 164, 166; 165, identifier:end; 166, identifier:now; 167, block; 167, 168; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:end; 171, binary_operator:-; 171, 172; 171, 173; 172, identifier:now; 173, attribute; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:pd; 176, identifier:datetools; 177, identifier:day; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:live_dates; 181, identifier:EMPTY_DATES; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:bt_dates; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:pd; 188, identifier:date_range; 189, argument_list; 189, 190; 189, 193; 190, keyword_argument; 190, 191; 190, 192; 191, identifier:start; 192, identifier:start; 193, keyword_argument; 193, 194; 193, 195; 194, identifier:end; 195, identifier:end; 196, else_clause; 196, 197; 197, block; 197, 198; 197, 205; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:end; 201, call; 201, 202; 201, 203; 202, identifier:normalize_date_format; 203, argument_list; 203, 204; 204, identifier:end; 205, if_statement; 205, 206; 205, 209; 205, 228; 206, comparison_operator:<; 206, 207; 206, 208; 207, identifier:end; 208, identifier:now; 209, block; 209, 210; 209, 214; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:live_dates; 213, identifier:EMPTY_DATES; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 217; 216, identifier:bt_dates; 217, call; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:pd; 220, identifier:date_range; 221, argument_list; 221, 222; 221, 225; 222, keyword_argument; 222, 223; 222, 224; 223, identifier:start; 224, identifier:start; 225, keyword_argument; 225, 226; 225, 227; 226, identifier:end; 227, identifier:end; 228, elif_clause; 228, 229; 228, 232; 229, comparison_operator:>; 229, 230; 229, 231; 230, identifier:end; 231, identifier:now; 232, block; 232, 233; 232, 253; 233, expression_statement; 233, 234; 234, assignment; 234, 235; 234, 236; 235, identifier:bt_dates; 236, call; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:pd; 239, identifier:date_range; 240, argument_list; 240, 241; 240, 244; 241, keyword_argument; 241, 242; 241, 243; 242, identifier:start; 243, identifier:start; 244, keyword_argument; 244, 245; 244, 246; 245, identifier:end; 246, binary_operator:-; 246, 247; 246, 248; 247, identifier:now; 248, attribute; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:pd; 251, identifier:datetools; 252, identifier:day; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 256; 255, identifier:live_dates; 256, call; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:pd; 259, identifier:date_range; 260, argument_list; 260, 261; 260, 264; 261, keyword_argument; 261, 262; 261, 263; 262, identifier:start; 263, identifier:now; 264, keyword_argument; 264, 265; 264, 266; 265, identifier:end; 266, identifier:end; 267, elif_clause; 267, 268; 267, 271; 268, comparison_operator:>; 268, 269; 268, 270; 269, identifier:start; 270, identifier:now; 271, block; 271, 272; 272, if_statement; 272, 273; 272, 275; 272, 297; 273, not_operator; 273, 274; 274, identifier:end; 275, block; 275, 276; 275, 280; 276, expression_statement; 276, 277; 277, assignment; 277, 278; 277, 279; 278, identifier:bt_dates; 279, identifier:EMPTY_DATES; 280, expression_statement; 280, 281; 281, assignment; 281, 282; 281, 283; 282, identifier:live_dates; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:pd; 286, identifier:date_range; 287, argument_list; 287, 288; 287, 291; 288, keyword_argument; 288, 289; 288, 290; 289, identifier:start; 290, identifier:start; 291, keyword_argument; 291, 292; 291, 293; 292, identifier:end; 293, call; 293, 294; 293, 295; 294, identifier:normalize_date_format; 295, argument_list; 295, 296; 296, string:'23h59'; 297, else_clause; 297, 298; 298, block; 298, 299; 298, 306; 298, 310; 299, expression_statement; 299, 300; 300, assignment; 300, 301; 300, 302; 301, identifier:end; 302, call; 302, 303; 302, 304; 303, identifier:normalize_date_format; 304, argument_list; 304, 305; 305, identifier:end; 306, expression_statement; 306, 307; 307, assignment; 307, 308; 307, 309; 308, identifier:bt_dates; 309, identifier:EMPTY_DATES; 310, expression_statement; 310, 311; 311, assignment; 311, 312; 311, 313; 312, identifier:live_dates; 313, call; 313, 314; 313, 317; 314, attribute; 314, 315; 314, 316; 315, identifier:pd; 316, identifier:date_range; 317, argument_list; 317, 318; 317, 321; 318, keyword_argument; 318, 319; 318, 320; 319, identifier:start; 320, identifier:start; 321, keyword_argument; 321, 322; 321, 323; 322, identifier:end; 323, identifier:end; 324, return_statement; 324, 325; 325, binary_operator:+; 325, 326; 325, 327; 326, identifier:bt_dates; 327, identifier:live_dates | def build_trading_timeline(start, end):
''' Build the daily-based index we will trade on '''
EMPTY_DATES = pd.date_range('2000/01/01', periods=0, tz=pytz.utc)
now = dt.datetime.now(tz=pytz.utc)
if not start:
if not end:
bt_dates = EMPTY_DATES
live_dates = pd.date_range(
start=now,
end=normalize_date_format('23h59'))
else:
end = normalize_date_format(end)
if end < now:
bt_dates = pd.date_range(
start=end - 360 * pd.datetools.day,
end=end)
live_dates = EMPTY_DATES
elif end > now:
bt_dates = EMPTY_DATES
live_dates = pd.date_range(start=now, end=end)
else:
start = normalize_date_format(start)
if start < now:
if not end:
end = start + 360 * pd.datetools.day
if end > now:
end = now - pd.datetools.day
live_dates = EMPTY_DATES
bt_dates = pd.date_range(
start=start, end=end)
else:
end = normalize_date_format(end)
if end < now:
live_dates = EMPTY_DATES
bt_dates = pd.date_range(start=start, end=end)
elif end > now:
bt_dates = pd.date_range(
start=start, end=now - pd.datetools.day)
live_dates = pd.date_range(start=now, end=end)
elif start > now:
if not end:
bt_dates = EMPTY_DATES
live_dates = pd.date_range(
start=start,
end=normalize_date_format('23h59'))
else:
end = normalize_date_format(end)
bt_dates = EMPTY_DATES
live_dates = pd.date_range(start=start, end=end)
return bt_dates + live_dates |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:gcal2jd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:year; 5, identifier:month; 6, identifier:day; 7, block; 7, 8; 7, 15; 7, 22; 7, 29; 7, 41; 7, 58; 7, 77; 7, 91; 7, 103; 7, 109; 7, 113; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:year; 11, call; 11, 12; 11, 13; 12, identifier:int; 13, argument_list; 13, 14; 14, identifier:year; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:month; 18, call; 18, 19; 18, 20; 19, identifier:int; 20, argument_list; 20, 21; 21, identifier:month; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:day; 25, call; 25, 26; 25, 27; 26, identifier:int; 27, argument_list; 27, 28; 28, identifier:day; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:a; 32, call; 32, 33; 32, 34; 33, identifier:ipart; 34, argument_list; 34, 35; 35, binary_operator:/; 35, 36; 35, 40; 36, parenthesized_expression; 36, 37; 37, binary_operator:-; 37, 38; 37, 39; 38, identifier:month; 39, integer:14; 40, float:12.0; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:jd; 44, call; 44, 45; 44, 46; 45, identifier:ipart; 46, argument_list; 46, 47; 47, binary_operator:/; 47, 48; 47, 57; 48, parenthesized_expression; 48, 49; 49, binary_operator:*; 49, 50; 49, 51; 50, integer:1461; 51, parenthesized_expression; 51, 52; 52, binary_operator:+; 52, 53; 52, 56; 53, binary_operator:+; 53, 54; 53, 55; 54, identifier:year; 55, integer:4800; 56, identifier:a; 57, float:4.0; 58, expression_statement; 58, 59; 59, augmented_assignment:+=; 59, 60; 59, 61; 60, identifier:jd; 61, call; 61, 62; 61, 63; 62, identifier:ipart; 63, argument_list; 63, 64; 64, binary_operator:/; 64, 65; 64, 76; 65, parenthesized_expression; 65, 66; 66, binary_operator:*; 66, 67; 66, 68; 67, integer:367; 68, parenthesized_expression; 68, 69; 69, binary_operator:-; 69, 70; 69, 73; 70, binary_operator:-; 70, 71; 70, 72; 71, identifier:month; 72, integer:2; 73, binary_operator:*; 73, 74; 73, 75; 74, integer:12; 75, identifier:a; 76, float:12.0; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:x; 80, call; 80, 81; 80, 82; 81, identifier:ipart; 82, argument_list; 82, 83; 83, binary_operator:/; 83, 84; 83, 90; 84, parenthesized_expression; 84, 85; 85, binary_operator:+; 85, 86; 85, 89; 86, binary_operator:+; 86, 87; 86, 88; 87, identifier:year; 88, integer:4900; 89, identifier:a; 90, float:100.0; 91, expression_statement; 91, 92; 92, augmented_assignment:-=; 92, 93; 92, 94; 93, identifier:jd; 94, call; 94, 95; 94, 96; 95, identifier:ipart; 96, argument_list; 96, 97; 97, binary_operator:/; 97, 98; 97, 102; 98, parenthesized_expression; 98, 99; 99, binary_operator:*; 99, 100; 99, 101; 100, integer:3; 101, identifier:x; 102, float:4.0; 103, expression_statement; 103, 104; 104, augmented_assignment:+=; 104, 105; 104, 106; 105, identifier:jd; 106, binary_operator:-; 106, 107; 106, 108; 107, identifier:day; 108, float:2432075.5; 109, expression_statement; 109, 110; 110, augmented_assignment:-=; 110, 111; 110, 112; 111, identifier:jd; 112, float:0.5; 113, return_statement; 113, 114; 114, expression_list; 114, 115; 114, 116; 115, identifier:MJD_0; 116, identifier:jd | def gcal2jd(year, month, day):
year = int(year)
month = int(month)
day = int(day)
a = ipart((month - 14) / 12.0)
jd = ipart((1461 * (year + 4800 + a)) / 4.0)
jd += ipart((367 * (month - 2 - 12 * a)) / 12.0)
x = ipart((year + 4900 + a) / 100.0)
jd -= ipart((3 * x) / 4.0)
jd += day - 2432075.5
jd -= 0.5
return MJD_0, jd |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_check_restart_params; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:restart_strategy; 6, identifier:min_beta; 7, identifier:s_greedy; 8, identifier:xi_restart; 9, block; 9, 10; 9, 12; 9, 19; 9, 33; 9, 48; 9, 62; 9, 76; 10, expression_statement; 10, 11; 11, identifier:r; 12, if_statement; 12, 13; 12, 16; 13, comparison_operator:is; 13, 14; 13, 15; 14, identifier:restart_strategy; 15, None; 16, block; 16, 17; 17, return_statement; 17, 18; 18, True; 19, if_statement; 19, 20; 19, 25; 20, comparison_operator:!=; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:mode; 24, string:'regular'; 25, block; 25, 26; 26, raise_statement; 26, 27; 27, call; 27, 28; 27, 29; 28, identifier:ValueError; 29, argument_list; 29, 30; 30, concatenated_string; 30, 31; 30, 32; 31, string:'Restarting strategies can only be used with '; 32, string:'regular mode.'; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:greedy_params_check; 36, parenthesized_expression; 36, 37; 37, boolean_operator:or; 37, 38; 37, 45; 38, boolean_operator:or; 38, 39; 38, 42; 39, comparison_operator:is; 39, 40; 39, 41; 40, identifier:min_beta; 41, None; 42, comparison_operator:is; 42, 43; 42, 44; 43, identifier:s_greedy; 44, None; 45, comparison_operator:<=; 45, 46; 45, 47; 46, identifier:s_greedy; 47, integer:1; 48, if_statement; 48, 49; 48, 54; 49, boolean_operator:and; 49, 50; 49, 53; 50, comparison_operator:==; 50, 51; 50, 52; 51, identifier:restart_strategy; 52, string:'greedy'; 53, identifier:greedy_params_check; 54, block; 54, 55; 55, raise_statement; 55, 56; 56, call; 56, 57; 56, 58; 57, identifier:ValueError; 58, argument_list; 58, 59; 59, concatenated_string; 59, 60; 59, 61; 60, string:'You need a min_beta and an s_greedy > 1 for '; 61, string:'greedy restart.'; 62, if_statement; 62, 63; 62, 70; 63, boolean_operator:or; 63, 64; 63, 67; 64, comparison_operator:is; 64, 65; 64, 66; 65, identifier:xi_restart; 66, None; 67, comparison_operator:>=; 67, 68; 67, 69; 68, identifier:xi_restart; 69, integer:1; 70, block; 70, 71; 71, raise_statement; 71, 72; 72, call; 72, 73; 72, 74; 73, identifier:ValueError; 74, argument_list; 74, 75; 75, string:'You need a xi_restart < 1 for restart.'; 76, return_statement; 76, 77; 77, True | def _check_restart_params(self, restart_strategy, min_beta, s_greedy,
xi_restart):
r
if restart_strategy is None:
return True
if self.mode != 'regular':
raise ValueError('Restarting strategies can only be used with '
'regular mode.')
greedy_params_check = (min_beta is None or s_greedy is None or
s_greedy <= 1)
if restart_strategy == 'greedy' and greedy_params_check:
raise ValueError('You need a min_beta and an s_greedy > 1 for '
'greedy restart.')
if xi_restart is None or xi_restart >= 1:
raise ValueError('You need a xi_restart < 1 for restart.')
return True |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:method_cache; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:by; 6, string:'value'; 7, default_parameter; 7, 8; 7, 9; 8, identifier:method; 9, string:'run'; 10, block; 10, 11; 10, 243; 11, function_definition; 11, 12; 11, 13; 11, 15; 12, function_name:decorate_; 13, parameters; 13, 14; 14, identifier:func; 15, block; 15, 16; 15, 241; 16, function_definition; 16, 17; 16, 18; 16, 23; 17, function_name:decorate; 18, parameters; 18, 19; 18, 21; 19, list_splat_pattern; 19, 20; 20, identifier:args; 21, dictionary_splat_pattern; 21, 22; 22, identifier:kwargs; 23, block; 23, 24; 23, 30; 23, 39; 23, 63; 23, 81; 23, 89; 23, 167; 23, 233; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:model; 27, subscript; 27, 28; 27, 29; 28, identifier:args; 29, integer:0; 30, assert_statement; 30, 31; 30, 36; 31, call; 31, 32; 31, 33; 32, identifier:hasattr; 33, argument_list; 33, 34; 33, 35; 34, identifier:model; 35, identifier:method; 36, binary_operator:%; 36, 37; 36, 38; 37, string:"Model must have a '%s' method."; 38, identifier:method; 39, if_statement; 39, 40; 39, 45; 39, 50; 40, comparison_operator:==; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:func; 43, identifier:__name__; 44, identifier:method; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:method_args; 49, identifier:kwargs; 50, else_clause; 50, 51; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:method_args; 55, conditional_expression:if; 55, 56; 55, 59; 55, 62; 56, subscript; 56, 57; 56, 58; 57, identifier:kwargs; 58, identifier:method; 59, comparison_operator:in; 59, 60; 59, 61; 60, identifier:method; 61, identifier:kwargs; 62, dictionary; 63, if_statement; 63, 64; 63, 72; 64, not_operator; 64, 65; 65, call; 65, 66; 65, 67; 66, identifier:hasattr; 67, argument_list; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:model; 70, identifier:__class__; 71, string:'cached_runs'; 72, block; 72, 73; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:model; 78, identifier:__class__; 79, identifier:cached_runs; 80, dictionary; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:cache; 84, attribute; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:model; 87, identifier:__class__; 88, identifier:cached_runs; 89, if_statement; 89, 90; 89, 93; 89, 137; 89, 160; 90, comparison_operator:==; 90, 91; 90, 92; 91, identifier:by; 92, string:'value'; 93, block; 93, 94; 93, 122; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:model_dict; 97, dictionary_comprehension; 97, 98; 97, 101; 97, 115; 97, 116; 98, pair; 98, 99; 98, 100; 99, identifier:key; 100, identifier:value; 101, for_in_clause; 101, 102; 101, 105; 102, pattern_list; 102, 103; 102, 104; 103, identifier:key; 104, identifier:value; 105, call; 105, 106; 105, 107; 106, identifier:list; 107, argument_list; 107, 108; 108, call; 108, 109; 108, 114; 109, attribute; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:model; 112, identifier:__dict__; 113, identifier:items; 114, argument_list; 115, line_continuation:\; 116, if_clause; 116, 117; 117, comparison_operator:!=; 117, 118; 117, 121; 118, subscript; 118, 119; 118, 120; 119, identifier:key; 120, integer:0; 121, string:'_'; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:method_signature; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:SciUnit; 128, identifier:dict_hash; 129, argument_list; 129, 130; 130, dictionary; 130, 131; 130, 134; 131, pair; 131, 132; 131, 133; 132, string:'attrs'; 133, identifier:model_dict; 134, pair; 134, 135; 134, 136; 135, string:'args'; 136, identifier:method_args; 137, elif_clause; 137, 138; 137, 141; 138, comparison_operator:==; 138, 139; 138, 140; 139, identifier:by; 140, string:'instance'; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:method_signature; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:SciUnit; 148, identifier:dict_hash; 149, argument_list; 149, 150; 150, dictionary; 150, 151; 150, 157; 151, pair; 151, 152; 151, 153; 152, string:'id'; 153, call; 153, 154; 153, 155; 154, identifier:id; 155, argument_list; 155, 156; 156, identifier:model; 157, pair; 157, 158; 157, 159; 158, string:'args'; 159, identifier:method_args; 160, else_clause; 160, 161; 161, block; 161, 162; 162, raise_statement; 162, 163; 163, call; 163, 164; 163, 165; 164, identifier:ValueError; 165, argument_list; 165, 166; 166, string:"Cache type must be 'value' or 'instance'"; 167, if_statement; 167, 168; 167, 171; 167, 209; 168, comparison_operator:not; 168, 169; 168, 170; 169, identifier:method_signature; 170, identifier:cache; 171, block; 171, 172; 171, 177; 171, 185; 171, 191; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 175; 174, identifier:print; 175, argument_list; 175, 176; 176, string:"Method with this signature not found in the cache. Running..."; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:f; 180, call; 180, 181; 180, 182; 181, identifier:getattr; 182, argument_list; 182, 183; 182, 184; 183, identifier:model; 184, identifier:method; 185, expression_statement; 185, 186; 186, call; 186, 187; 186, 188; 187, identifier:f; 188, argument_list; 188, 189; 189, dictionary_splat; 189, 190; 190, identifier:method_args; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 196; 193, subscript; 193, 194; 193, 195; 194, identifier:cache; 195, identifier:method_signature; 196, tuple; 196, 197; 196, 202; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:datetime; 200, identifier:now; 201, argument_list; 202, call; 202, 203; 202, 208; 203, attribute; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:model; 206, identifier:__dict__; 207, identifier:copy; 208, argument_list; 209, else_clause; 209, 210; 210, block; 210, 211; 210, 216; 210, 224; 211, expression_statement; 211, 212; 212, call; 212, 213; 212, 214; 213, identifier:print; 214, argument_list; 214, 215; 215, string:"Method with this signature found in the cache. Restoring..."; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 221; 218, pattern_list; 218, 219; 218, 220; 219, identifier:_; 220, identifier:attrs; 221, subscript; 221, 222; 221, 223; 222, identifier:cache; 223, identifier:method_signature; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 231; 226, attribute; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:model; 229, identifier:__dict__; 230, identifier:update; 231, argument_list; 231, 232; 232, identifier:attrs; 233, return_statement; 233, 234; 234, call; 234, 235; 234, 236; 235, identifier:func; 236, argument_list; 236, 237; 236, 239; 237, list_splat; 237, 238; 238, identifier:args; 239, dictionary_splat; 239, 240; 240, identifier:kwargs; 241, return_statement; 241, 242; 242, identifier:decorate; 243, return_statement; 243, 244; 244, identifier:decorate_ | def method_cache(by='value',method='run'):
def decorate_(func):
def decorate(*args, **kwargs):
model = args[0]
assert hasattr(model,method), "Model must have a '%s' method."%method
if func.__name__ == method:
method_args = kwargs
else:
method_args = kwargs[method] if method in kwargs else {}
if not hasattr(model.__class__,'cached_runs'):
model.__class__.cached_runs = {}
cache = model.__class__.cached_runs
if by == 'value':
model_dict = {key:value for key,value in list(model.__dict__.items()) \
if key[0]!='_'}
method_signature = SciUnit.dict_hash({'attrs':model_dict,'args':method_args})
elif by == 'instance':
method_signature = SciUnit.dict_hash({'id':id(model),'args':method_args})
else:
raise ValueError("Cache type must be 'value' or 'instance'")
if method_signature not in cache:
print("Method with this signature not found in the cache. Running...")
f = getattr(model,method)
f(**method_args)
cache[method_signature] = (datetime.now(),model.__dict__.copy())
else:
print("Method with this signature found in the cache. Restoring...")
_,attrs = cache[method_signature]
model.__dict__.update(attrs)
return func(*args, **kwargs)
return decorate
return decorate_ |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_format_command; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:ctx; 5, identifier:show_nested; 6, default_parameter; 6, 7; 6, 8; 7, identifier:commands; 8, None; 9, block; 9, 10; 9, 21; 9, 31; 9, 41; 9, 51; 9, 61; 9, 70; 9, 77; 9, 87; 9, 96; 9, 103; 9, 113; 9, 122; 9, 129; 9, 133; 9, 141; 9, 150; 10, if_statement; 10, 11; 10, 19; 11, call; 11, 12; 11, 13; 12, identifier:getattr; 13, argument_list; 13, 14; 13, 17; 13, 18; 14, attribute; 14, 15; 14, 16; 15, identifier:ctx; 16, identifier:command; 17, string:'hidden'; 18, False; 19, block; 19, 20; 20, return_statement; 21, for_statement; 21, 22; 21, 23; 21, 27; 22, identifier:line; 23, call; 23, 24; 23, 25; 24, identifier:_format_description; 25, argument_list; 25, 26; 26, identifier:ctx; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, yield; 29, 30; 30, identifier:line; 31, expression_statement; 31, 32; 32, yield; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, string:'.. program:: {}'; 36, identifier:format; 37, argument_list; 37, 38; 38, attribute; 38, 39; 38, 40; 39, identifier:ctx; 40, identifier:command_path; 41, for_statement; 41, 42; 41, 43; 41, 47; 42, identifier:line; 43, call; 43, 44; 43, 45; 44, identifier:_format_usage; 45, argument_list; 45, 46; 46, identifier:ctx; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, yield; 49, 50; 50, identifier:line; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:lines; 54, call; 54, 55; 54, 56; 55, identifier:list; 56, argument_list; 56, 57; 57, call; 57, 58; 57, 59; 58, identifier:_format_options; 59, argument_list; 59, 60; 60, identifier:ctx; 61, if_statement; 61, 62; 61, 63; 62, identifier:lines; 63, block; 63, 64; 63, 67; 64, expression_statement; 64, 65; 65, yield; 65, 66; 66, string:'.. rubric:: Options'; 67, expression_statement; 67, 68; 68, yield; 68, 69; 69, string:''; 70, for_statement; 70, 71; 70, 72; 70, 73; 71, identifier:line; 72, identifier:lines; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, yield; 75, 76; 76, identifier:line; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:lines; 80, call; 80, 81; 80, 82; 81, identifier:list; 82, argument_list; 82, 83; 83, call; 83, 84; 83, 85; 84, identifier:_format_arguments; 85, argument_list; 85, 86; 86, identifier:ctx; 87, if_statement; 87, 88; 87, 89; 88, identifier:lines; 89, block; 89, 90; 89, 93; 90, expression_statement; 90, 91; 91, yield; 91, 92; 92, string:'.. rubric:: Arguments'; 93, expression_statement; 93, 94; 94, yield; 94, 95; 95, string:''; 96, for_statement; 96, 97; 96, 98; 96, 99; 97, identifier:line; 98, identifier:lines; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, yield; 101, 102; 102, identifier:line; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:lines; 106, call; 106, 107; 106, 108; 107, identifier:list; 108, argument_list; 108, 109; 109, call; 109, 110; 109, 111; 110, identifier:_format_envvars; 111, argument_list; 111, 112; 112, identifier:ctx; 113, if_statement; 113, 114; 113, 115; 114, identifier:lines; 115, block; 115, 116; 115, 119; 116, expression_statement; 116, 117; 117, yield; 117, 118; 118, string:'.. rubric:: Environment variables'; 119, expression_statement; 119, 120; 120, yield; 120, 121; 121, string:''; 122, for_statement; 122, 123; 122, 124; 122, 125; 123, identifier:line; 124, identifier:lines; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, yield; 127, 128; 128, identifier:line; 129, if_statement; 129, 130; 129, 131; 130, identifier:show_nested; 131, block; 131, 132; 132, return_statement; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:commands; 136, call; 136, 137; 136, 138; 137, identifier:_filter_commands; 138, argument_list; 138, 139; 138, 140; 139, identifier:ctx; 140, identifier:commands; 141, if_statement; 141, 142; 141, 143; 142, identifier:commands; 143, block; 143, 144; 143, 147; 144, expression_statement; 144, 145; 145, yield; 145, 146; 146, string:'.. rubric:: Commands'; 147, expression_statement; 147, 148; 148, yield; 148, 149; 149, string:''; 150, for_statement; 150, 151; 150, 152; 150, 153; 151, identifier:command; 152, identifier:commands; 153, block; 153, 154; 153, 167; 153, 177; 154, if_statement; 154, 155; 154, 160; 155, comparison_operator:>=; 155, 156; 155, 157; 156, identifier:CLICK_VERSION; 157, tuple; 157, 158; 157, 159; 158, integer:7; 159, integer:0; 160, block; 160, 161; 161, if_statement; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:command; 164, identifier:hidden; 165, block; 165, 166; 166, continue_statement; 167, for_statement; 167, 168; 167, 169; 167, 173; 168, identifier:line; 169, call; 169, 170; 169, 171; 170, identifier:_format_subcommand; 171, argument_list; 171, 172; 172, identifier:command; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, yield; 175, 176; 176, identifier:line; 177, expression_statement; 177, 178; 178, yield; 178, 179; 179, string:'' | def _format_command(ctx, show_nested, commands=None):
if getattr(ctx.command, 'hidden', False):
return
for line in _format_description(ctx):
yield line
yield '.. program:: {}'.format(ctx.command_path)
for line in _format_usage(ctx):
yield line
lines = list(_format_options(ctx))
if lines:
yield '.. rubric:: Options'
yield ''
for line in lines:
yield line
lines = list(_format_arguments(ctx))
if lines:
yield '.. rubric:: Arguments'
yield ''
for line in lines:
yield line
lines = list(_format_envvars(ctx))
if lines:
yield '.. rubric:: Environment variables'
yield ''
for line in lines:
yield line
if show_nested:
return
commands = _filter_commands(ctx, commands)
if commands:
yield '.. rubric:: Commands'
yield ''
for command in commands:
if CLICK_VERSION >= (7, 0):
if command.hidden:
continue
for line in _format_subcommand(command):
yield line
yield '' |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:_formatter; 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:x; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:y; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:z; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:s; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:label; 19, None; 20, dictionary_splat_pattern; 20, 21; 21, identifier:kwargs; 22, block; 22, 23; 22, 53; 22, 77; 22, 87; 22, 139; 22, 191; 22, 195; 22, 257; 22, 280; 22, 307; 22, 341; 23, function_definition; 23, 24; 23, 25; 23, 27; 24, function_name:is_date; 25, parameters; 25, 26; 26, identifier:axis; 27, block; 27, 28; 27, 36; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:fmt; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:axis; 34, identifier:get_major_formatter; 35, argument_list; 36, return_statement; 36, 37; 37, parenthesized_expression; 37, 38; 38, boolean_operator:or; 38, 39; 38, 46; 39, call; 39, 40; 39, 41; 40, identifier:isinstance; 41, argument_list; 41, 42; 41, 43; 42, identifier:fmt; 43, attribute; 43, 44; 43, 45; 44, identifier:mdates; 45, identifier:DateFormatter; 46, call; 46, 47; 46, 48; 47, identifier:isinstance; 48, argument_list; 48, 49; 48, 50; 49, identifier:fmt; 50, attribute; 50, 51; 50, 52; 51, identifier:mdates; 52, identifier:AutoDateFormatter; 53, function_definition; 53, 54; 53, 55; 53, 57; 54, function_name:format_date; 55, parameters; 55, 56; 56, identifier:num; 57, block; 57, 58; 58, if_statement; 58, 59; 58, 62; 59, comparison_operator:is; 59, 60; 59, 61; 60, identifier:num; 61, None; 62, block; 62, 63; 63, return_statement; 63, 64; 64, call; 64, 65; 64, 73; 65, attribute; 65, 66; 65, 72; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:mdates; 69, identifier:num2date; 70, argument_list; 70, 71; 71, identifier:num; 72, identifier:strftime; 73, argument_list; 73, 74; 74, attribute; 74, 75; 74, 76; 75, identifier:self; 76, identifier:date_format; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:ax; 80, attribute; 80, 81; 80, 86; 81, attribute; 81, 82; 81, 85; 82, subscript; 82, 83; 82, 84; 83, identifier:kwargs; 84, string:'event'; 85, identifier:artist; 86, identifier:axes; 87, if_statement; 87, 88; 87, 94; 87, 102; 88, call; 88, 89; 88, 90; 89, identifier:is_date; 90, argument_list; 90, 91; 91, attribute; 91, 92; 91, 93; 92, identifier:ax; 93, identifier:xaxis; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:x; 98, call; 98, 99; 98, 100; 99, identifier:format_date; 100, argument_list; 100, 101; 101, identifier:x; 102, else_clause; 102, 103; 103, block; 103, 104; 103, 112; 103, 122; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:limits; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:ax; 110, identifier:get_xlim; 111, argument_list; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:x; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:_format_coord; 119, argument_list; 119, 120; 119, 121; 120, identifier:x; 121, identifier:limits; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 127; 124, subscript; 124, 125; 124, 126; 125, identifier:kwargs; 126, string:'xerror'; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:self; 130, identifier:_format_coord; 131, argument_list; 131, 132; 131, 138; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:kwargs; 135, identifier:get; 136, argument_list; 136, 137; 137, string:'xerror'; 138, identifier:limits; 139, if_statement; 139, 140; 139, 146; 139, 154; 140, call; 140, 141; 140, 142; 141, identifier:is_date; 142, argument_list; 142, 143; 143, attribute; 143, 144; 143, 145; 144, identifier:ax; 145, identifier:yaxis; 146, block; 146, 147; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:y; 150, call; 150, 151; 150, 152; 151, identifier:format_date; 152, argument_list; 152, 153; 153, identifier:y; 154, else_clause; 154, 155; 155, block; 155, 156; 155, 164; 155, 174; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:limits; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:ax; 162, identifier:get_ylim; 163, argument_list; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:y; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:_format_coord; 171, argument_list; 171, 172; 171, 173; 172, identifier:y; 173, identifier:limits; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 179; 176, subscript; 176, 177; 176, 178; 177, identifier:kwargs; 178, string:'yerror'; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:_format_coord; 183, argument_list; 183, 184; 183, 190; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:kwargs; 187, identifier:get; 188, argument_list; 188, 189; 189, string:'yerror'; 190, identifier:limits; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:output; 194, list:[]; 195, for_statement; 195, 196; 195, 199; 195, 212; 196, pattern_list; 196, 197; 196, 198; 197, identifier:key; 198, identifier:val; 199, call; 199, 200; 199, 201; 200, identifier:zip; 201, argument_list; 201, 202; 201, 207; 202, list:['x', 'y', 'z', 's']; 202, 203; 202, 204; 202, 205; 202, 206; 203, string:'x'; 204, string:'y'; 205, string:'z'; 206, string:'s'; 207, list:[x, y, z, s]; 207, 208; 207, 209; 207, 210; 207, 211; 208, identifier:x; 209, identifier:y; 210, identifier:z; 211, identifier:s; 212, block; 212, 213; 213, if_statement; 213, 214; 213, 217; 214, comparison_operator:is; 214, 215; 214, 216; 215, identifier:val; 216, None; 217, block; 217, 218; 218, try_statement; 218, 219; 218, 237; 219, block; 219, 220; 220, expression_statement; 220, 221; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:output; 224, identifier:append; 225, argument_list; 225, 226; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, string:u'{key}: {val:0.3g}'; 229, identifier:format; 230, argument_list; 230, 231; 230, 234; 231, keyword_argument; 231, 232; 231, 233; 232, identifier:key; 233, identifier:key; 234, keyword_argument; 234, 235; 234, 236; 235, identifier:val; 236, identifier:val; 237, except_clause; 237, 238; 237, 239; 238, identifier:ValueError; 239, block; 239, 240; 240, expression_statement; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:output; 244, identifier:append; 245, argument_list; 245, 246; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, string:u'{key}: {val}'; 249, identifier:format; 250, argument_list; 250, 251; 250, 254; 251, keyword_argument; 251, 252; 251, 253; 252, identifier:key; 253, identifier:key; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:val; 256, identifier:val; 257, if_statement; 257, 258; 257, 267; 258, boolean_operator:and; 258, 259; 258, 260; 259, identifier:label; 260, not_operator; 260, 261; 261, call; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:label; 264, identifier:startswith; 265, argument_list; 265, 266; 266, string:'_'; 267, block; 267, 268; 268, expression_statement; 268, 269; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:output; 272, identifier:append; 273, argument_list; 273, 274; 274, call; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, string:u'Label: {}'; 277, identifier:format; 278, argument_list; 278, 279; 279, identifier:label; 280, if_statement; 280, 281; 280, 290; 281, comparison_operator:is; 281, 282; 281, 289; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:kwargs; 285, identifier:get; 286, argument_list; 286, 287; 286, 288; 287, string:u'point_label'; 288, None; 289, None; 290, block; 290, 291; 291, expression_statement; 291, 292; 292, call; 292, 293; 292, 296; 293, attribute; 293, 294; 293, 295; 294, identifier:output; 295, identifier:append; 296, argument_list; 296, 297; 297, binary_operator:+; 297, 298; 297, 299; 298, string:u'Point: '; 299, call; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, string:u', '; 302, identifier:join; 303, argument_list; 303, 304; 304, subscript; 304, 305; 304, 306; 305, identifier:kwargs; 306, string:'point_label'; 307, for_statement; 307, 308; 307, 309; 307, 312; 308, identifier:arg; 309, list:['xerror', 'yerror']; 309, 310; 309, 311; 310, string:'xerror'; 311, string:'yerror'; 312, block; 312, 313; 312, 323; 313, expression_statement; 313, 314; 314, assignment; 314, 315; 314, 316; 315, identifier:val; 316, call; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:kwargs; 319, identifier:get; 320, argument_list; 320, 321; 320, 322; 321, identifier:arg; 322, None; 323, if_statement; 323, 324; 323, 327; 324, comparison_operator:is; 324, 325; 324, 326; 325, identifier:val; 326, None; 327, block; 327, 328; 328, expression_statement; 328, 329; 329, call; 329, 330; 329, 333; 330, attribute; 330, 331; 330, 332; 331, identifier:output; 332, identifier:append; 333, argument_list; 333, 334; 334, call; 334, 335; 334, 338; 335, attribute; 335, 336; 335, 337; 336, string:u'{}: {}'; 337, identifier:format; 338, argument_list; 338, 339; 338, 340; 339, identifier:arg; 340, identifier:val; 341, return_statement; 341, 342; 342, call; 342, 343; 342, 346; 343, attribute; 343, 344; 343, 345; 344, string:u'\n'; 345, identifier:join; 346, argument_list; 346, 347; 347, identifier:output | def _formatter(self, x=None, y=None, z=None, s=None, label=None, **kwargs):
def is_date(axis):
fmt = axis.get_major_formatter()
return (isinstance(fmt, mdates.DateFormatter)
or isinstance(fmt, mdates.AutoDateFormatter))
def format_date(num):
if num is not None:
return mdates.num2date(num).strftime(self.date_format)
ax = kwargs['event'].artist.axes
if is_date(ax.xaxis):
x = format_date(x)
else:
limits = ax.get_xlim()
x = self._format_coord(x, limits)
kwargs['xerror'] = self._format_coord(kwargs.get('xerror'), limits)
if is_date(ax.yaxis):
y = format_date(y)
else:
limits = ax.get_ylim()
y = self._format_coord(y, limits)
kwargs['yerror'] = self._format_coord(kwargs.get('yerror'), limits)
output = []
for key, val in zip(['x', 'y', 'z', 's'], [x, y, z, s]):
if val is not None:
try:
output.append(u'{key}: {val:0.3g}'.format(key=key, val=val))
except ValueError:
output.append(u'{key}: {val}'.format(key=key, val=val))
if label and not label.startswith('_'):
output.append(u'Label: {}'.format(label))
if kwargs.get(u'point_label', None) is not None:
output.append(u'Point: ' + u', '.join(kwargs['point_label']))
for arg in ['xerror', 'yerror']:
val = kwargs.get(arg, None)
if val is not None:
output.append(u'{}: {}'.format(arg, val))
return u'\n'.join(output) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:datacursor; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:artists; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:axes; 9, None; 10, dictionary_splat_pattern; 10, 11; 11, identifier:kwargs; 12, block; 12, 13; 12, 43; 12, 83; 12, 97; 12, 116; 13, function_definition; 13, 14; 13, 15; 13, 17; 14, function_name:plotted_artists; 15, parameters; 15, 16; 16, identifier:ax; 17, block; 17, 18; 17, 41; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:artists; 21, parenthesized_expression; 21, 22; 22, binary_operator:+; 22, 23; 22, 38; 23, binary_operator:+; 23, 24; 23, 35; 24, binary_operator:+; 24, 25; 24, 32; 25, binary_operator:+; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:ax; 28, identifier:lines; 29, attribute; 29, 30; 29, 31; 30, identifier:ax; 31, identifier:patches; 32, attribute; 32, 33; 32, 34; 33, identifier:ax; 34, identifier:collections; 35, attribute; 35, 36; 35, 37; 36, identifier:ax; 37, identifier:images; 38, attribute; 38, 39; 38, 40; 39, identifier:ax; 40, identifier:containers; 41, return_statement; 41, 42; 42, identifier:artists; 43, if_statement; 43, 44; 43, 47; 44, comparison_operator:is; 44, 45; 44, 46; 45, identifier:axes; 46, None; 47, block; 47, 48; 47, 58; 47, 70; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:managers; 51, call; 51, 52; 51, 57; 52, attribute; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:pylab_helpers; 55, identifier:Gcf; 56, identifier:get_all_fig_managers; 57, argument_list; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:figs; 61, list_comprehension; 61, 62; 61, 67; 62, attribute; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:manager; 65, identifier:canvas; 66, identifier:figure; 67, for_in_clause; 67, 68; 67, 69; 68, identifier:manager; 69, identifier:managers; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:axes; 73, list_comprehension; 73, 74; 73, 75; 73, 78; 74, identifier:ax; 75, for_in_clause; 75, 76; 75, 77; 76, identifier:fig; 77, identifier:figs; 78, for_in_clause; 78, 79; 78, 80; 79, identifier:ax; 80, attribute; 80, 81; 80, 82; 81, identifier:fig; 82, identifier:axes; 83, if_statement; 83, 84; 83, 91; 84, not_operator; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:cbook; 88, identifier:iterable; 89, argument_list; 89, 90; 90, identifier:axes; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:axes; 95, list:[axes]; 95, 96; 96, identifier:axes; 97, if_statement; 97, 98; 97, 101; 98, comparison_operator:is; 98, 99; 98, 100; 99, identifier:artists; 100, None; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:artists; 105, list_comprehension; 105, 106; 105, 107; 105, 110; 106, identifier:artist; 107, for_in_clause; 107, 108; 107, 109; 108, identifier:ax; 109, identifier:axes; 110, for_in_clause; 110, 111; 110, 112; 111, identifier:artist; 112, call; 112, 113; 112, 114; 113, identifier:plotted_artists; 114, argument_list; 114, 115; 115, identifier:ax; 116, return_statement; 116, 117; 117, call; 117, 118; 117, 119; 118, identifier:DataCursor; 119, argument_list; 119, 120; 119, 121; 120, identifier:artists; 121, dictionary_splat; 121, 122; 122, identifier:kwargs | def datacursor(artists=None, axes=None, **kwargs):
def plotted_artists(ax):
artists = (ax.lines + ax.patches + ax.collections
+ ax.images + ax.containers)
return artists
if axes is None:
managers = pylab_helpers.Gcf.get_all_fig_managers()
figs = [manager.canvas.figure for manager in managers]
axes = [ax for fig in figs for ax in fig.axes]
if not cbook.iterable(axes):
axes = [axes]
if artists is None:
artists = [artist for ax in axes for artist in plotted_artists(ax)]
return DataCursor(artists, **kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:wait_for_notification; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 10; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:handle; 7, type; 7, 8; 8, identifier:int; 9, identifier:delegate; 10, typed_parameter; 10, 11; 10, 12; 11, identifier:notification_timeout; 12, type; 12, 13; 13, identifier:float; 14, block; 14, 15; 14, 28; 14, 32; 14, 36; 14, 46; 14, 288; 15, if_statement; 15, 16; 15, 22; 16, not_operator; 16, 17; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:is_connected; 21, argument_list; 22, block; 22, 23; 23, raise_statement; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:BluetoothBackendException; 26, argument_list; 26, 27; 27, string:'Not connected to any device.'; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:attempt; 31, integer:0; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:delay; 35, integer:10; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:_LOGGER; 40, identifier:debug; 41, argument_list; 41, 42; 41, 43; 42, string:"Enter write_ble (%s)"; 43, call; 43, 44; 43, 45; 44, identifier:current_thread; 45, argument_list; 46, while_statement; 46, 47; 46, 52; 47, comparison_operator:<=; 47, 48; 47, 49; 48, identifier:attempt; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:retries; 52, block; 52, 53; 52, 84; 52, 93; 52, 172; 52, 186; 52, 201; 52, 209; 52, 258; 52, 262; 52, 270; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:cmd; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, string:"gatttool --device={} --addr-type={} --char-write-req -a {} -n {} --adapter={} --listen"; 59, identifier:format; 60, argument_list; 60, 61; 60, 64; 60, 67; 60, 73; 60, 81; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:_mac; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:address_type; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:byte_to_handle; 71, argument_list; 71, 72; 72, identifier:handle; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:self; 76, identifier:bytes_to_string; 77, argument_list; 77, 78; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:_DATA_MODE_LISTEN; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:adapter; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:_LOGGER; 88, identifier:debug; 89, argument_list; 89, 90; 89, 91; 89, 92; 90, string:"Running gatttool with a timeout of %d: %s"; 91, identifier:notification_timeout; 92, identifier:cmd; 93, with_statement; 93, 94; 93, 117; 94, with_clause; 94, 95; 95, with_item; 95, 96; 96, as_pattern; 96, 97; 96, 115; 97, call; 97, 98; 97, 99; 98, identifier:Popen; 99, argument_list; 99, 100; 99, 101; 99, 104; 99, 107; 99, 110; 100, identifier:cmd; 101, keyword_argument; 101, 102; 101, 103; 102, identifier:shell; 103, True; 104, keyword_argument; 104, 105; 104, 106; 105, identifier:stdout; 106, identifier:PIPE; 107, keyword_argument; 107, 108; 107, 109; 108, identifier:stderr; 109, identifier:PIPE; 110, keyword_argument; 110, 111; 110, 112; 111, identifier:preexec_fn; 112, attribute; 112, 113; 112, 114; 113, identifier:os; 114, identifier:setsid; 115, as_pattern_target; 115, 116; 116, identifier:process; 117, block; 117, 118; 118, try_statement; 118, 119; 118, 140; 119, block; 119, 120; 119, 133; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:result; 123, subscript; 123, 124; 123, 132; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:process; 127, identifier:communicate; 128, argument_list; 128, 129; 129, keyword_argument; 129, 130; 129, 131; 130, identifier:timeout; 131, identifier:notification_timeout; 132, integer:0; 133, expression_statement; 133, 134; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:_LOGGER; 137, identifier:debug; 138, argument_list; 138, 139; 139, string:"Finished gatttool"; 140, except_clause; 140, 141; 140, 142; 141, identifier:TimeoutExpired; 142, block; 142, 143; 142, 155; 142, 165; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:os; 147, identifier:killpg; 148, argument_list; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:process; 151, identifier:pid; 152, attribute; 152, 153; 152, 154; 153, identifier:signal; 154, identifier:SIGINT; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:result; 158, subscript; 158, 159; 158, 164; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:process; 162, identifier:communicate; 163, argument_list; 164, integer:0; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:_LOGGER; 169, identifier:debug; 170, argument_list; 170, 171; 171, string:"Listening stopped forcefully after timeout."; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:result; 175, call; 175, 176; 175, 184; 176, attribute; 176, 177; 176, 183; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:result; 180, identifier:decode; 181, argument_list; 181, 182; 182, string:"utf-8"; 183, identifier:strip; 184, argument_list; 184, 185; 185, string:' \n\t'; 186, if_statement; 186, 187; 186, 190; 187, comparison_operator:in; 187, 188; 187, 189; 188, string:"Write Request failed"; 189, identifier:result; 190, block; 190, 191; 191, raise_statement; 191, 192; 192, call; 192, 193; 192, 194; 193, identifier:BluetoothBackendException; 194, argument_list; 194, 195; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, string:'Error writing handle to sensor: {}'; 198, identifier:format; 199, argument_list; 199, 200; 200, identifier:result; 201, expression_statement; 201, 202; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:_LOGGER; 205, identifier:debug; 206, argument_list; 206, 207; 206, 208; 207, string:"Got %s from gatttool"; 208, identifier:result; 209, if_statement; 209, 210; 209, 213; 210, comparison_operator:in; 210, 211; 210, 212; 211, string:"successfully"; 212, identifier:result; 213, block; 213, 214; 213, 224; 213, 256; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:_LOGGER; 218, identifier:debug; 219, argument_list; 219, 220; 219, 221; 220, string:"Exit write_ble with result (%s)"; 221, call; 221, 222; 221, 223; 222, identifier:current_thread; 223, argument_list; 224, for_statement; 224, 225; 224, 226; 224, 232; 225, identifier:element; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:self; 229, identifier:extract_notification_payload; 230, argument_list; 230, 231; 231, identifier:result; 232, block; 232, 233; 233, expression_statement; 233, 234; 234, call; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:delegate; 237, identifier:handleNotification; 238, argument_list; 238, 239; 238, 240; 239, identifier:handle; 240, call; 240, 241; 240, 242; 241, identifier:bytes; 242, argument_list; 242, 243; 243, list_comprehension; 243, 244; 243, 249; 244, call; 244, 245; 244, 246; 245, identifier:int; 246, argument_list; 246, 247; 246, 248; 247, identifier:x; 248, integer:16; 249, for_in_clause; 249, 250; 249, 251; 250, identifier:x; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:element; 254, identifier:split; 255, argument_list; 256, return_statement; 256, 257; 257, True; 258, expression_statement; 258, 259; 259, augmented_assignment:+=; 259, 260; 259, 261; 260, identifier:attempt; 261, integer:1; 262, expression_statement; 262, 263; 263, call; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:_LOGGER; 266, identifier:debug; 267, argument_list; 267, 268; 267, 269; 268, string:"Waiting for %s seconds before retrying"; 269, identifier:delay; 270, if_statement; 270, 271; 270, 276; 271, comparison_operator:<; 271, 272; 271, 273; 272, identifier:attempt; 273, attribute; 273, 274; 273, 275; 274, identifier:self; 275, identifier:retries; 276, block; 276, 277; 276, 284; 277, expression_statement; 277, 278; 278, call; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:time; 281, identifier:sleep; 282, argument_list; 282, 283; 283, identifier:delay; 284, expression_statement; 284, 285; 285, augmented_assignment:*=; 285, 286; 285, 287; 286, identifier:delay; 287, integer:2; 288, raise_statement; 288, 289; 289, call; 289, 290; 289, 291; 290, identifier:BluetoothBackendException; 291, argument_list; 291, 292; 292, call; 292, 293; 292, 296; 293, attribute; 293, 294; 293, 295; 294, string:"Exit write_ble, no data ({})"; 295, identifier:format; 296, argument_list; 296, 297; 297, call; 297, 298; 297, 299; 298, identifier:current_thread; 299, argument_list | def wait_for_notification(self, handle: int, delegate, notification_timeout: float):
if not self.is_connected():
raise BluetoothBackendException('Not connected to any device.')
attempt = 0
delay = 10
_LOGGER.debug("Enter write_ble (%s)", current_thread())
while attempt <= self.retries:
cmd = "gatttool --device={} --addr-type={} --char-write-req -a {} -n {} --adapter={} --listen".format(
self._mac, self.address_type, self.byte_to_handle(handle), self.bytes_to_string(self._DATA_MODE_LISTEN),
self.adapter)
_LOGGER.debug("Running gatttool with a timeout of %d: %s", notification_timeout, cmd)
with Popen(cmd,
shell=True,
stdout=PIPE,
stderr=PIPE,
preexec_fn=os.setsid) as process:
try:
result = process.communicate(timeout=notification_timeout)[0]
_LOGGER.debug("Finished gatttool")
except TimeoutExpired:
os.killpg(process.pid, signal.SIGINT)
result = process.communicate()[0]
_LOGGER.debug("Listening stopped forcefully after timeout.")
result = result.decode("utf-8").strip(' \n\t')
if "Write Request failed" in result:
raise BluetoothBackendException('Error writing handle to sensor: {}'.format(result))
_LOGGER.debug("Got %s from gatttool", result)
if "successfully" in result:
_LOGGER.debug("Exit write_ble with result (%s)", current_thread())
for element in self.extract_notification_payload(result):
delegate.handleNotification(handle, bytes([int(x, 16) for x in element.split()]))
return True
attempt += 1
_LOGGER.debug("Waiting for %s seconds before retrying", delay)
if attempt < self.retries:
time.sleep(delay)
delay *= 2
raise BluetoothBackendException("Exit write_ble, no data ({})".format(current_thread())) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:simplify_tree; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:tree; 5, default_parameter; 5, 6; 5, 7; 6, identifier:unpack_lists; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:in_list; 10, False; 11, block; 11, 12; 11, 188; 12, if_statement; 12, 13; 12, 25; 12, 132; 12, 154; 13, boolean_operator:and; 13, 14; 13, 19; 14, call; 14, 15; 14, 16; 15, identifier:isinstance; 16, argument_list; 16, 17; 16, 18; 17, identifier:tree; 18, identifier:BaseNode; 19, not_operator; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:isinstance; 22, argument_list; 22, 23; 22, 24; 23, identifier:tree; 24, identifier:Terminal; 25, block; 25, 26; 25, 43; 25, 67; 25, 128; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:used_fields; 29, list_comprehension; 29, 30; 29, 31; 29, 36; 30, identifier:field; 31, for_in_clause; 31, 32; 31, 33; 32, identifier:field; 33, attribute; 33, 34; 33, 35; 34, identifier:tree; 35, identifier:_fields; 36, if_clause; 36, 37; 37, call; 37, 38; 37, 39; 38, identifier:getattr; 39, argument_list; 39, 40; 39, 41; 39, 42; 40, identifier:tree; 41, identifier:field; 42, False; 43, if_statement; 43, 44; 43, 50; 43, 61; 44, comparison_operator:==; 44, 45; 44, 49; 45, call; 45, 46; 45, 47; 46, identifier:len; 47, argument_list; 47, 48; 48, identifier:used_fields; 49, integer:1; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:result; 54, call; 54, 55; 54, 56; 55, identifier:getattr; 56, argument_list; 56, 57; 56, 58; 57, identifier:tree; 58, subscript; 58, 59; 58, 60; 59, identifier:used_fields; 60, integer:0; 61, else_clause; 61, 62; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:result; 66, None; 67, if_statement; 67, 68; 67, 90; 68, parenthesized_expression; 68, 69; 69, boolean_operator:or; 69, 70; 69, 82; 70, boolean_operator:or; 70, 71; 70, 77; 71, comparison_operator:!=; 71, 72; 71, 76; 72, call; 72, 73; 72, 74; 73, identifier:len; 74, argument_list; 74, 75; 75, identifier:used_fields; 76, integer:1; 77, call; 77, 78; 77, 79; 78, identifier:isinstance; 79, argument_list; 79, 80; 79, 81; 80, identifier:tree; 81, identifier:AliasNode; 82, parenthesized_expression; 82, 83; 83, boolean_operator:and; 83, 84; 83, 85; 84, identifier:in_list; 85, call; 85, 86; 85, 87; 86, identifier:isinstance; 87, argument_list; 87, 88; 87, 89; 88, identifier:result; 89, identifier:list; 90, block; 90, 91; 90, 95; 90, 126; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:result; 94, identifier:tree; 95, for_statement; 95, 96; 95, 97; 95, 100; 96, identifier:field; 97, attribute; 97, 98; 97, 99; 98, identifier:tree; 99, identifier:_fields; 100, block; 100, 101; 100, 110; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:old_value; 104, call; 104, 105; 104, 106; 105, identifier:getattr; 106, argument_list; 106, 107; 106, 108; 106, 109; 107, identifier:tree; 108, identifier:field; 109, None; 110, if_statement; 110, 111; 110, 112; 111, identifier:old_value; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 116; 115, identifier:setattr; 116, argument_list; 116, 117; 116, 118; 116, 119; 117, identifier:result; 118, identifier:field; 119, call; 119, 120; 119, 121; 120, identifier:simplify_tree; 121, argument_list; 121, 122; 121, 123; 122, identifier:old_value; 123, keyword_argument; 123, 124; 123, 125; 124, identifier:unpack_lists; 125, identifier:unpack_lists; 126, return_statement; 126, 127; 127, identifier:result; 128, assert_statement; 128, 129; 129, comparison_operator:is; 129, 130; 129, 131; 130, identifier:result; 131, None; 132, elif_clause; 132, 133; 132, 147; 133, boolean_operator:and; 133, 134; 133, 146; 134, boolean_operator:and; 134, 135; 134, 140; 135, call; 135, 136; 135, 137; 136, identifier:isinstance; 137, argument_list; 137, 138; 137, 139; 138, identifier:tree; 139, identifier:list; 140, comparison_operator:==; 140, 141; 140, 145; 141, call; 141, 142; 141, 143; 142, identifier:len; 143, argument_list; 143, 144; 144, identifier:tree; 145, integer:1; 146, identifier:unpack_lists; 147, block; 147, 148; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:result; 151, subscript; 151, 152; 151, 153; 152, identifier:tree; 153, integer:0; 154, else_clause; 154, 155; 155, block; 155, 156; 155, 186; 156, if_statement; 156, 157; 156, 162; 156, 180; 157, call; 157, 158; 157, 159; 158, identifier:isinstance; 159, argument_list; 159, 160; 159, 161; 160, identifier:tree; 161, identifier:list; 162, block; 162, 163; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:result; 166, list_comprehension; 166, 167; 166, 177; 167, call; 167, 168; 167, 169; 168, identifier:simplify_tree; 169, argument_list; 169, 170; 169, 171; 169, 174; 170, identifier:el; 171, keyword_argument; 171, 172; 171, 173; 172, identifier:unpack_lists; 173, identifier:unpack_lists; 174, keyword_argument; 174, 175; 174, 176; 175, identifier:in_list; 176, True; 177, for_in_clause; 177, 178; 177, 179; 178, identifier:el; 179, identifier:tree; 180, else_clause; 180, 181; 181, block; 181, 182; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:result; 185, identifier:tree; 186, return_statement; 186, 187; 187, identifier:result; 188, return_statement; 188, 189; 189, call; 189, 190; 189, 191; 190, identifier:simplify_tree; 191, argument_list; 191, 192; 191, 193; 192, identifier:result; 193, keyword_argument; 193, 194; 193, 195; 194, identifier:unpack_lists; 195, identifier:unpack_lists | def simplify_tree(tree, unpack_lists=True, in_list=False):
if isinstance(tree, BaseNode) and not isinstance(tree, Terminal):
used_fields = [field for field in tree._fields if getattr(tree, field, False)]
if len(used_fields) == 1:
result = getattr(tree, used_fields[0])
else:
result = None
if (
len(used_fields) != 1
or isinstance(tree, AliasNode)
or (in_list and isinstance(result, list))
):
result = tree
for field in tree._fields:
old_value = getattr(tree, field, None)
if old_value:
setattr(
result,
field,
simplify_tree(old_value, unpack_lists=unpack_lists),
)
return result
assert result is not None
elif isinstance(tree, list) and len(tree) == 1 and unpack_lists:
result = tree[0]
else:
if isinstance(tree, list):
result = [
simplify_tree(el, unpack_lists=unpack_lists, in_list=True)
for el in tree
]
else:
result = tree
return result
return simplify_tree(result, unpack_lists=unpack_lists) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, block; 7, 8; 7, 19; 7, 30; 7, 78; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:params; 11, call; 11, 12; 11, 17; 12, attribute; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:parser; 16, identifier:parse_args; 17, argument_list; 17, 18; 18, identifier:args; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:config_file; 22, call; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:os; 26, identifier:path; 27, identifier:expanduser; 28, argument_list; 28, 29; 29, string:'~/.sortinghat'; 30, if_statement; 30, 31; 30, 36; 30, 49; 30, 71; 31, comparison_operator:==; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:params; 34, identifier:action; 35, string:'get'; 36, block; 36, 37; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:code; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:get; 44, argument_list; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:params; 47, identifier:parameter; 48, identifier:config_file; 49, elif_clause; 49, 50; 49, 55; 50, comparison_operator:==; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:params; 53, identifier:action; 54, string:'set'; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:code; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:self; 62, identifier:set; 63, argument_list; 63, 64; 63, 67; 63, 70; 64, attribute; 64, 65; 64, 66; 65, identifier:params; 66, identifier:parameter; 67, attribute; 67, 68; 67, 69; 68, identifier:params; 69, identifier:value; 70, identifier:config_file; 71, else_clause; 71, 72; 72, block; 72, 73; 73, raise_statement; 73, 74; 74, call; 74, 75; 74, 76; 75, identifier:RuntimeError; 76, argument_list; 76, 77; 77, string:"Not get or set action given"; 78, return_statement; 78, 79; 79, identifier:code | def run(self, *args):
params = self.parser.parse_args(args)
config_file = os.path.expanduser('~/.sortinghat')
if params.action == 'get':
code = self.get(params.parameter, config_file)
elif params.action == 'set':
code = self.set(params.parameter, params.value, config_file)
else:
raise RuntimeError("Not get or set action given")
return code |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:export; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:source; 7, None; 8, block; 8, 9; 8, 13; 8, 27; 8, 97; 8, 114; 8, 142; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:uidentities; 12, dictionary; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:uids; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:api; 19, identifier:unique_identities; 20, argument_list; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:db; 24, keyword_argument; 24, 25; 24, 26; 25, identifier:source; 26, identifier:source; 27, for_statement; 27, 28; 27, 29; 27, 30; 28, identifier:uid; 29, identifier:uids; 30, block; 30, 31; 30, 55; 30, 63; 30, 79; 30, 87; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:enrollments; 34, list_comprehension; 34, 35; 34, 40; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:rol; 38, identifier:to_dict; 39, argument_list; 40, for_in_clause; 40, 41; 40, 42; 41, identifier:rol; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:api; 45, identifier:enrollments; 46, argument_list; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:db; 50, keyword_argument; 50, 51; 50, 52; 51, identifier:uuid; 52, attribute; 52, 53; 52, 54; 53, identifier:uid; 54, identifier:uuid; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:u; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:uid; 61, identifier:to_dict; 62, argument_list; 63, expression_statement; 63, 64; 64, call; 64, 65; 64, 70; 65, attribute; 65, 66; 65, 69; 66, subscript; 66, 67; 66, 68; 67, identifier:u; 68, string:'identities'; 69, identifier:sort; 70, argument_list; 70, 71; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:key; 73, lambda; 73, 74; 73, 76; 74, lambda_parameters; 74, 75; 75, identifier:x; 76, subscript; 76, 77; 76, 78; 77, identifier:x; 78, string:'id'; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 86; 81, subscript; 81, 82; 81, 83; 82, identifier:uidentities; 83, attribute; 83, 84; 83, 85; 84, identifier:uid; 85, identifier:uuid; 86, identifier:u; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 96; 89, subscript; 89, 90; 89, 95; 90, subscript; 90, 91; 90, 92; 91, identifier:uidentities; 92, attribute; 92, 93; 92, 94; 93, identifier:uid; 94, identifier:uuid; 95, string:'enrollments'; 96, identifier:enrollments; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:blacklist; 100, list_comprehension; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:mb; 103, identifier:excluded; 104, for_in_clause; 104, 105; 104, 106; 105, identifier:mb; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:api; 109, identifier:blacklist; 110, argument_list; 110, 111; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:db; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:obj; 117, dictionary; 117, 118; 117, 130; 117, 133; 117, 136; 117, 139; 118, pair; 118, 119; 118, 120; 119, string:'time'; 120, call; 120, 121; 120, 122; 121, identifier:str; 122, argument_list; 122, 123; 123, call; 123, 124; 123, 129; 124, attribute; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:datetime; 127, identifier:datetime; 128, identifier:now; 129, argument_list; 130, pair; 130, 131; 130, 132; 131, string:'source'; 132, identifier:source; 133, pair; 133, 134; 133, 135; 134, string:'blacklist'; 135, identifier:blacklist; 136, pair; 136, 137; 136, 138; 137, string:'organizations'; 138, dictionary; 139, pair; 139, 140; 139, 141; 140, string:'uidentities'; 141, identifier:uidentities; 142, return_statement; 142, 143; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:json; 146, identifier:dumps; 147, argument_list; 147, 148; 147, 149; 147, 154; 147, 157; 147, 162; 148, identifier:obj; 149, keyword_argument; 149, 150; 149, 151; 150, identifier:default; 151, attribute; 151, 152; 151, 153; 152, identifier:self; 153, identifier:_json_encoder; 154, keyword_argument; 154, 155; 154, 156; 155, identifier:indent; 156, integer:4; 157, keyword_argument; 157, 158; 157, 159; 158, identifier:separators; 159, tuple; 159, 160; 159, 161; 160, string:','; 161, string:': '; 162, keyword_argument; 162, 163; 162, 164; 163, identifier:sort_keys; 164, True | def export(self, source=None):
uidentities = {}
uids = api.unique_identities(self.db, source=source)
for uid in uids:
enrollments = [rol.to_dict()
for rol in api.enrollments(self.db, uuid=uid.uuid)]
u = uid.to_dict()
u['identities'].sort(key=lambda x: x['id'])
uidentities[uid.uuid] = u
uidentities[uid.uuid]['enrollments'] = enrollments
blacklist = [mb.excluded for mb in api.blacklist(self.db)]
obj = {'time': str(datetime.datetime.now()),
'source': source,
'blacklist': blacklist,
'organizations': {},
'uidentities': uidentities}
return json.dumps(obj, default=self._json_encoder,
indent=4, separators=(',', ': '),
sort_keys=True) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:export; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 21; 5, 67; 5, 92; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:organizations; 9, dictionary; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:orgs; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:api; 16, identifier:registry; 17, argument_list; 17, 18; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:db; 21, for_statement; 21, 22; 21, 23; 21, 24; 22, identifier:org; 23, identifier:orgs; 24, block; 24, 25; 24, 45; 24, 59; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:domains; 28, list_comprehension; 28, 29; 28, 40; 29, dictionary; 29, 30; 29, 35; 30, pair; 30, 31; 30, 32; 31, string:'domain'; 32, attribute; 32, 33; 32, 34; 33, identifier:dom; 34, identifier:domain; 35, pair; 35, 36; 35, 37; 36, string:'is_top'; 37, attribute; 37, 38; 37, 39; 38, identifier:dom; 39, identifier:is_top_domain; 40, for_in_clause; 40, 41; 40, 42; 41, identifier:dom; 42, attribute; 42, 43; 42, 44; 43, identifier:org; 44, identifier:domains; 45, expression_statement; 45, 46; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:domains; 49, identifier:sort; 50, argument_list; 50, 51; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:key; 53, lambda; 53, 54; 53, 56; 54, lambda_parameters; 54, 55; 55, identifier:x; 56, subscript; 56, 57; 56, 58; 57, identifier:x; 58, string:'domain'; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 66; 61, subscript; 61, 62; 61, 63; 62, identifier:organizations; 63, attribute; 63, 64; 63, 65; 64, identifier:org; 65, identifier:name; 66, identifier:domains; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:obj; 70, dictionary; 70, 71; 70, 83; 70, 86; 70, 89; 71, pair; 71, 72; 71, 73; 72, string:'time'; 73, call; 73, 74; 73, 75; 74, identifier:str; 75, argument_list; 75, 76; 76, call; 76, 77; 76, 82; 77, attribute; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:datetime; 80, identifier:datetime; 81, identifier:now; 82, argument_list; 83, pair; 83, 84; 83, 85; 84, string:'blacklist'; 85, list:[]; 86, pair; 86, 87; 86, 88; 87, string:'organizations'; 88, identifier:organizations; 89, pair; 89, 90; 89, 91; 90, string:'uidentities'; 91, dictionary; 92, return_statement; 92, 93; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:json; 96, identifier:dumps; 97, argument_list; 97, 98; 97, 99; 97, 104; 97, 107; 97, 112; 98, identifier:obj; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:default; 101, attribute; 101, 102; 101, 103; 102, identifier:self; 103, identifier:_json_encoder; 104, keyword_argument; 104, 105; 104, 106; 105, identifier:indent; 106, integer:4; 107, keyword_argument; 107, 108; 107, 109; 108, identifier:separators; 109, tuple; 109, 110; 109, 111; 110, string:','; 111, string:': '; 112, keyword_argument; 112, 113; 112, 114; 113, identifier:sort_keys; 114, True | def export(self):
organizations = {}
orgs = api.registry(self.db)
for org in orgs:
domains = [{'domain': dom.domain,
'is_top': dom.is_top_domain}
for dom in org.domains]
domains.sort(key=lambda x: x['domain'])
organizations[org.name] = domains
obj = {'time': str(datetime.datetime.now()),
'blacklist': [],
'organizations': organizations,
'uidentities': {}}
return json.dumps(obj, default=self._json_encoder,
indent=4, separators=(',', ': '),
sort_keys=True) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:match; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:a; 6, identifier:b; 7, block; 7, 8; 7, 21; 7, 34; 7, 53; 7, 62; 7, 71; 7, 90; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:isinstance; 12, argument_list; 12, 13; 12, 14; 13, identifier:a; 14, identifier:UniqueIdentity; 15, block; 15, 16; 16, raise_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:ValueError; 19, argument_list; 19, 20; 20, string:"<a> is not an instance of UniqueIdentity"; 21, if_statement; 21, 22; 21, 28; 22, not_operator; 22, 23; 23, call; 23, 24; 23, 25; 24, identifier:isinstance; 25, argument_list; 25, 26; 25, 27; 26, identifier:b; 27, identifier:UniqueIdentity; 28, block; 28, 29; 29, raise_statement; 29, 30; 30, call; 30, 31; 30, 32; 31, identifier:ValueError; 32, argument_list; 32, 33; 33, string:"<b> is not an instance of UniqueIdentity"; 34, if_statement; 34, 35; 34, 50; 35, boolean_operator:and; 35, 36; 35, 43; 36, boolean_operator:and; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:a; 39, identifier:uuid; 40, attribute; 40, 41; 40, 42; 41, identifier:b; 42, identifier:uuid; 43, comparison_operator:==; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:a; 46, identifier:uuid; 47, attribute; 47, 48; 47, 49; 48, identifier:b; 49, identifier:uuid; 50, block; 50, 51; 51, return_statement; 51, 52; 52, True; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:filtered_a; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:filter; 60, argument_list; 60, 61; 61, identifier:a; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:filtered_b; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:filter; 69, argument_list; 69, 70; 70, identifier:b; 71, for_statement; 71, 72; 71, 73; 71, 74; 72, identifier:fa; 73, identifier:filtered_a; 74, block; 74, 75; 75, for_statement; 75, 76; 75, 77; 75, 78; 76, identifier:fb; 77, identifier:filtered_b; 78, block; 78, 79; 79, if_statement; 79, 80; 79, 87; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:match_filtered_identities; 84, argument_list; 84, 85; 84, 86; 85, identifier:fa; 86, identifier:fb; 87, block; 87, 88; 88, return_statement; 88, 89; 89, True; 90, return_statement; 90, 91; 91, False | def match(self, a, b):
if not isinstance(a, UniqueIdentity):
raise ValueError("<a> is not an instance of UniqueIdentity")
if not isinstance(b, UniqueIdentity):
raise ValueError("<b> is not an instance of UniqueIdentity")
if a.uuid and b.uuid and a.uuid == b.uuid:
return True
filtered_a = self.filter(a)
filtered_b = self.filter(b)
for fa in filtered_a:
for fb in filtered_b:
if self.match_filtered_identities(fa, fb):
return True
return False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:merge_enrollments; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:db; 5, identifier:uuid; 6, identifier:organization; 7, block; 7, 8; 8, with_statement; 8, 9; 8, 19; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, as_pattern; 11, 12; 11, 17; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:db; 15, identifier:connect; 16, argument_list; 17, as_pattern_target; 17, 18; 18, identifier:session; 19, block; 19, 20; 19, 28; 19, 39; 19, 47; 19, 58; 19, 86; 19, 108; 19, 122; 19, 210; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:uidentity; 23, call; 23, 24; 23, 25; 24, identifier:find_unique_identity; 25, argument_list; 25, 26; 25, 27; 26, identifier:session; 27, identifier:uuid; 28, if_statement; 28, 29; 28, 31; 29, not_operator; 29, 30; 30, identifier:uidentity; 31, block; 31, 32; 32, raise_statement; 32, 33; 33, call; 33, 34; 33, 35; 34, identifier:NotFoundError; 35, argument_list; 35, 36; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:entity; 38, identifier:uuid; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:org; 42, call; 42, 43; 42, 44; 43, identifier:find_organization; 44, argument_list; 44, 45; 44, 46; 45, identifier:session; 46, identifier:organization; 47, if_statement; 47, 48; 47, 50; 48, not_operator; 48, 49; 49, identifier:org; 50, block; 50, 51; 51, raise_statement; 51, 52; 52, call; 52, 53; 52, 54; 53, identifier:NotFoundError; 54, argument_list; 54, 55; 55, keyword_argument; 55, 56; 55, 57; 56, identifier:entity; 57, identifier:organization; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:disjoint; 61, call; 61, 62; 61, 85; 62, attribute; 62, 63; 62, 84; 63, call; 63, 64; 63, 73; 64, attribute; 64, 65; 64, 71; 64, 72; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:session; 68, identifier:query; 69, argument_list; 69, 70; 70, identifier:Enrollment; 71, line_continuation:\; 72, identifier:filter; 73, argument_list; 73, 74; 73, 79; 74, comparison_operator:==; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:Enrollment; 77, identifier:uidentity; 78, identifier:uidentity; 79, comparison_operator:==; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:Enrollment; 82, identifier:organization; 83, identifier:org; 84, identifier:all; 85, argument_list; 86, if_statement; 86, 87; 86, 89; 87, not_operator; 87, 88; 88, identifier:disjoint; 89, block; 89, 90; 89, 101; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:entity; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, string:'-'; 96, identifier:join; 97, argument_list; 97, 98; 98, tuple; 98, 99; 98, 100; 99, identifier:uuid; 100, identifier:organization; 101, raise_statement; 101, 102; 102, call; 102, 103; 102, 104; 103, identifier:NotFoundError; 104, argument_list; 104, 105; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:entity; 107, identifier:entity; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:dates; 111, list_comprehension; 111, 112; 111, 119; 112, tuple; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:enr; 115, identifier:start; 116, attribute; 116, 117; 116, 118; 117, identifier:enr; 118, identifier:end; 119, for_in_clause; 119, 120; 119, 121; 120, identifier:enr; 121, identifier:disjoint; 122, for_statement; 122, 123; 122, 126; 122, 132; 123, pattern_list; 123, 124; 123, 125; 124, identifier:st; 125, identifier:en; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:utils; 129, identifier:merge_date_ranges; 130, argument_list; 130, 131; 131, identifier:dates; 132, block; 132, 133; 132, 152; 132, 168; 132, 184; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:is_dup; 136, lambda; 136, 137; 136, 141; 137, lambda_parameters; 137, 138; 137, 139; 137, 140; 138, identifier:x; 139, identifier:st; 140, identifier:en; 141, boolean_operator:and; 141, 142; 141, 147; 142, comparison_operator:==; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:x; 145, identifier:start; 146, identifier:st; 147, comparison_operator:==; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:x; 150, identifier:end; 151, identifier:en; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:filtered; 155, list_comprehension; 155, 156; 155, 157; 155, 160; 156, identifier:x; 157, for_in_clause; 157, 158; 157, 159; 158, identifier:x; 159, identifier:disjoint; 160, if_clause; 160, 161; 161, not_operator; 161, 162; 162, call; 162, 163; 162, 164; 163, identifier:is_dup; 164, argument_list; 164, 165; 164, 166; 164, 167; 165, identifier:x; 166, identifier:st; 167, identifier:en; 168, if_statement; 168, 169; 168, 178; 169, comparison_operator:!=; 169, 170; 169, 174; 170, call; 170, 171; 170, 172; 171, identifier:len; 172, argument_list; 172, 173; 173, identifier:filtered; 174, call; 174, 175; 174, 176; 175, identifier:len; 176, argument_list; 176, 177; 177, identifier:disjoint; 178, block; 178, 179; 178, 183; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:disjoint; 182, identifier:filtered; 183, continue_statement; 184, try_statement; 184, 185; 184, 199; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, call; 187, 188; 187, 189; 188, identifier:enroll_db; 189, argument_list; 189, 190; 189, 191; 189, 192; 189, 193; 189, 196; 190, identifier:session; 191, identifier:uidentity; 192, identifier:org; 193, keyword_argument; 193, 194; 193, 195; 194, identifier:from_date; 195, identifier:st; 196, keyword_argument; 196, 197; 196, 198; 197, identifier:to_date; 198, identifier:en; 199, except_clause; 199, 200; 199, 204; 200, as_pattern; 200, 201; 200, 202; 201, identifier:ValueError; 202, as_pattern_target; 202, 203; 203, identifier:e; 204, block; 204, 205; 205, raise_statement; 205, 206; 206, call; 206, 207; 206, 208; 207, identifier:InvalidValueError; 208, argument_list; 208, 209; 209, identifier:e; 210, for_statement; 210, 211; 210, 212; 210, 213; 211, identifier:enr; 212, identifier:disjoint; 213, block; 213, 214; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 217; 216, identifier:delete_enrollment_db; 217, argument_list; 217, 218; 217, 219; 218, identifier:session; 219, identifier:enr | def merge_enrollments(db, uuid, organization):
with db.connect() as session:
uidentity = find_unique_identity(session, uuid)
if not uidentity:
raise NotFoundError(entity=uuid)
org = find_organization(session, organization)
if not org:
raise NotFoundError(entity=organization)
disjoint = session.query(Enrollment).\
filter(Enrollment.uidentity == uidentity,
Enrollment.organization == org).all()
if not disjoint:
entity = '-'.join((uuid, organization))
raise NotFoundError(entity=entity)
dates = [(enr.start, enr.end) for enr in disjoint]
for st, en in utils.merge_date_ranges(dates):
is_dup = lambda x, st, en: x.start == st and x.end == en
filtered = [x for x in disjoint if not is_dup(x, st, en)]
if len(filtered) != len(disjoint):
disjoint = filtered
continue
try:
enroll_db(session, uidentity, org,
from_date=st, to_date=en)
except ValueError as e:
raise InvalidValueError(e)
for enr in disjoint:
delete_enrollment_db(session, enr) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:registry; 3, parameters; 3, 4; 3, 5; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:term; 7, None; 8, block; 8, 9; 8, 13; 8, 106; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:orgs; 12, list:[]; 13, with_statement; 13, 14; 13, 24; 14, with_clause; 14, 15; 15, with_item; 15, 16; 16, as_pattern; 16, 17; 16, 22; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:db; 20, identifier:connect; 21, argument_list; 22, as_pattern_target; 22, 23; 23, identifier:session; 24, block; 24, 25; 24, 100; 25, if_statement; 25, 26; 25, 27; 25, 77; 26, identifier:term; 27, block; 27, 28; 27, 66; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:orgs; 31, call; 31, 32; 31, 65; 32, attribute; 32, 33; 32, 64; 33, call; 33, 34; 33, 60; 34, attribute; 34, 35; 34, 58; 34, 59; 35, call; 35, 36; 35, 45; 36, attribute; 36, 37; 36, 43; 36, 44; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:session; 40, identifier:query; 41, argument_list; 41, 42; 42, identifier:Organization; 43, line_continuation:\; 44, identifier:filter; 45, argument_list; 45, 46; 46, call; 46, 47; 46, 52; 47, attribute; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:Organization; 50, identifier:name; 51, identifier:like; 52, argument_list; 52, 53; 53, binary_operator:+; 53, 54; 53, 57; 54, binary_operator:+; 54, 55; 54, 56; 55, string:'%'; 56, identifier:term; 57, string:'%'; 58, line_continuation:\; 59, identifier:order_by; 60, argument_list; 60, 61; 61, attribute; 61, 62; 61, 63; 62, identifier:Organization; 63, identifier:name; 64, identifier:all; 65, argument_list; 66, if_statement; 66, 67; 66, 69; 67, not_operator; 67, 68; 68, identifier:orgs; 69, block; 69, 70; 70, raise_statement; 70, 71; 71, call; 71, 72; 71, 73; 72, identifier:NotFoundError; 73, argument_list; 73, 74; 74, keyword_argument; 74, 75; 74, 76; 75, identifier:entity; 76, identifier:term; 77, else_clause; 77, 78; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:orgs; 82, call; 82, 83; 82, 99; 83, attribute; 83, 84; 83, 98; 84, call; 84, 85; 84, 94; 85, attribute; 85, 86; 85, 92; 85, 93; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:session; 89, identifier:query; 90, argument_list; 90, 91; 91, identifier:Organization; 92, line_continuation:\; 93, identifier:order_by; 94, argument_list; 94, 95; 95, attribute; 95, 96; 95, 97; 96, identifier:Organization; 97, identifier:name; 98, identifier:all; 99, argument_list; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:session; 104, identifier:expunge_all; 105, argument_list; 106, return_statement; 106, 107; 107, identifier:orgs | def registry(db, term=None):
orgs = []
with db.connect() as session:
if term:
orgs = session.query(Organization).\
filter(Organization.name.like('%' + term + '%')).\
order_by(Organization.name).all()
if not orgs:
raise NotFoundError(entity=term)
else:
orgs = session.query(Organization).\
order_by(Organization.name).all()
session.expunge_all()
return orgs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:domains; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:domain; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:top; 10, False; 11, block; 11, 12; 11, 16; 11, 193; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:doms; 15, list:[]; 16, with_statement; 16, 17; 16, 27; 17, with_clause; 17, 18; 18, with_item; 18, 19; 19, as_pattern; 19, 20; 19, 25; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:db; 23, identifier:connect; 24, argument_list; 25, as_pattern_target; 25, 26; 26, identifier:session; 27, block; 27, 28; 27, 187; 28, if_statement; 28, 29; 28, 30; 28, 147; 29, identifier:domain; 30, block; 30, 31; 30, 39; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:dom; 34, call; 34, 35; 34, 36; 35, identifier:find_domain; 36, argument_list; 36, 37; 36, 38; 37, identifier:session; 38, identifier:domain; 39, if_statement; 39, 40; 39, 42; 39, 140; 40, not_operator; 40, 41; 41, identifier:dom; 42, block; 42, 43; 43, if_statement; 43, 44; 43, 46; 43, 54; 44, not_operator; 44, 45; 45, identifier:top; 46, block; 46, 47; 47, raise_statement; 47, 48; 48, call; 48, 49; 48, 50; 49, identifier:NotFoundError; 50, argument_list; 50, 51; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:entity; 53, identifier:domain; 54, else_clause; 54, 55; 55, block; 55, 56; 55, 74; 55, 81; 55, 109; 55, 129; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:add_dot; 59, lambda; 59, 60; 59, 62; 60, lambda_parameters; 60, 61; 61, identifier:d; 62, conditional_expression:if; 62, 63; 62, 66; 62, 73; 63, binary_operator:+; 63, 64; 63, 65; 64, string:'.'; 65, identifier:d; 66, not_operator; 66, 67; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:d; 70, identifier:startswith; 71, argument_list; 71, 72; 72, string:'.'; 73, identifier:d; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:d; 77, call; 77, 78; 77, 79; 78, identifier:add_dot; 79, argument_list; 79, 80; 80, identifier:domain; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:tops; 84, call; 84, 85; 84, 108; 85, attribute; 85, 86; 85, 107; 86, call; 86, 87; 86, 103; 87, attribute; 87, 88; 87, 102; 88, call; 88, 89; 88, 98; 89, attribute; 89, 90; 89, 96; 89, 97; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:session; 93, identifier:query; 94, argument_list; 94, 95; 95, identifier:Domain; 96, line_continuation:\; 97, identifier:filter; 98, argument_list; 98, 99; 99, attribute; 99, 100; 99, 101; 100, identifier:Domain; 101, identifier:is_top_domain; 102, identifier:order_by; 103, argument_list; 103, 104; 104, attribute; 104, 105; 104, 106; 105, identifier:Domain; 106, identifier:domain; 107, identifier:all; 108, argument_list; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:doms; 112, list_comprehension; 112, 113; 112, 114; 112, 117; 113, identifier:t; 114, for_in_clause; 114, 115; 114, 116; 115, identifier:t; 116, identifier:tops; 117, if_clause; 117, 118; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:d; 121, identifier:endswith; 122, argument_list; 122, 123; 123, call; 123, 124; 123, 125; 124, identifier:add_dot; 125, argument_list; 125, 126; 126, attribute; 126, 127; 126, 128; 127, identifier:t; 128, identifier:domain; 129, if_statement; 129, 130; 129, 132; 130, not_operator; 130, 131; 131, identifier:doms; 132, block; 132, 133; 133, raise_statement; 133, 134; 134, call; 134, 135; 134, 136; 135, identifier:NotFoundError; 136, argument_list; 136, 137; 137, keyword_argument; 137, 138; 137, 139; 138, identifier:entity; 139, identifier:domain; 140, else_clause; 140, 141; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:doms; 145, list:[dom]; 145, 146; 146, identifier:dom; 147, else_clause; 147, 148; 148, block; 148, 149; 148, 158; 148, 172; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:query; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:session; 155, identifier:query; 156, argument_list; 156, 157; 157, identifier:Domain; 158, if_statement; 158, 159; 158, 160; 159, identifier:top; 160, block; 160, 161; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:query; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:query; 167, identifier:filter; 168, argument_list; 168, 169; 169, attribute; 169, 170; 169, 171; 170, identifier:Domain; 171, identifier:is_top_domain; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:doms; 175, call; 175, 176; 175, 186; 176, attribute; 176, 177; 176, 185; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:query; 180, identifier:order_by; 181, argument_list; 181, 182; 182, attribute; 182, 183; 182, 184; 183, identifier:Domain; 184, identifier:domain; 185, identifier:all; 186, argument_list; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:session; 191, identifier:expunge_all; 192, argument_list; 193, return_statement; 193, 194; 194, identifier:doms | def domains(db, domain=None, top=False):
doms = []
with db.connect() as session:
if domain:
dom = find_domain(session, domain)
if not dom:
if not top:
raise NotFoundError(entity=domain)
else:
add_dot = lambda d: '.' + d if not d.startswith('.') else d
d = add_dot(domain)
tops = session.query(Domain).\
filter(Domain.is_top_domain).order_by(Domain.domain).all()
doms = [t for t in tops
if d.endswith(add_dot(t.domain))]
if not doms:
raise NotFoundError(entity=domain)
else:
doms = [dom]
else:
query = session.query(Domain)
if top:
query = query.filter(Domain.is_top_domain)
doms = query.order_by(Domain.domain).all()
session.expunge_all()
return doms |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:countries; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:code; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:term; 10, None; 11, block; 11, 12; 11, 39; 11, 60; 11, 64; 11, 195; 12, function_definition; 12, 13; 12, 14; 12, 16; 13, function_name:_is_code_valid; 14, parameters; 14, 15; 15, identifier:code; 16, block; 16, 17; 17, return_statement; 17, 18; 18, boolean_operator:and; 18, 19; 18, 33; 18, 34; 19, boolean_operator:and; 19, 20; 19, 26; 19, 27; 20, comparison_operator:==; 20, 21; 20, 25; 21, call; 21, 22; 21, 23; 22, identifier:type; 23, argument_list; 23, 24; 24, identifier:code; 25, identifier:str; 26, line_continuation:\; 27, comparison_operator:==; 27, 28; 27, 32; 28, call; 28, 29; 28, 30; 29, identifier:len; 30, argument_list; 30, 31; 31, identifier:code; 32, integer:2; 33, line_continuation:\; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:code; 37, identifier:isalpha; 38, argument_list; 39, if_statement; 39, 40; 39, 49; 40, boolean_operator:and; 40, 41; 40, 44; 41, comparison_operator:is; 41, 42; 41, 43; 42, identifier:code; 43, None; 44, not_operator; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:_is_code_valid; 47, argument_list; 47, 48; 48, identifier:code; 49, block; 49, 50; 50, raise_statement; 50, 51; 51, call; 51, 52; 51, 53; 52, identifier:InvalidValueError; 53, argument_list; 53, 54; 54, binary_operator:%; 54, 55; 54, 56; 55, string:'country code must be a 2 length alpha string - %s given'; 56, call; 56, 57; 56, 58; 57, identifier:str; 58, argument_list; 58, 59; 59, identifier:code; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:cs; 63, list:[]; 64, with_statement; 64, 65; 64, 75; 65, with_clause; 65, 66; 66, with_item; 66, 67; 67, as_pattern; 67, 68; 67, 73; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:db; 71, identifier:connect; 72, argument_list; 73, as_pattern_target; 73, 74; 74, identifier:session; 75, block; 75, 76; 75, 85; 75, 189; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:query; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:session; 82, identifier:query; 83, argument_list; 83, 84; 84, identifier:Country; 85, if_statement; 85, 86; 85, 89; 85, 166; 86, boolean_operator:or; 86, 87; 86, 88; 87, identifier:code; 88, identifier:term; 89, block; 89, 90; 89, 133; 89, 148; 90, if_statement; 90, 91; 90, 92; 90, 110; 91, identifier:code; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:query; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:query; 99, identifier:filter; 100, argument_list; 100, 101; 101, comparison_operator:==; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:Country; 104, identifier:code; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:code; 108, identifier:upper; 109, argument_list; 110, elif_clause; 110, 111; 110, 112; 111, identifier:term; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:query; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:query; 119, identifier:filter; 120, argument_list; 120, 121; 121, call; 121, 122; 121, 127; 122, attribute; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:Country; 125, identifier:name; 126, identifier:like; 127, argument_list; 127, 128; 128, binary_operator:+; 128, 129; 128, 132; 129, binary_operator:+; 129, 130; 129, 131; 130, string:'%'; 131, identifier:term; 132, string:'%'; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:cs; 136, call; 136, 137; 136, 147; 137, attribute; 137, 138; 137, 146; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:query; 141, identifier:order_by; 142, argument_list; 142, 143; 143, attribute; 143, 144; 143, 145; 144, identifier:Country; 145, identifier:code; 146, identifier:all; 147, argument_list; 148, if_statement; 148, 149; 148, 151; 149, not_operator; 149, 150; 150, identifier:cs; 151, block; 151, 152; 151, 159; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:e; 155, conditional_expression:if; 155, 156; 155, 157; 155, 158; 156, identifier:code; 157, identifier:code; 158, identifier:term; 159, raise_statement; 159, 160; 160, call; 160, 161; 160, 162; 161, identifier:NotFoundError; 162, argument_list; 162, 163; 163, keyword_argument; 163, 164; 163, 165; 164, identifier:entity; 165, identifier:e; 166, else_clause; 166, 167; 167, block; 167, 168; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:cs; 171, call; 171, 172; 171, 188; 172, attribute; 172, 173; 172, 187; 173, call; 173, 174; 173, 183; 174, attribute; 174, 175; 174, 181; 174, 182; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:session; 178, identifier:query; 179, argument_list; 179, 180; 180, identifier:Country; 181, line_continuation:\; 182, identifier:order_by; 183, argument_list; 183, 184; 184, attribute; 184, 185; 184, 186; 185, identifier:Country; 186, identifier:code; 187, identifier:all; 188, argument_list; 189, expression_statement; 189, 190; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:session; 193, identifier:expunge_all; 194, argument_list; 195, return_statement; 195, 196; 196, identifier:cs | def countries(db, code=None, term=None):
def _is_code_valid(code):
return type(code) == str \
and len(code) == 2 \
and code.isalpha()
if code is not None and not _is_code_valid(code):
raise InvalidValueError('country code must be a 2 length alpha string - %s given'
% str(code))
cs = []
with db.connect() as session:
query = session.query(Country)
if code or term:
if code:
query = query.filter(Country.code == code.upper())
elif term:
query = query.filter(Country.name.like('%' + term + '%'))
cs = query.order_by(Country.code).all()
if not cs:
e = code if code else term
raise NotFoundError(entity=e)
else:
cs = session.query(Country).\
order_by(Country.code).all()
session.expunge_all()
return cs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:enrollments; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:uuid; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:organization; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:from_date; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:to_date; 16, None; 17, block; 17, 18; 17, 26; 17, 34; 17, 53; 17, 72; 17, 90; 17, 94; 17, 237; 18, if_statement; 18, 19; 18, 21; 19, not_operator; 19, 20; 20, identifier:from_date; 21, block; 21, 22; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:from_date; 25, identifier:MIN_PERIOD_DATE; 26, if_statement; 26, 27; 26, 29; 27, not_operator; 27, 28; 28, identifier:to_date; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:to_date; 33, identifier:MAX_PERIOD_DATE; 34, if_statement; 34, 35; 34, 42; 35, boolean_operator:or; 35, 36; 35, 39; 36, comparison_operator:<; 36, 37; 36, 38; 37, identifier:from_date; 38, identifier:MIN_PERIOD_DATE; 39, comparison_operator:>; 39, 40; 39, 41; 40, identifier:from_date; 41, identifier:MAX_PERIOD_DATE; 42, block; 42, 43; 43, raise_statement; 43, 44; 44, call; 44, 45; 44, 46; 45, identifier:InvalidValueError; 46, argument_list; 46, 47; 47, binary_operator:%; 47, 48; 47, 49; 48, string:"'from_date' %s is out of bounds"; 49, call; 49, 50; 49, 51; 50, identifier:str; 51, argument_list; 51, 52; 52, identifier:from_date; 53, if_statement; 53, 54; 53, 61; 54, boolean_operator:or; 54, 55; 54, 58; 55, comparison_operator:<; 55, 56; 55, 57; 56, identifier:to_date; 57, identifier:MIN_PERIOD_DATE; 58, comparison_operator:>; 58, 59; 58, 60; 59, identifier:to_date; 60, identifier:MAX_PERIOD_DATE; 61, block; 61, 62; 62, raise_statement; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:InvalidValueError; 65, argument_list; 65, 66; 66, binary_operator:%; 66, 67; 66, 68; 67, string:"'to_date' %s is out of bounds"; 68, call; 68, 69; 68, 70; 69, identifier:str; 70, argument_list; 70, 71; 71, identifier:to_date; 72, if_statement; 72, 73; 72, 80; 73, boolean_operator:and; 73, 74; 73, 77; 74, boolean_operator:and; 74, 75; 74, 76; 75, identifier:from_date; 76, identifier:to_date; 77, comparison_operator:>; 77, 78; 77, 79; 78, identifier:from_date; 79, identifier:to_date; 80, block; 80, 81; 81, raise_statement; 81, 82; 82, call; 82, 83; 82, 84; 83, identifier:InvalidValueError; 84, argument_list; 84, 85; 85, binary_operator:%; 85, 86; 85, 87; 86, string:"'from_date' %s cannot be greater than %s"; 87, tuple; 87, 88; 87, 89; 88, identifier:from_date; 89, identifier:to_date; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:enrollments; 93, list:[]; 94, with_statement; 94, 95; 94, 105; 95, with_clause; 95, 96; 96, with_item; 96, 97; 97, as_pattern; 97, 98; 97, 103; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:db; 101, identifier:connect; 102, argument_list; 103, as_pattern_target; 103, 104; 104, identifier:session; 105, block; 105, 106; 105, 137; 105, 172; 105, 207; 105, 231; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:query; 109, call; 109, 110; 109, 126; 110, attribute; 110, 111; 110, 124; 110, 125; 111, call; 111, 112; 111, 121; 112, attribute; 112, 113; 112, 119; 112, 120; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:session; 116, identifier:query; 117, argument_list; 117, 118; 118, identifier:Enrollment; 119, line_continuation:\; 120, identifier:join; 121, argument_list; 121, 122; 121, 123; 122, identifier:UniqueIdentity; 123, identifier:Organization; 124, line_continuation:\; 125, identifier:filter; 126, argument_list; 126, 127; 126, 132; 127, comparison_operator:>=; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:Enrollment; 130, identifier:start; 131, identifier:from_date; 132, comparison_operator:<=; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:Enrollment; 135, identifier:end; 136, identifier:to_date; 137, if_statement; 137, 138; 137, 139; 138, identifier:uuid; 139, block; 139, 140; 139, 148; 139, 159; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:uidentity; 143, call; 143, 144; 143, 145; 144, identifier:find_unique_identity; 145, argument_list; 145, 146; 145, 147; 146, identifier:session; 147, identifier:uuid; 148, if_statement; 148, 149; 148, 151; 149, not_operator; 149, 150; 150, identifier:uidentity; 151, block; 151, 152; 152, raise_statement; 152, 153; 153, call; 153, 154; 153, 155; 154, identifier:NotFoundError; 155, argument_list; 155, 156; 156, keyword_argument; 156, 157; 156, 158; 157, identifier:entity; 158, identifier:uuid; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:query; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:query; 165, identifier:filter; 166, argument_list; 166, 167; 167, comparison_operator:==; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:Enrollment; 170, identifier:uidentity; 171, identifier:uidentity; 172, if_statement; 172, 173; 172, 174; 173, identifier:organization; 174, block; 174, 175; 174, 183; 174, 194; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:org; 178, call; 178, 179; 178, 180; 179, identifier:find_organization; 180, argument_list; 180, 181; 180, 182; 181, identifier:session; 182, identifier:organization; 183, if_statement; 183, 184; 183, 186; 184, not_operator; 184, 185; 185, identifier:org; 186, block; 186, 187; 187, raise_statement; 187, 188; 188, call; 188, 189; 188, 190; 189, identifier:NotFoundError; 190, argument_list; 190, 191; 191, keyword_argument; 191, 192; 191, 193; 192, identifier:entity; 193, identifier:organization; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:query; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:query; 200, identifier:filter; 201, argument_list; 201, 202; 202, comparison_operator:==; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:Enrollment; 205, identifier:organization; 206, identifier:org; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 210; 209, identifier:enrollments; 210, call; 210, 211; 210, 230; 211, attribute; 211, 212; 211, 229; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:query; 215, identifier:order_by; 216, argument_list; 216, 217; 216, 220; 216, 223; 216, 226; 217, attribute; 217, 218; 217, 219; 218, identifier:UniqueIdentity; 219, identifier:uuid; 220, attribute; 220, 221; 220, 222; 221, identifier:Organization; 222, identifier:name; 223, attribute; 223, 224; 223, 225; 224, identifier:Enrollment; 225, identifier:start; 226, attribute; 226, 227; 226, 228; 227, identifier:Enrollment; 228, identifier:end; 229, identifier:all; 230, argument_list; 231, expression_statement; 231, 232; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:session; 235, identifier:expunge_all; 236, argument_list; 237, return_statement; 237, 238; 238, identifier:enrollments | def enrollments(db, uuid=None, organization=None, from_date=None, to_date=None):
if not from_date:
from_date = MIN_PERIOD_DATE
if not to_date:
to_date = MAX_PERIOD_DATE
if from_date < MIN_PERIOD_DATE or from_date > MAX_PERIOD_DATE:
raise InvalidValueError("'from_date' %s is out of bounds" % str(from_date))
if to_date < MIN_PERIOD_DATE or to_date > MAX_PERIOD_DATE:
raise InvalidValueError("'to_date' %s is out of bounds" % str(to_date))
if from_date and to_date and from_date > to_date:
raise InvalidValueError("'from_date' %s cannot be greater than %s"
% (from_date, to_date))
enrollments = []
with db.connect() as session:
query = session.query(Enrollment).\
join(UniqueIdentity, Organization).\
filter(Enrollment.start >= from_date,
Enrollment.end <= to_date)
if uuid:
uidentity = find_unique_identity(session, uuid)
if not uidentity:
raise NotFoundError(entity=uuid)
query = query.filter(Enrollment.uidentity == uidentity)
if organization:
org = find_organization(session, organization)
if not org:
raise NotFoundError(entity=organization)
query = query.filter(Enrollment.organization == org)
enrollments = query.order_by(UniqueIdentity.uuid,
Organization.name,
Enrollment.start,
Enrollment.end).all()
session.expunge_all()
return enrollments |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:blacklist; 3, parameters; 3, 4; 3, 5; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:term; 7, None; 8, block; 8, 9; 8, 13; 8, 106; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:mbs; 12, list:[]; 13, with_statement; 13, 14; 13, 24; 14, with_clause; 14, 15; 15, with_item; 15, 16; 16, as_pattern; 16, 17; 16, 22; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:db; 20, identifier:connect; 21, argument_list; 22, as_pattern_target; 22, 23; 23, identifier:session; 24, block; 24, 25; 24, 100; 25, if_statement; 25, 26; 25, 27; 25, 77; 26, identifier:term; 27, block; 27, 28; 27, 66; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:mbs; 31, call; 31, 32; 31, 65; 32, attribute; 32, 33; 32, 64; 33, call; 33, 34; 33, 60; 34, attribute; 34, 35; 34, 58; 34, 59; 35, call; 35, 36; 35, 45; 36, attribute; 36, 37; 36, 43; 36, 44; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:session; 40, identifier:query; 41, argument_list; 41, 42; 42, identifier:MatchingBlacklist; 43, line_continuation:\; 44, identifier:filter; 45, argument_list; 45, 46; 46, call; 46, 47; 46, 52; 47, attribute; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:MatchingBlacklist; 50, identifier:excluded; 51, identifier:like; 52, argument_list; 52, 53; 53, binary_operator:+; 53, 54; 53, 57; 54, binary_operator:+; 54, 55; 54, 56; 55, string:'%'; 56, identifier:term; 57, string:'%'; 58, line_continuation:\; 59, identifier:order_by; 60, argument_list; 60, 61; 61, attribute; 61, 62; 61, 63; 62, identifier:MatchingBlacklist; 63, identifier:excluded; 64, identifier:all; 65, argument_list; 66, if_statement; 66, 67; 66, 69; 67, not_operator; 67, 68; 68, identifier:mbs; 69, block; 69, 70; 70, raise_statement; 70, 71; 71, call; 71, 72; 71, 73; 72, identifier:NotFoundError; 73, argument_list; 73, 74; 74, keyword_argument; 74, 75; 74, 76; 75, identifier:entity; 76, identifier:term; 77, else_clause; 77, 78; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:mbs; 82, call; 82, 83; 82, 99; 83, attribute; 83, 84; 83, 98; 84, call; 84, 85; 84, 94; 85, attribute; 85, 86; 85, 92; 85, 93; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:session; 89, identifier:query; 90, argument_list; 90, 91; 91, identifier:MatchingBlacklist; 92, line_continuation:\; 93, identifier:order_by; 94, argument_list; 94, 95; 95, attribute; 95, 96; 95, 97; 96, identifier:MatchingBlacklist; 97, identifier:excluded; 98, identifier:all; 99, argument_list; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:session; 104, identifier:expunge_all; 105, argument_list; 106, return_statement; 106, 107; 107, identifier:mbs | def blacklist(db, term=None):
mbs = []
with db.connect() as session:
if term:
mbs = session.query(MatchingBlacklist).\
filter(MatchingBlacklist.excluded.like('%' + term + '%')).\
order_by(MatchingBlacklist.excluded).all()
if not mbs:
raise NotFoundError(entity=term)
else:
mbs = session.query(MatchingBlacklist).\
order_by(MatchingBlacklist.excluded).all()
session.expunge_all()
return mbs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_identities; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stream; 6, block; 6, 7; 6, 96; 6, 105; 6, 109; 7, function_definition; 7, 8; 7, 9; 7, 13; 8, function_name:__create_sh_identities; 9, parameters; 9, 10; 9, 11; 9, 12; 10, identifier:name; 11, identifier:emails; 12, identifier:yaml_entry; 13, block; 13, 14; 13, 18; 13, 35; 13, 59; 13, 94; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:ids; 17, list:[]; 18, expression_statement; 18, 19; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:ids; 22, identifier:append; 23, argument_list; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:Identity; 26, argument_list; 26, 27; 26, 30; 27, keyword_argument; 27, 28; 27, 29; 28, identifier:name; 29, identifier:name; 30, keyword_argument; 30, 31; 30, 32; 31, identifier:source; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:source; 35, if_statement; 35, 36; 35, 37; 36, identifier:emails; 37, block; 37, 38; 38, for_statement; 38, 39; 38, 40; 38, 41; 39, identifier:m; 40, identifier:emails; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:ids; 46, identifier:append; 47, argument_list; 47, 48; 48, call; 48, 49; 48, 50; 49, identifier:Identity; 50, argument_list; 50, 51; 50, 54; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:email; 53, identifier:m; 54, keyword_argument; 54, 55; 54, 56; 55, identifier:source; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:source; 59, for_statement; 59, 60; 59, 61; 59, 62; 60, identifier:pb; 61, identifier:PERCEVAL_BACKENDS; 62, block; 62, 63; 62, 69; 63, if_statement; 63, 64; 63, 67; 64, comparison_operator:not; 64, 65; 64, 66; 65, identifier:pb; 66, identifier:yaml_entry; 67, block; 67, 68; 68, continue_statement; 69, for_statement; 69, 70; 69, 71; 69, 74; 70, identifier:username; 71, subscript; 71, 72; 71, 73; 72, identifier:yaml_entry; 73, identifier:pb; 74, block; 74, 75; 74, 87; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:identity; 78, call; 78, 79; 78, 80; 79, identifier:Identity; 80, argument_list; 80, 81; 80, 84; 81, keyword_argument; 81, 82; 81, 83; 82, identifier:username; 83, identifier:username; 84, keyword_argument; 84, 85; 84, 86; 85, identifier:source; 86, identifier:pb; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:ids; 91, identifier:append; 92, argument_list; 92, 93; 93, identifier:identity; 94, return_statement; 94, 95; 95, identifier:ids; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:yaml_file; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:__load_yml; 103, argument_list; 103, 104; 104, identifier:stream; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:yid_counter; 108, integer:0; 109, try_statement; 109, 110; 109, 264; 110, block; 110, 111; 111, for_statement; 111, 112; 111, 113; 111, 114; 112, identifier:yid; 113, identifier:yaml_file; 114, block; 114, 115; 114, 121; 114, 131; 114, 139; 114, 149; 114, 159; 114, 175; 114, 185; 114, 192; 114, 196; 114, 205; 114, 217; 114, 223; 114, 232; 114, 238; 114, 256; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:profile; 118, subscript; 118, 119; 118, 120; 119, identifier:yid; 120, string:'profile'; 121, if_statement; 121, 122; 121, 125; 122, comparison_operator:is; 122, 123; 122, 124; 123, identifier:profile; 124, None; 125, block; 125, 126; 126, raise_statement; 126, 127; 127, call; 127, 128; 127, 129; 128, identifier:AttributeError; 129, argument_list; 129, 130; 130, string:'profile'; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:name; 134, subscript; 134, 135; 134, 138; 135, subscript; 135, 136; 135, 137; 136, identifier:yid; 137, string:'profile'; 138, string:'name'; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:is_bot; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:profile; 145, identifier:get; 146, argument_list; 146, 147; 146, 148; 147, string:'is_bot'; 148, False; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:emails; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:yid; 155, identifier:get; 156, argument_list; 156, 157; 156, 158; 157, string:'email'; 158, None; 159, if_statement; 159, 160; 159, 165; 160, boolean_operator:and; 160, 161; 160, 162; 161, identifier:emails; 162, attribute; 162, 163; 162, 164; 163, identifier:self; 164, identifier:email_validation; 165, block; 165, 166; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:__validate_email; 171, argument_list; 171, 172; 172, subscript; 172, 173; 172, 174; 173, identifier:emails; 174, integer:0; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:enrollments; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:yid; 181, identifier:get; 182, argument_list; 182, 183; 182, 184; 183, string:'enrollments'; 184, None; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:uuid; 188, call; 188, 189; 188, 190; 189, identifier:str; 190, argument_list; 190, 191; 191, identifier:yid_counter; 192, expression_statement; 192, 193; 193, augmented_assignment:+=; 193, 194; 193, 195; 194, identifier:yid_counter; 195, integer:1; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 199; 198, identifier:uid; 199, call; 199, 200; 199, 201; 200, identifier:UniqueIdentity; 201, argument_list; 201, 202; 202, keyword_argument; 202, 203; 202, 204; 203, identifier:uuid; 204, identifier:uuid; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:prf; 208, call; 208, 209; 208, 210; 209, identifier:Profile; 210, argument_list; 210, 211; 210, 214; 211, keyword_argument; 211, 212; 211, 213; 212, identifier:name; 213, identifier:name; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:is_bot; 216, identifier:is_bot; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:uid; 221, identifier:profile; 222, identifier:prf; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:sh_identities; 226, call; 226, 227; 226, 228; 227, identifier:__create_sh_identities; 228, argument_list; 228, 229; 228, 230; 228, 231; 229, identifier:name; 230, identifier:emails; 231, identifier:yid; 232, expression_statement; 232, 233; 233, augmented_assignment:+=; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:uid; 236, identifier:identities; 237, identifier:sh_identities; 238, if_statement; 238, 239; 238, 240; 239, identifier:enrollments; 240, block; 240, 241; 240, 250; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:affiliations; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:self; 247, identifier:__parse_affiliations_yml; 248, argument_list; 248, 249; 249, identifier:enrollments; 250, expression_statement; 250, 251; 251, augmented_assignment:+=; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:uid; 254, identifier:enrollments; 255, identifier:affiliations; 256, expression_statement; 256, 257; 257, assignment; 257, 258; 257, 263; 258, subscript; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:self; 261, identifier:_identities; 262, identifier:uuid; 263, identifier:uid; 264, except_clause; 264, 265; 264, 269; 265, as_pattern; 265, 266; 265, 267; 266, identifier:KeyError; 267, as_pattern_target; 267, 268; 268, identifier:e; 269, block; 269, 270; 269, 278; 269, 289; 270, expression_statement; 270, 271; 271, assignment; 271, 272; 271, 273; 272, identifier:error; 273, binary_operator:%; 273, 274; 273, 275; 274, string:"Attribute %s not found"; 275, attribute; 275, 276; 275, 277; 276, identifier:e; 277, identifier:args; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:msg; 281, binary_operator:%; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:self; 284, identifier:GRIMOIRELAB_INVALID_FORMAT; 285, dictionary; 285, 286; 286, pair; 286, 287; 286, 288; 287, string:'error'; 288, identifier:error; 289, raise_statement; 289, 290; 290, call; 290, 291; 290, 292; 291, identifier:InvalidFormatError; 292, argument_list; 292, 293; 293, keyword_argument; 293, 294; 293, 295; 294, identifier:cause; 295, identifier:msg | def __parse_identities(self, stream):
def __create_sh_identities(name, emails, yaml_entry):
ids = []
ids.append(Identity(name=name, source=self.source))
if emails:
for m in emails:
ids.append(Identity(email=m, source=self.source))
for pb in PERCEVAL_BACKENDS:
if pb not in yaml_entry:
continue
for username in yaml_entry[pb]:
identity = Identity(username=username, source=pb)
ids.append(identity)
return ids
yaml_file = self.__load_yml(stream)
yid_counter = 0
try:
for yid in yaml_file:
profile = yid['profile']
if profile is None:
raise AttributeError('profile')
name = yid['profile']['name']
is_bot = profile.get('is_bot', False)
emails = yid.get('email', None)
if emails and self.email_validation:
self.__validate_email(emails[0])
enrollments = yid.get('enrollments', None)
uuid = str(yid_counter)
yid_counter += 1
uid = UniqueIdentity(uuid=uuid)
prf = Profile(name=name, is_bot=is_bot)
uid.profile = prf
sh_identities = __create_sh_identities(name, emails, yid)
uid.identities += sh_identities
if enrollments:
affiliations = self.__parse_affiliations_yml(enrollments)
uid.enrollments += affiliations
self._identities[uuid] = uid
except KeyError as e:
error = "Attribute %s not found" % e.args
msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
raise InvalidFormatError(cause=msg) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_organizations; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stream; 6, block; 6, 7; 6, 12; 6, 21; 7, if_statement; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:stream; 10, block; 10, 11; 11, return_statement; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:yaml_file; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:__load_yml; 19, argument_list; 19, 20; 20, identifier:stream; 21, try_statement; 21, 22; 21, 176; 21, 208; 22, block; 22, 23; 23, for_statement; 23, 24; 23, 25; 23, 26; 24, identifier:element; 25, identifier:yaml_file; 26, block; 26, 27; 26, 38; 26, 64; 26, 73; 26, 168; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:name; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:__encode; 34, argument_list; 34, 35; 35, subscript; 35, 36; 35, 37; 36, identifier:element; 37, string:'organization'; 38, if_statement; 38, 39; 38, 41; 39, not_operator; 39, 40; 40, identifier:name; 41, block; 41, 42; 41, 46; 41, 57; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:error; 45, string:"Empty organization name"; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:msg; 49, binary_operator:%; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:self; 52, identifier:GRIMOIRELAB_INVALID_FORMAT; 53, dictionary; 53, 54; 54, pair; 54, 55; 54, 56; 55, string:'error'; 56, identifier:error; 57, raise_statement; 57, 58; 58, call; 58, 59; 58, 60; 59, identifier:InvalidFormatError; 60, argument_list; 60, 61; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:cause; 63, identifier:msg; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:o; 67, call; 67, 68; 67, 69; 68, identifier:Organization; 69, argument_list; 69, 70; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:name; 72, identifier:name; 73, if_statement; 73, 74; 73, 77; 74, comparison_operator:in; 74, 75; 74, 76; 75, string:'domains'; 76, identifier:element; 77, block; 77, 78; 77, 112; 78, if_statement; 78, 79; 78, 87; 79, not_operator; 79, 80; 80, call; 80, 81; 80, 82; 81, identifier:isinstance; 82, argument_list; 82, 83; 82, 86; 83, subscript; 83, 84; 83, 85; 84, identifier:element; 85, string:'domains'; 86, identifier:list; 87, block; 87, 88; 87, 94; 87, 105; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:error; 91, binary_operator:%; 91, 92; 91, 93; 92, string:"List of elements expected for organization %s"; 93, identifier:name; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:msg; 97, binary_operator:%; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:self; 100, identifier:GRIMOIRELAB_INVALID_FORMAT; 101, dictionary; 101, 102; 102, pair; 102, 103; 102, 104; 103, string:'error'; 104, identifier:error; 105, raise_statement; 105, 106; 106, call; 106, 107; 106, 108; 107, identifier:InvalidFormatError; 108, argument_list; 108, 109; 109, keyword_argument; 109, 110; 109, 111; 110, identifier:cause; 111, identifier:msg; 112, for_statement; 112, 113; 112, 114; 112, 117; 113, identifier:dom; 114, subscript; 114, 115; 114, 116; 115, identifier:element; 116, string:'domains'; 117, block; 117, 118; 118, if_statement; 118, 119; 118, 120; 118, 142; 119, identifier:dom; 120, block; 120, 121; 120, 133; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:d; 124, call; 124, 125; 124, 126; 125, identifier:Domain; 126, argument_list; 126, 127; 126, 130; 127, keyword_argument; 127, 128; 127, 129; 128, identifier:domain; 129, identifier:dom; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:is_top_domain; 132, False; 133, expression_statement; 133, 134; 134, call; 134, 135; 134, 140; 135, attribute; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:o; 138, identifier:domains; 139, identifier:append; 140, argument_list; 140, 141; 141, identifier:d; 142, else_clause; 142, 143; 143, block; 143, 144; 143, 150; 143, 161; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:error; 147, binary_operator:%; 147, 148; 147, 149; 148, string:"Empty domain name for organization %s"; 149, identifier:name; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:msg; 153, binary_operator:%; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:self; 156, identifier:GRIMOIRELAB_INVALID_FORMAT; 157, dictionary; 157, 158; 158, pair; 158, 159; 158, 160; 159, string:'error'; 160, identifier:error; 161, raise_statement; 161, 162; 162, call; 162, 163; 162, 164; 163, identifier:InvalidFormatError; 164, argument_list; 164, 165; 165, keyword_argument; 165, 166; 165, 167; 166, identifier:cause; 167, identifier:msg; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 175; 170, subscript; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:self; 173, identifier:_organizations; 174, identifier:name; 175, identifier:o; 176, except_clause; 176, 177; 176, 181; 177, as_pattern; 177, 178; 177, 179; 178, identifier:KeyError; 179, as_pattern_target; 179, 180; 180, identifier:e; 181, block; 181, 182; 181, 190; 181, 201; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:error; 185, binary_operator:%; 185, 186; 185, 187; 186, string:"Attribute %s not found"; 187, attribute; 187, 188; 187, 189; 188, identifier:e; 189, identifier:args; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:msg; 193, binary_operator:%; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:self; 196, identifier:GRIMOIRELAB_INVALID_FORMAT; 197, dictionary; 197, 198; 198, pair; 198, 199; 198, 200; 199, string:'error'; 200, identifier:error; 201, raise_statement; 201, 202; 202, call; 202, 203; 202, 204; 203, identifier:InvalidFormatError; 204, argument_list; 204, 205; 205, keyword_argument; 205, 206; 205, 207; 206, identifier:cause; 207, identifier:msg; 208, except_clause; 208, 209; 208, 213; 209, as_pattern; 209, 210; 209, 211; 210, identifier:TypeError; 211, as_pattern_target; 211, 212; 212, identifier:e; 213, block; 213, 214; 213, 222; 213, 233; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 217; 216, identifier:error; 217, binary_operator:%; 217, 218; 217, 219; 218, string:"%s"; 219, attribute; 219, 220; 219, 221; 220, identifier:e; 221, identifier:args; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:msg; 225, binary_operator:%; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:self; 228, identifier:GRIMOIRELAB_INVALID_FORMAT; 229, dictionary; 229, 230; 230, pair; 230, 231; 230, 232; 231, string:'error'; 232, identifier:error; 233, raise_statement; 233, 234; 234, call; 234, 235; 234, 236; 235, identifier:InvalidFormatError; 236, argument_list; 236, 237; 237, keyword_argument; 237, 238; 237, 239; 238, identifier:cause; 239, identifier:msg | def __parse_organizations(self, stream):
if not stream:
return
yaml_file = self.__load_yml(stream)
try:
for element in yaml_file:
name = self.__encode(element['organization'])
if not name:
error = "Empty organization name"
msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
raise InvalidFormatError(cause=msg)
o = Organization(name=name)
if 'domains' in element:
if not isinstance(element['domains'], list):
error = "List of elements expected for organization %s" % name
msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
raise InvalidFormatError(cause=msg)
for dom in element['domains']:
if dom:
d = Domain(domain=dom, is_top_domain=False)
o.domains.append(d)
else:
error = "Empty domain name for organization %s" % name
msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
raise InvalidFormatError(cause=msg)
self._organizations[name] = o
except KeyError as e:
error = "Attribute %s not found" % e.args
msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
raise InvalidFormatError(cause=msg)
except TypeError as e:
error = "%s" % e.args
msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
raise InvalidFormatError(cause=msg) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stream; 6, block; 6, 7; 6, 18; 6, 27; 6, 34; 6, 41; 7, if_statement; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:stream; 10, block; 10, 11; 11, raise_statement; 11, 12; 12, call; 12, 13; 12, 14; 13, identifier:InvalidFormatError; 14, argument_list; 14, 15; 15, keyword_argument; 15, 16; 15, 17; 16, identifier:cause; 17, string:"stream cannot be empty or None"; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:json; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:__load_json; 25, argument_list; 25, 26; 26, identifier:stream; 27, expression_statement; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:__parse_organizations; 32, argument_list; 32, 33; 33, identifier:json; 34, expression_statement; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:__parse_identities; 39, argument_list; 39, 40; 40, identifier:json; 41, expression_statement; 41, 42; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:__parse_blacklist; 46, argument_list; 46, 47; 47, identifier:json | def __parse(self, stream):
if not stream:
raise InvalidFormatError(cause="stream cannot be empty or None")
json = self.__load_json(stream)
self.__parse_organizations(json)
self.__parse_identities(json)
self.__parse_blacklist(json) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_blacklist; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:json; 6, block; 6, 7; 7, try_statement; 7, 8; 7, 72; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 11; 9, 14; 10, identifier:entry; 11, subscript; 11, 12; 11, 13; 12, identifier:json; 13, string:'blacklist'; 14, block; 14, 15; 14, 30; 14, 39; 14, 51; 15, if_statement; 15, 16; 15, 18; 16, not_operator; 16, 17; 17, identifier:entry; 18, block; 18, 19; 18, 23; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:msg; 22, string:"invalid json format. Blacklist entries cannot be null or empty"; 23, raise_statement; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:InvalidFormatError; 26, argument_list; 26, 27; 27, keyword_argument; 27, 28; 27, 29; 28, identifier:cause; 29, identifier:msg; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:excluded; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:__encode; 37, argument_list; 37, 38; 38, identifier:entry; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:bl; 42, call; 42, 43; 42, 48; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:_blacklist; 47, identifier:get; 48, argument_list; 48, 49; 48, 50; 49, identifier:excluded; 50, None; 51, if_statement; 51, 52; 51, 54; 52, not_operator; 52, 53; 53, identifier:bl; 54, block; 54, 55; 54, 64; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:bl; 58, call; 58, 59; 58, 60; 59, identifier:MatchingBlacklist; 60, argument_list; 60, 61; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:excluded; 63, identifier:excluded; 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:_blacklist; 70, identifier:excluded; 71, identifier:bl; 72, except_clause; 72, 73; 72, 77; 73, as_pattern; 73, 74; 73, 75; 74, identifier:KeyError; 75, as_pattern_target; 75, 76; 76, identifier:e; 77, block; 77, 78; 77, 86; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:msg; 81, binary_operator:%; 81, 82; 81, 83; 82, string:"invalid json format. Attribute %s not found"; 83, attribute; 83, 84; 83, 85; 84, identifier:e; 85, identifier:args; 86, raise_statement; 86, 87; 87, call; 87, 88; 87, 89; 88, identifier:InvalidFormatError; 89, argument_list; 89, 90; 90, keyword_argument; 90, 91; 90, 92; 91, identifier:cause; 92, identifier:msg | def __parse_blacklist(self, json):
try:
for entry in json['blacklist']:
if not entry:
msg = "invalid json format. Blacklist entries cannot be null or empty"
raise InvalidFormatError(cause=msg)
excluded = self.__encode(entry)
bl = self._blacklist.get(excluded, None)
if not bl:
bl = MatchingBlacklist(excluded=excluded)
self._blacklist[excluded] = bl
except KeyError as e:
msg = "invalid json format. Attribute %s not found" % e.args
raise InvalidFormatError(cause=msg) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_organizations; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:json; 6, block; 6, 7; 7, try_statement; 7, 8; 7, 115; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 11; 9, 14; 10, identifier:organization; 11, subscript; 11, 12; 11, 13; 12, identifier:json; 13, string:'organizations'; 14, block; 14, 15; 14, 24; 14, 36; 14, 57; 14, 65; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:name; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:__encode; 22, argument_list; 22, 23; 23, identifier:organization; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:org; 27, call; 27, 28; 27, 33; 28, attribute; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:_organizations; 32, identifier:get; 33, argument_list; 33, 34; 33, 35; 34, identifier:name; 35, None; 36, if_statement; 36, 37; 36, 39; 37, not_operator; 37, 38; 38, identifier:org; 39, block; 39, 40; 39, 49; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:org; 43, call; 43, 44; 43, 45; 44, identifier:Organization; 45, argument_list; 45, 46; 46, keyword_argument; 46, 47; 46, 48; 47, identifier:name; 48, identifier:name; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 56; 51, subscript; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:_organizations; 55, identifier:name; 56, identifier:org; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:domains; 60, subscript; 60, 61; 60, 64; 61, subscript; 61, 62; 61, 63; 62, identifier:json; 63, string:'organizations'; 64, identifier:organization; 65, for_statement; 65, 66; 65, 67; 65, 68; 66, identifier:domain; 67, identifier:domains; 68, block; 68, 69; 68, 90; 68, 106; 69, if_statement; 69, 70; 69, 78; 70, comparison_operator:!=; 70, 71; 70, 77; 71, call; 71, 72; 71, 73; 72, identifier:type; 73, argument_list; 73, 74; 74, subscript; 74, 75; 74, 76; 75, identifier:domain; 76, string:'is_top'; 77, identifier:bool; 78, block; 78, 79; 78, 83; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:msg; 82, string:"invalid json format. 'is_top' must have a bool value"; 83, raise_statement; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:InvalidFormatError; 86, argument_list; 86, 87; 87, keyword_argument; 87, 88; 87, 89; 88, identifier:cause; 89, identifier:msg; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:dom; 93, call; 93, 94; 93, 95; 94, identifier:Domain; 95, argument_list; 95, 96; 95, 101; 96, keyword_argument; 96, 97; 96, 98; 97, identifier:domain; 98, subscript; 98, 99; 98, 100; 99, identifier:domain; 100, string:'domain'; 101, keyword_argument; 101, 102; 101, 103; 102, identifier:is_top_domain; 103, subscript; 103, 104; 103, 105; 104, identifier:domain; 105, string:'is_top'; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 113; 108, attribute; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:org; 111, identifier:domains; 112, identifier:append; 113, argument_list; 113, 114; 114, identifier:dom; 115, except_clause; 115, 116; 115, 120; 116, as_pattern; 116, 117; 116, 118; 117, identifier:KeyError; 118, as_pattern_target; 118, 119; 119, identifier:e; 120, block; 120, 121; 120, 129; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:msg; 124, binary_operator:%; 124, 125; 124, 126; 125, string:"invalid json format. Attribute %s not found"; 126, attribute; 126, 127; 126, 128; 127, identifier:e; 128, identifier:args; 129, raise_statement; 129, 130; 130, call; 130, 131; 130, 132; 131, identifier:InvalidFormatError; 132, argument_list; 132, 133; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:cause; 135, identifier:msg | def __parse_organizations(self, json):
try:
for organization in json['organizations']:
name = self.__encode(organization)
org = self._organizations.get(name, None)
if not org:
org = Organization(name=name)
self._organizations[name] = org
domains = json['organizations'][organization]
for domain in domains:
if type(domain['is_top']) != bool:
msg = "invalid json format. 'is_top' must have a bool value"
raise InvalidFormatError(cause=msg)
dom = Domain(domain=domain['domain'],
is_top_domain=domain['is_top'])
org.domains.append(dom)
except KeyError as e:
msg = "invalid json format. Attribute %s not found" % e.args
raise InvalidFormatError(cause=msg) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:import_blacklist; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:parser; 6, block; 6, 7; 6, 13; 6, 20; 6, 24; 6, 94; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:blacklist; 10, attribute; 10, 11; 10, 12; 11, identifier:parser; 12, identifier:blacklist; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:log; 18, argument_list; 18, 19; 19, string:"Loading blacklist..."; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:n; 23, integer:0; 24, for_statement; 24, 25; 24, 26; 24, 27; 25, identifier:entry; 26, identifier:blacklist; 27, block; 27, 28; 28, try_statement; 28, 29; 28, 58; 28, 72; 29, block; 29, 30; 29, 42; 29, 54; 30, expression_statement; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:api; 34, identifier:add_to_matching_blacklist; 35, argument_list; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:db; 39, attribute; 39, 40; 39, 41; 40, identifier:entry; 41, identifier:excluded; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:display; 47, argument_list; 47, 48; 47, 49; 48, string:'load_blacklist.tmpl'; 49, keyword_argument; 49, 50; 49, 51; 50, identifier:entry; 51, attribute; 51, 52; 51, 53; 52, identifier:entry; 53, identifier:excluded; 54, expression_statement; 54, 55; 55, augmented_assignment:+=; 55, 56; 55, 57; 56, identifier:n; 57, integer:1; 58, except_clause; 58, 59; 58, 63; 59, as_pattern; 59, 60; 59, 61; 60, identifier:ValueError; 61, as_pattern_target; 61, 62; 62, identifier:e; 63, block; 63, 64; 64, raise_statement; 64, 65; 65, call; 65, 66; 65, 67; 66, identifier:RuntimeError; 67, argument_list; 67, 68; 68, call; 68, 69; 68, 70; 69, identifier:str; 70, argument_list; 70, 71; 71, identifier:e; 72, except_clause; 72, 73; 72, 77; 73, as_pattern; 73, 74; 73, 75; 74, identifier:AlreadyExistsError; 75, as_pattern_target; 75, 76; 76, identifier:e; 77, block; 77, 78; 77, 87; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:msg; 81, binary_operator:%; 81, 82; 81, 83; 82, string:"%s. Not added."; 83, call; 83, 84; 83, 85; 84, identifier:str; 85, argument_list; 85, 86; 86, identifier:e; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:warning; 92, argument_list; 92, 93; 93, identifier:msg; 94, expression_statement; 94, 95; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:self; 98, identifier:log; 99, argument_list; 99, 100; 100, binary_operator:%; 100, 101; 100, 102; 101, string:"%d/%d blacklist entries loaded"; 102, tuple; 102, 103; 102, 104; 103, identifier:n; 104, call; 104, 105; 104, 106; 105, identifier:len; 106, argument_list; 106, 107; 107, identifier:blacklist | def import_blacklist(self, parser):
blacklist = parser.blacklist
self.log("Loading blacklist...")
n = 0
for entry in blacklist:
try:
api.add_to_matching_blacklist(self.db, entry.excluded)
self.display('load_blacklist.tmpl', entry=entry.excluded)
n += 1
except ValueError as e:
raise RuntimeError(str(e))
except AlreadyExistsError as e:
msg = "%s. Not added." % str(e)
self.warning(msg)
self.log("%d/%d blacklist entries loaded" % (n, len(blacklist))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:import_organizations; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:parser; 6, default_parameter; 6, 7; 6, 8; 7, identifier:overwrite; 8, False; 9, block; 9, 10; 9, 16; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:orgs; 13, attribute; 13, 14; 13, 15; 14, identifier:parser; 15, identifier:organizations; 16, for_statement; 16, 17; 16, 18; 16, 19; 17, identifier:org; 18, identifier:orgs; 19, block; 19, 20; 19, 55; 20, try_statement; 20, 21; 20, 34; 20, 48; 21, block; 21, 22; 22, expression_statement; 22, 23; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:api; 26, identifier:add_organization; 27, argument_list; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:db; 31, attribute; 31, 32; 31, 33; 32, identifier:org; 33, identifier:name; 34, except_clause; 34, 35; 34, 39; 35, as_pattern; 35, 36; 35, 37; 36, identifier:ValueError; 37, as_pattern_target; 37, 38; 38, identifier:e; 39, block; 39, 40; 40, raise_statement; 40, 41; 41, call; 41, 42; 41, 43; 42, identifier:RuntimeError; 43, argument_list; 43, 44; 44, call; 44, 45; 44, 46; 45, identifier:str; 46, argument_list; 46, 47; 47, identifier:e; 48, except_clause; 48, 49; 48, 53; 49, as_pattern; 49, 50; 49, 51; 50, identifier:AlreadyExistsError; 51, as_pattern_target; 51, 52; 52, identifier:e; 53, block; 53, 54; 54, pass_statement; 55, for_statement; 55, 56; 55, 57; 55, 60; 56, identifier:dom; 57, attribute; 57, 58; 57, 59; 58, identifier:org; 59, identifier:domains; 60, block; 60, 61; 61, try_statement; 61, 62; 61, 103; 61, 119; 62, block; 62, 63; 62, 86; 63, expression_statement; 63, 64; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:api; 67, identifier:add_domain; 68, argument_list; 68, 69; 68, 72; 68, 75; 68, 78; 68, 83; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:db; 72, attribute; 72, 73; 72, 74; 73, identifier:org; 74, identifier:name; 75, attribute; 75, 76; 75, 77; 76, identifier:dom; 77, identifier:domain; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:is_top_domain; 80, attribute; 80, 81; 80, 82; 81, identifier:dom; 82, identifier:is_top_domain; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:overwrite; 85, identifier:overwrite; 86, expression_statement; 86, 87; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:display; 91, argument_list; 91, 92; 91, 93; 91, 98; 92, string:'load_domains.tmpl'; 93, keyword_argument; 93, 94; 93, 95; 94, identifier:domain; 95, attribute; 95, 96; 95, 97; 96, identifier:dom; 97, identifier:domain; 98, keyword_argument; 98, 99; 98, 100; 99, identifier:organization; 100, attribute; 100, 101; 100, 102; 101, identifier:org; 102, identifier:name; 103, except_clause; 103, 104; 103, 110; 104, as_pattern; 104, 105; 104, 108; 105, tuple; 105, 106; 105, 107; 106, identifier:ValueError; 107, identifier:NotFoundError; 108, as_pattern_target; 108, 109; 109, identifier:e; 110, block; 110, 111; 111, raise_statement; 111, 112; 112, call; 112, 113; 112, 114; 113, identifier:RuntimeError; 114, argument_list; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:str; 117, argument_list; 117, 118; 118, identifier:e; 119, except_clause; 119, 120; 119, 124; 120, as_pattern; 120, 121; 120, 122; 121, identifier:AlreadyExistsError; 122, as_pattern_target; 122, 123; 123, identifier:e; 124, block; 124, 125; 124, 134; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 128; 127, identifier:msg; 128, binary_operator:%; 128, 129; 128, 130; 129, string:"%s. Not updated."; 130, call; 130, 131; 130, 132; 131, identifier:str; 132, argument_list; 132, 133; 133, identifier:e; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:warning; 139, argument_list; 139, 140; 140, identifier:msg | def import_organizations(self, parser, overwrite=False):
orgs = parser.organizations
for org in orgs:
try:
api.add_organization(self.db, org.name)
except ValueError as e:
raise RuntimeError(str(e))
except AlreadyExistsError as e:
pass
for dom in org.domains:
try:
api.add_domain(self.db, org.name, dom.domain,
is_top_domain=dom.is_top_domain,
overwrite=overwrite)
self.display('load_domains.tmpl', domain=dom.domain,
organization=org.name)
except (ValueError, NotFoundError) as e:
raise RuntimeError(str(e))
except AlreadyExistsError as e:
msg = "%s. Not updated." % str(e)
self.warning(msg) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:import_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:parser; 6, default_parameter; 6, 7; 6, 8; 7, identifier:matching; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:match_new; 11, False; 12, default_parameter; 12, 13; 12, 14; 13, identifier:no_strict_matching; 14, False; 15, default_parameter; 15, 16; 15, 17; 16, identifier:reset; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:verbose; 20, False; 21, block; 21, 22; 21, 26; 21, 78; 21, 84; 21, 117; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:matcher; 25, None; 26, if_statement; 26, 27; 26, 28; 27, identifier:matching; 28, block; 28, 29; 28, 34; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:strict; 32, not_operator; 32, 33; 33, identifier:no_strict_matching; 34, try_statement; 34, 35; 34, 58; 35, block; 35, 36; 35, 47; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:blacklist; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:api; 42, identifier:blacklist; 43, argument_list; 43, 44; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:db; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:matcher; 50, call; 50, 51; 50, 52; 51, identifier:create_identity_matcher; 52, argument_list; 52, 53; 52, 54; 52, 55; 53, identifier:matching; 54, identifier:blacklist; 55, keyword_argument; 55, 56; 55, 57; 56, identifier:strict; 57, identifier:strict; 58, except_clause; 58, 59; 58, 63; 59, as_pattern; 59, 60; 59, 61; 60, identifier:MatcherNotSupportedError; 61, as_pattern_target; 61, 62; 62, identifier:e; 63, block; 63, 64; 63, 74; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:error; 69, argument_list; 69, 70; 70, call; 70, 71; 70, 72; 71, identifier:str; 72, argument_list; 72, 73; 73, identifier:e; 74, return_statement; 74, 75; 75, attribute; 75, 76; 75, 77; 76, identifier:e; 77, identifier:code; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:uidentities; 81, attribute; 81, 82; 81, 83; 82, identifier:parser; 83, identifier:identities; 84, try_statement; 84, 85; 84, 97; 85, block; 85, 86; 86, expression_statement; 86, 87; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:__load_unique_identities; 91, argument_list; 91, 92; 91, 93; 91, 94; 91, 95; 91, 96; 92, identifier:uidentities; 93, identifier:matcher; 94, identifier:match_new; 95, identifier:reset; 96, identifier:verbose; 97, except_clause; 97, 98; 97, 102; 98, as_pattern; 98, 99; 98, 100; 99, identifier:LoadError; 100, as_pattern_target; 100, 101; 101, identifier:e; 102, block; 102, 103; 102, 113; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:self; 107, identifier:error; 108, argument_list; 108, 109; 109, call; 109, 110; 109, 111; 110, identifier:str; 111, argument_list; 111, 112; 112, identifier:e; 113, return_statement; 113, 114; 114, attribute; 114, 115; 114, 116; 115, identifier:e; 116, identifier:code; 117, return_statement; 117, 118; 118, identifier:CMD_SUCCESS | def import_identities(self, parser, matching=None, match_new=False,
no_strict_matching=False,
reset=False, verbose=False):
matcher = None
if matching:
strict = not no_strict_matching
try:
blacklist = api.blacklist(self.db)
matcher = create_identity_matcher(matching, blacklist, strict=strict)
except MatcherNotSupportedError as e:
self.error(str(e))
return e.code
uidentities = parser.identities
try:
self.__load_unique_identities(uidentities, matcher, match_new,
reset, verbose)
except LoadError as e:
self.error(str(e))
return e.code
return CMD_SUCCESS |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:__create_profile_from_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:identities; 6, identifier:uuid; 7, identifier:verbose; 8, block; 8, 9; 8, 12; 8, 16; 8, 20; 8, 24; 8, 28; 8, 32; 8, 115; 8, 153; 8, 163; 8, 175; 9, import_statement; 9, 10; 10, dotted_name; 10, 11; 11, identifier:re; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:EMAIL_ADDRESS_REGEX; 15, string:r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$"; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:NAME_REGEX; 19, string:r"^\w+\s\w+"; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:name; 23, None; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:email; 27, None; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:username; 31, None; 32, for_statement; 32, 33; 32, 34; 32, 35; 33, identifier:identity; 34, identifier:identities; 35, block; 35, 36; 35, 65; 35, 94; 36, if_statement; 36, 37; 36, 43; 37, boolean_operator:and; 37, 38; 37, 40; 38, not_operator; 38, 39; 39, identifier:name; 40, attribute; 40, 41; 40, 42; 41, identifier:identity; 42, identifier:name; 43, block; 43, 44; 43, 56; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:m; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:re; 50, identifier:match; 51, argument_list; 51, 52; 51, 53; 52, identifier:NAME_REGEX; 53, attribute; 53, 54; 53, 55; 54, identifier:identity; 55, identifier:name; 56, if_statement; 56, 57; 56, 58; 57, identifier:m; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:name; 62, attribute; 62, 63; 62, 64; 63, identifier:identity; 64, identifier:name; 65, if_statement; 65, 66; 65, 72; 66, boolean_operator:and; 66, 67; 66, 69; 67, not_operator; 67, 68; 68, identifier:email; 69, attribute; 69, 70; 69, 71; 70, identifier:identity; 71, identifier:email; 72, block; 72, 73; 72, 85; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:m; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:re; 79, identifier:match; 80, argument_list; 80, 81; 80, 82; 81, identifier:EMAIL_ADDRESS_REGEX; 82, attribute; 82, 83; 82, 84; 83, identifier:identity; 84, identifier:email; 85, if_statement; 85, 86; 85, 87; 86, identifier:m; 87, block; 87, 88; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:email; 91, attribute; 91, 92; 91, 93; 92, identifier:identity; 93, identifier:email; 94, if_statement; 94, 95; 94, 97; 95, not_operator; 95, 96; 96, identifier:username; 97, block; 97, 98; 98, if_statement; 98, 99; 98, 108; 99, boolean_operator:and; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:identity; 102, identifier:username; 103, comparison_operator:!=; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:identity; 106, identifier:username; 107, string:'None'; 108, block; 108, 109; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:username; 112, attribute; 112, 113; 112, 114; 113, identifier:identity; 114, identifier:username; 115, if_statement; 115, 116; 115, 118; 116, not_operator; 116, 117; 117, identifier:name; 118, block; 118, 119; 119, if_statement; 119, 120; 119, 121; 119, 133; 119, 147; 120, identifier:email; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:name; 125, subscript; 125, 126; 125, 132; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:email; 129, identifier:split; 130, argument_list; 130, 131; 131, string:'@'; 132, integer:0; 133, elif_clause; 133, 134; 133, 135; 134, identifier:username; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:name; 139, subscript; 139, 140; 139, 146; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:username; 143, identifier:split; 144, argument_list; 144, 145; 145, string:'@'; 146, integer:0; 147, else_clause; 147, 148; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:name; 152, None; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:kw; 156, dictionary; 156, 157; 156, 160; 157, pair; 157, 158; 157, 159; 158, string:'name'; 159, identifier:name; 160, pair; 160, 161; 160, 162; 161, string:'email'; 162, identifier:email; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:api; 167, identifier:edit_profile; 168, argument_list; 168, 169; 168, 172; 168, 173; 169, attribute; 169, 170; 169, 171; 170, identifier:self; 171, identifier:db; 172, identifier:uuid; 173, dictionary_splat; 173, 174; 174, identifier:kw; 175, expression_statement; 175, 176; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:self; 179, identifier:log; 180, argument_list; 180, 181; 180, 184; 181, binary_operator:%; 181, 182; 181, 183; 182, string:"-- profile %s updated"; 183, identifier:uuid; 184, identifier:verbose | def __create_profile_from_identities(self, identities, uuid, verbose):
import re
EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$"
NAME_REGEX = r"^\w+\s\w+"
name = None
email = None
username = None
for identity in identities:
if not name and identity.name:
m = re.match(NAME_REGEX, identity.name)
if m:
name = identity.name
if not email and identity.email:
m = re.match(EMAIL_ADDRESS_REGEX, identity.email)
if m:
email = identity.email
if not username:
if identity.username and identity.username != 'None':
username = identity.username
if not name:
if email:
name = email.split('@')[0]
elif username:
name = username.split('@')[0]
else:
name = None
kw = {'name': name,
'email': email}
api.edit_profile(self.db, uuid, **kw)
self.log("-- profile %s updated" % uuid, verbose) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:__parse_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:aliases; 6, identifier:email_to_employer; 7, block; 7, 8; 7, 15; 7, 22; 7, 181; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:__parse_aliases_stream; 13, argument_list; 13, 14; 14, identifier:aliases; 15, expression_statement; 15, 16; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:__parse_email_to_employer_stream; 20, argument_list; 20, 21; 21, identifier:email_to_employer; 22, for_statement; 22, 23; 22, 26; 22, 33; 23, pattern_list; 23, 24; 23, 25; 24, identifier:alias; 25, identifier:email; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:__raw_aliases; 31, identifier:items; 32, argument_list; 33, block; 33, 34; 33, 46; 33, 124; 33, 139; 33, 172; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:uid; 37, call; 37, 38; 37, 43; 38, attribute; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:_identities; 42, identifier:get; 43, argument_list; 43, 44; 43, 45; 44, identifier:email; 45, None; 46, if_statement; 46, 47; 46, 49; 47, not_operator; 47, 48; 48, identifier:uid; 49, block; 49, 50; 49, 59; 49, 74; 49, 107; 49, 116; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:uid; 53, call; 53, 54; 53, 55; 54, identifier:UniqueIdentity; 55, argument_list; 55, 56; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:uuid; 58, identifier:email; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:e; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:re; 65, identifier:match; 66, argument_list; 66, 67; 66, 70; 66, 71; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:EMAIL_ADDRESS_REGEX; 70, identifier:email; 71, attribute; 71, 72; 71, 73; 72, identifier:re; 73, identifier:UNICODE; 74, if_statement; 74, 75; 74, 76; 74, 91; 75, identifier:e; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:identity; 80, call; 80, 81; 80, 82; 81, identifier:Identity; 82, argument_list; 82, 83; 82, 86; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:email; 85, identifier:email; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:source; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:source; 91, else_clause; 91, 92; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:identity; 96, call; 96, 97; 96, 98; 97, identifier:Identity; 98, argument_list; 98, 99; 98, 102; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:username; 101, identifier:email; 102, keyword_argument; 102, 103; 102, 104; 103, identifier:source; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:source; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 114; 109, attribute; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:uid; 112, identifier:identities; 113, identifier:append; 114, argument_list; 114, 115; 115, identifier:identity; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 123; 118, subscript; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:_identities; 122, identifier:email; 123, identifier:uid; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:e; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:re; 130, identifier:match; 131, argument_list; 131, 132; 131, 135; 131, 136; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:EMAIL_ADDRESS_REGEX; 135, identifier:alias; 136, attribute; 136, 137; 136, 138; 137, identifier:re; 138, identifier:UNICODE; 139, if_statement; 139, 140; 139, 141; 139, 156; 140, identifier:e; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:identity; 145, call; 145, 146; 145, 147; 146, identifier:Identity; 147, argument_list; 147, 148; 147, 151; 148, keyword_argument; 148, 149; 148, 150; 149, identifier:email; 150, identifier:alias; 151, keyword_argument; 151, 152; 151, 153; 152, identifier:source; 153, attribute; 153, 154; 153, 155; 154, identifier:self; 155, identifier:source; 156, else_clause; 156, 157; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:identity; 161, call; 161, 162; 161, 163; 162, identifier:Identity; 163, argument_list; 163, 164; 163, 167; 164, keyword_argument; 164, 165; 164, 166; 165, identifier:username; 166, identifier:alias; 167, keyword_argument; 167, 168; 167, 169; 168, identifier:source; 169, attribute; 169, 170; 169, 171; 170, identifier:self; 171, identifier:source; 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:uid; 177, identifier:identities; 178, identifier:append; 179, argument_list; 179, 180; 180, identifier:identity; 181, for_statement; 181, 182; 181, 183; 181, 186; 182, identifier:email; 183, attribute; 183, 184; 183, 185; 184, identifier:self; 185, identifier:__raw_identities; 186, block; 186, 187; 186, 267; 186, 275; 186, 289; 186, 293; 187, if_statement; 187, 188; 187, 193; 187, 202; 187, 225; 188, comparison_operator:in; 188, 189; 188, 190; 189, identifier:email; 190, attribute; 190, 191; 190, 192; 191, identifier:self; 192, identifier:_identities; 193, block; 193, 194; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:uid; 197, subscript; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:self; 200, identifier:_identities; 201, identifier:email; 202, elif_clause; 202, 203; 202, 208; 203, comparison_operator:in; 203, 204; 203, 205; 204, identifier:email; 205, attribute; 205, 206; 205, 207; 206, identifier:self; 207, identifier:__raw_aliases; 208, block; 208, 209; 208, 217; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:canonical; 212, subscript; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:self; 215, identifier:__raw_aliases; 216, identifier:email; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:uid; 220, subscript; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:self; 223, identifier:_identities; 224, identifier:canonical; 225, else_clause; 225, 226; 226, block; 226, 227; 226, 236; 226, 250; 226, 259; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:uid; 230, call; 230, 231; 230, 232; 231, identifier:UniqueIdentity; 232, argument_list; 232, 233; 233, keyword_argument; 233, 234; 233, 235; 234, identifier:uuid; 235, identifier:email; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:identity; 239, call; 239, 240; 239, 241; 240, identifier:Identity; 241, argument_list; 241, 242; 241, 245; 242, keyword_argument; 242, 243; 242, 244; 243, identifier:email; 244, identifier:email; 245, keyword_argument; 245, 246; 245, 247; 246, identifier:source; 247, attribute; 247, 248; 247, 249; 248, identifier:self; 249, identifier:source; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 257; 252, attribute; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:uid; 255, identifier:identities; 256, identifier:append; 257, argument_list; 257, 258; 258, identifier:identity; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 266; 261, subscript; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:self; 264, identifier:_identities; 265, identifier:email; 266, identifier:uid; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:enrs; 270, subscript; 270, 271; 270, 274; 271, attribute; 271, 272; 271, 273; 272, identifier:self; 273, identifier:__raw_identities; 274, identifier:email; 275, expression_statement; 275, 276; 276, call; 276, 277; 276, 280; 277, attribute; 277, 278; 277, 279; 278, identifier:enrs; 279, identifier:sort; 280, argument_list; 280, 281; 281, keyword_argument; 281, 282; 281, 283; 282, identifier:key; 283, lambda; 283, 284; 283, 286; 284, lambda_parameters; 284, 285; 285, identifier:r; 286, subscript; 286, 287; 286, 288; 287, identifier:r; 288, integer:1; 289, expression_statement; 289, 290; 290, assignment; 290, 291; 290, 292; 291, identifier:start_date; 292, identifier:MIN_PERIOD_DATE; 293, for_statement; 293, 294; 293, 295; 293, 296; 294, identifier:rol; 295, identifier:enrs; 296, block; 296, 297; 296, 303; 296, 315; 296, 336; 296, 342; 296, 357; 296, 366; 297, expression_statement; 297, 298; 298, assignment; 298, 299; 298, 300; 299, identifier:name; 300, subscript; 300, 301; 300, 302; 301, identifier:rol; 302, integer:0; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 306; 305, identifier:org; 306, call; 306, 307; 306, 312; 307, attribute; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:self; 310, identifier:_organizations; 311, identifier:get; 312, argument_list; 312, 313; 312, 314; 313, identifier:name; 314, None; 315, if_statement; 315, 316; 315, 318; 316, not_operator; 316, 317; 317, identifier:org; 318, block; 318, 319; 318, 328; 319, expression_statement; 319, 320; 320, assignment; 320, 321; 320, 322; 321, identifier:org; 322, call; 322, 323; 322, 324; 323, identifier:Organization; 324, argument_list; 324, 325; 325, keyword_argument; 325, 326; 325, 327; 326, identifier:name; 327, identifier:name; 328, expression_statement; 328, 329; 329, assignment; 329, 330; 329, 335; 330, subscript; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:self; 333, identifier:_organizations; 334, identifier:name; 335, identifier:org; 336, expression_statement; 336, 337; 337, assignment; 337, 338; 337, 339; 338, identifier:end_date; 339, subscript; 339, 340; 339, 341; 340, identifier:rol; 341, integer:1; 342, expression_statement; 342, 343; 343, assignment; 343, 344; 343, 345; 344, identifier:enrollment; 345, call; 345, 346; 345, 347; 346, identifier:Enrollment; 347, argument_list; 347, 348; 347, 351; 347, 354; 348, keyword_argument; 348, 349; 348, 350; 349, identifier:start; 350, identifier:start_date; 351, keyword_argument; 351, 352; 351, 353; 352, identifier:end; 353, identifier:end_date; 354, keyword_argument; 354, 355; 354, 356; 355, identifier:organization; 356, identifier:org; 357, expression_statement; 357, 358; 358, call; 358, 359; 358, 364; 359, attribute; 359, 360; 359, 363; 360, attribute; 360, 361; 360, 362; 361, identifier:uid; 362, identifier:enrollments; 363, identifier:append; 364, argument_list; 364, 365; 365, identifier:enrollment; 366, if_statement; 366, 367; 366, 370; 367, comparison_operator:!=; 367, 368; 367, 369; 368, identifier:end_date; 369, identifier:MAX_PERIOD_DATE; 370, block; 370, 371; 371, expression_statement; 371, 372; 372, assignment; 372, 373; 372, 374; 373, identifier:start_date; 374, identifier:end_date | def __parse_identities(self, aliases, email_to_employer):
self.__parse_aliases_stream(aliases)
self.__parse_email_to_employer_stream(email_to_employer)
for alias, email in self.__raw_aliases.items():
uid = self._identities.get(email, None)
if not uid:
uid = UniqueIdentity(uuid=email)
e = re.match(self.EMAIL_ADDRESS_REGEX, email, re.UNICODE)
if e:
identity = Identity(email=email, source=self.source)
else:
identity = Identity(username=email, source=self.source)
uid.identities.append(identity)
self._identities[email] = uid
e = re.match(self.EMAIL_ADDRESS_REGEX, alias, re.UNICODE)
if e:
identity = Identity(email=alias, source=self.source)
else:
identity = Identity(username=alias, source=self.source)
uid.identities.append(identity)
for email in self.__raw_identities:
if email in self._identities:
uid = self._identities[email]
elif email in self.__raw_aliases:
canonical = self.__raw_aliases[email]
uid = self._identities[canonical]
else:
uid = UniqueIdentity(uuid=email)
identity = Identity(email=email, source=self.source)
uid.identities.append(identity)
self._identities[email] = uid
enrs = self.__raw_identities[email]
enrs.sort(key=lambda r: r[1])
start_date = MIN_PERIOD_DATE
for rol in enrs:
name = rol[0]
org = self._organizations.get(name, None)
if not org:
org = Organization(name=name)
self._organizations[name] = org
end_date = rol[1]
enrollment = Enrollment(start=start_date, end=end_date,
organization=org)
uid.enrollments.append(enrollment)
if end_date != MAX_PERIOD_DATE:
start_date = end_date |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:initialize; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reuse; 8, False; 9, block; 9, 10; 9, 18; 9, 26; 9, 34; 9, 42; 9, 58; 9, 158; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:user; 13, subscript; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:_kwargs; 17, string:'user'; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:password; 21, subscript; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_kwargs; 25, string:'password'; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:host; 29, subscript; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:_kwargs; 33, string:'host'; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:port; 37, subscript; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:_kwargs; 41, string:'port'; 42, if_statement; 42, 43; 42, 46; 43, comparison_operator:in; 43, 44; 43, 45; 44, string:'-'; 45, identifier:name; 46, block; 46, 47; 46, 56; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:error; 52, argument_list; 52, 53; 53, binary_operator:%; 53, 54; 53, 55; 54, string:"dabase name '%s' cannot contain '-' characters"; 55, identifier:name; 56, return_statement; 56, 57; 57, identifier:CODE_VALUE_ERROR; 58, try_statement; 58, 59; 58, 89; 58, 111; 58, 129; 59, block; 59, 60; 59, 71; 59, 82; 60, expression_statement; 60, 61; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:Database; 64, identifier:create; 65, argument_list; 65, 66; 65, 67; 65, 68; 65, 69; 65, 70; 66, identifier:user; 67, identifier:password; 68, identifier:name; 69, identifier:host; 70, identifier:port; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:db; 74, call; 74, 75; 74, 76; 75, identifier:Database; 76, argument_list; 76, 77; 76, 78; 76, 79; 76, 80; 76, 81; 77, identifier:user; 78, identifier:password; 79, identifier:name; 80, identifier:host; 81, identifier:port; 82, expression_statement; 82, 83; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:self; 86, identifier:__load_countries; 87, argument_list; 87, 88; 88, identifier:db; 89, except_clause; 89, 90; 89, 94; 90, as_pattern; 90, 91; 90, 92; 91, identifier:DatabaseExists; 92, as_pattern_target; 92, 93; 93, identifier:e; 94, block; 94, 95; 95, if_statement; 95, 96; 95, 98; 96, not_operator; 96, 97; 97, identifier:reuse; 98, block; 98, 99; 98, 109; 99, expression_statement; 99, 100; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:self; 103, identifier:error; 104, argument_list; 104, 105; 105, call; 105, 106; 105, 107; 106, identifier:str; 107, argument_list; 107, 108; 108, identifier:e; 109, return_statement; 109, 110; 110, identifier:CODE_DATABASE_EXISTS; 111, except_clause; 111, 112; 111, 116; 112, as_pattern; 112, 113; 112, 114; 113, identifier:DatabaseError; 114, as_pattern_target; 114, 115; 115, identifier:e; 116, block; 116, 117; 116, 127; 117, expression_statement; 117, 118; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:error; 122, argument_list; 122, 123; 123, call; 123, 124; 123, 125; 124, identifier:str; 125, argument_list; 125, 126; 126, identifier:e; 127, return_statement; 127, 128; 128, identifier:CODE_DATABASE_ERROR; 129, except_clause; 129, 130; 129, 134; 130, as_pattern; 130, 131; 130, 132; 131, identifier:LoadError; 132, as_pattern_target; 132, 133; 133, identifier:e; 134, block; 134, 135; 134, 146; 134, 156; 135, expression_statement; 135, 136; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:Database; 139, identifier:drop; 140, argument_list; 140, 141; 140, 142; 140, 143; 140, 144; 140, 145; 141, identifier:user; 142, identifier:password; 143, identifier:name; 144, identifier:host; 145, identifier:port; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:self; 150, identifier:error; 151, argument_list; 151, 152; 152, call; 152, 153; 152, 154; 153, identifier:str; 154, argument_list; 154, 155; 155, identifier:e; 156, return_statement; 156, 157; 157, identifier:CODE_LOAD_ERROR; 158, return_statement; 158, 159; 159, identifier:CMD_SUCCESS | def initialize(self, name, reuse=False):
user = self._kwargs['user']
password = self._kwargs['password']
host = self._kwargs['host']
port = self._kwargs['port']
if '-' in name:
self.error("dabase name '%s' cannot contain '-' characters" % name)
return CODE_VALUE_ERROR
try:
Database.create(user, password, name, host, port)
db = Database(user, password, name, host, port)
self.__load_countries(db)
except DatabaseExists as e:
if not reuse:
self.error(str(e))
return CODE_DATABASE_EXISTS
except DatabaseError as e:
self.error(str(e))
return CODE_DATABASE_ERROR
except LoadError as e:
Database.drop(user, password, name, host, port)
self.error(str(e))
return CODE_LOAD_ERROR
return CMD_SUCCESS |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge_date_ranges; 3, parameters; 3, 4; 4, identifier:dates; 5, block; 5, 6; 5, 11; 5, 25; 5, 34; 5, 153; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:dates; 9, block; 9, 10; 10, return_statement; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:sorted_dates; 14, call; 14, 15; 14, 16; 15, identifier:sorted; 16, argument_list; 16, 17; 17, list_comprehension; 17, 18; 17, 22; 18, call; 18, 19; 18, 20; 19, identifier:sorted; 20, argument_list; 20, 21; 21, identifier:t; 22, for_in_clause; 22, 23; 22, 24; 23, identifier:t; 24, identifier:dates; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:saved; 28, call; 28, 29; 28, 30; 29, identifier:list; 30, argument_list; 30, 31; 31, subscript; 31, 32; 31, 33; 32, identifier:sorted_dates; 33, integer:0; 34, for_statement; 34, 35; 34, 38; 34, 39; 35, pattern_list; 35, 36; 35, 37; 36, identifier:st; 37, identifier:en; 38, identifier:sorted_dates; 39, block; 39, 40; 39, 59; 39, 78; 40, if_statement; 40, 41; 40, 48; 41, boolean_operator:or; 41, 42; 41, 45; 42, comparison_operator:<; 42, 43; 42, 44; 43, identifier:st; 44, identifier:MIN_PERIOD_DATE; 45, comparison_operator:>; 45, 46; 45, 47; 46, identifier:st; 47, identifier:MAX_PERIOD_DATE; 48, block; 48, 49; 49, raise_statement; 49, 50; 50, call; 50, 51; 50, 52; 51, identifier:ValueError; 52, argument_list; 52, 53; 53, binary_operator:%; 53, 54; 53, 55; 54, string:"start date %s is out of bounds"; 55, call; 55, 56; 55, 57; 56, identifier:str; 57, argument_list; 57, 58; 58, identifier:st; 59, if_statement; 59, 60; 59, 67; 60, boolean_operator:or; 60, 61; 60, 64; 61, comparison_operator:<; 61, 62; 61, 63; 62, identifier:en; 63, identifier:MIN_PERIOD_DATE; 64, comparison_operator:>; 64, 65; 64, 66; 65, identifier:en; 66, identifier:MAX_PERIOD_DATE; 67, block; 67, 68; 68, raise_statement; 68, 69; 69, call; 69, 70; 69, 71; 70, identifier:ValueError; 71, argument_list; 71, 72; 72, binary_operator:%; 72, 73; 72, 74; 73, string:"end date %s is out of bounds"; 74, call; 74, 75; 74, 76; 75, identifier:str; 76, argument_list; 76, 77; 77, identifier:en; 78, if_statement; 78, 79; 78, 84; 78, 133; 79, comparison_operator:<=; 79, 80; 79, 81; 80, identifier:st; 81, subscript; 81, 82; 81, 83; 82, identifier:saved; 83, integer:1; 84, block; 84, 85; 84, 98; 85, if_statement; 85, 86; 85, 91; 86, comparison_operator:==; 86, 87; 86, 90; 87, subscript; 87, 88; 87, 89; 88, identifier:saved; 89, integer:0; 90, identifier:MIN_PERIOD_DATE; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, subscript; 94, 95; 94, 96; 95, identifier:saved; 96, integer:0; 97, identifier:st; 98, if_statement; 98, 99; 98, 106; 98, 119; 99, comparison_operator:in; 99, 100; 99, 101; 100, identifier:MAX_PERIOD_DATE; 101, tuple; 101, 102; 101, 103; 102, identifier:en; 103, subscript; 103, 104; 103, 105; 104, identifier:saved; 105, integer:1; 106, block; 106, 107; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 112; 109, subscript; 109, 110; 109, 111; 110, identifier:saved; 111, integer:1; 112, call; 112, 113; 112, 114; 113, identifier:min; 114, argument_list; 114, 115; 114, 118; 115, subscript; 115, 116; 115, 117; 116, identifier:saved; 117, integer:1; 118, identifier:en; 119, else_clause; 119, 120; 120, block; 120, 121; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 126; 123, subscript; 123, 124; 123, 125; 124, identifier:saved; 125, integer:1; 126, call; 126, 127; 126, 128; 127, identifier:max; 128, argument_list; 128, 129; 128, 132; 129, subscript; 129, 130; 129, 131; 130, identifier:saved; 131, integer:1; 132, identifier:en; 133, else_clause; 133, 134; 134, block; 134, 135; 134, 141; 134, 147; 135, expression_statement; 135, 136; 136, yield; 136, 137; 137, call; 137, 138; 137, 139; 138, identifier:tuple; 139, argument_list; 139, 140; 140, identifier:saved; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 146; 143, subscript; 143, 144; 143, 145; 144, identifier:saved; 145, integer:0; 146, identifier:st; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 152; 149, subscript; 149, 150; 149, 151; 150, identifier:saved; 151, integer:1; 152, identifier:en; 153, expression_statement; 153, 154; 154, yield; 154, 155; 155, call; 155, 156; 155, 157; 156, identifier:tuple; 157, argument_list; 157, 158; 158, identifier:saved | def merge_date_ranges(dates):
if not dates:
return
sorted_dates = sorted([sorted(t) for t in dates])
saved = list(sorted_dates[0])
for st, en in sorted_dates:
if st < MIN_PERIOD_DATE or st > MAX_PERIOD_DATE:
raise ValueError("start date %s is out of bounds" % str(st))
if en < MIN_PERIOD_DATE or en > MAX_PERIOD_DATE:
raise ValueError("end date %s is out of bounds" % str(en))
if st <= saved[1]:
if saved[0] == MIN_PERIOD_DATE:
saved[0] = st
if MAX_PERIOD_DATE in (en, saved[1]):
saved[1] = min(saved[1], en)
else:
saved[1] = max(saved[1], en)
else:
yield tuple(saved)
saved[0] = st
saved[1] = en
yield tuple(saved) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:uuid; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:source; 5, default_parameter; 5, 6; 5, 7; 6, identifier:email; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:name; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:username; 13, None; 14, block; 14, 15; 14, 25; 14, 35; 14, 49; 14, 81; 14, 98; 14, 106; 15, if_statement; 15, 16; 15, 19; 16, comparison_operator:is; 16, 17; 16, 18; 17, identifier:source; 18, None; 19, block; 19, 20; 20, raise_statement; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:ValueError; 23, argument_list; 23, 24; 24, string:"source cannot be None"; 25, if_statement; 25, 26; 25, 29; 26, comparison_operator:==; 26, 27; 26, 28; 27, identifier:source; 28, string:''; 29, block; 29, 30; 30, raise_statement; 30, 31; 31, call; 31, 32; 31, 33; 32, identifier:ValueError; 33, argument_list; 33, 34; 34, string:"source cannot be an empty string"; 35, if_statement; 35, 36; 35, 43; 36, not_operator; 36, 37; 37, parenthesized_expression; 37, 38; 38, boolean_operator:or; 38, 39; 38, 42; 39, boolean_operator:or; 39, 40; 39, 41; 40, identifier:email; 41, identifier:name; 42, identifier:username; 43, block; 43, 44; 44, raise_statement; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:ValueError; 47, argument_list; 47, 48; 48, string:"identity data cannot be None or empty"; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:s; 52, call; 52, 53; 52, 80; 53, attribute; 53, 54; 53, 79; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, string:':'; 57, identifier:join; 58, argument_list; 58, 59; 59, tuple; 59, 60; 59, 64; 59, 68; 59, 75; 60, call; 60, 61; 60, 62; 61, identifier:to_unicode; 62, argument_list; 62, 63; 63, identifier:source; 64, call; 64, 65; 64, 66; 65, identifier:to_unicode; 66, argument_list; 66, 67; 67, identifier:email; 68, call; 68, 69; 68, 70; 69, identifier:to_unicode; 70, argument_list; 70, 71; 70, 72; 71, identifier:name; 72, keyword_argument; 72, 73; 72, 74; 73, identifier:unaccent; 74, True; 75, call; 75, 76; 75, 77; 76, identifier:to_unicode; 77, argument_list; 77, 78; 78, identifier:username; 79, identifier:lower; 80, argument_list; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:sha1; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:hashlib; 87, identifier:sha1; 88, argument_list; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:s; 92, identifier:encode; 93, argument_list; 93, 94; 93, 95; 94, string:'UTF-8'; 95, keyword_argument; 95, 96; 95, 97; 96, identifier:errors; 97, string:"surrogateescape"; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:uuid_; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:sha1; 104, identifier:hexdigest; 105, argument_list; 106, return_statement; 106, 107; 107, identifier:uuid_ | def uuid(source, email=None, name=None, username=None):
if source is None:
raise ValueError("source cannot be None")
if source == '':
raise ValueError("source cannot be an empty string")
if not (email or name or username):
raise ValueError("identity data cannot be None or empty")
s = ':'.join((to_unicode(source),
to_unicode(email),
to_unicode(name, unaccent=True),
to_unicode(username))).lower()
sha1 = hashlib.sha1(s.encode('UTF-8', errors="surrogateescape"))
uuid_ = sha1.hexdigest()
return uuid_ |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:call; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 11; 3, 16; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:method_name; 7, type; 7, 8; 8, identifier:str; 9, list_splat_pattern; 9, 10; 10, identifier:args; 11, typed_default_parameter; 11, 12; 11, 13; 11, 15; 12, identifier:rpc_timeout; 13, type; 13, 14; 14, identifier:float; 15, None; 16, dictionary_splat_pattern; 16, 17; 17, identifier:kwargs; 18, block; 18, 19; 18, 32; 18, 40; 18, 53; 18, 64; 18, 72; 18, 162; 18, 173; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:request; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:utils; 25, identifier:rpc_request; 26, argument_list; 26, 27; 26, 28; 26, 30; 27, identifier:method_name; 28, list_splat; 28, 29; 29, identifier:args; 30, dictionary_splat; 30, 31; 31, identifier:kwargs; 32, expression_statement; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:_log; 36, identifier:debug; 37, argument_list; 37, 38; 37, 39; 38, string:"Sending request: %s"; 39, identifier:request; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 47; 42, attribute; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:_socket; 46, identifier:send_multipart; 47, argument_list; 47, 48; 48, list:[to_msgpack(request)]; 48, 49; 49, call; 49, 50; 49, 51; 50, identifier:to_msgpack; 51, argument_list; 51, 52; 52, identifier:request; 53, if_statement; 53, 54; 53, 57; 54, comparison_operator:is; 54, 55; 54, 56; 55, identifier:rpc_timeout; 56, None; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:rpc_timeout; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:rpc_timeout; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:start_time; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:time; 70, identifier:time; 71, argument_list; 72, while_statement; 72, 73; 72, 74; 73, True; 74, block; 74, 75; 74, 99; 74, 116; 74, 127; 74, 134; 74, 142; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:timeout; 78, conditional_expression:if; 78, 79; 78, 95; 78, 98; 79, call; 79, 80; 79, 81; 80, identifier:max; 81, argument_list; 81, 82; 81, 94; 82, binary_operator:*; 82, 83; 82, 93; 83, parenthesized_expression; 83, 84; 84, binary_operator:-; 84, 85; 84, 88; 85, binary_operator:+; 85, 86; 85, 87; 86, identifier:start_time; 87, identifier:rpc_timeout; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:time; 91, identifier:time; 92, argument_list; 93, integer:1000; 94, integer:0; 95, comparison_operator:is; 95, 96; 95, 97; 96, identifier:rpc_timeout; 97, None; 98, None; 99, if_statement; 99, 100; 99, 110; 100, comparison_operator:==; 100, 101; 100, 109; 101, call; 101, 102; 101, 107; 102, attribute; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:self; 105, identifier:_socket; 106, identifier:poll; 107, argument_list; 107, 108; 108, identifier:timeout; 109, integer:0; 110, block; 110, 111; 111, raise_statement; 111, 112; 112, call; 112, 113; 112, 114; 113, identifier:TimeoutError; 114, argument_list; 114, 115; 115, string:f"Timeout on client {self.endpoint}, method name {method_name}, class info: {self}"; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 120; 118, pattern_list; 118, 119; 119, identifier:raw_reply; 120, call; 120, 121; 120, 126; 121, attribute; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:self; 124, identifier:_socket; 125, identifier:recv_multipart; 126, argument_list; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:reply; 130, call; 130, 131; 130, 132; 131, identifier:from_msgpack; 132, argument_list; 132, 133; 133, identifier:raw_reply; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:_log; 138, identifier:debug; 139, argument_list; 139, 140; 139, 141; 140, string:"Received reply: %s"; 141, identifier:reply; 142, if_statement; 142, 143; 142, 150; 142, 152; 143, comparison_operator:==; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:reply; 146, identifier:id; 147, attribute; 147, 148; 147, 149; 148, identifier:request; 149, identifier:id; 150, block; 150, 151; 151, break_statement; 152, else_clause; 152, 153; 153, block; 153, 154; 154, expression_statement; 154, 155; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:_log; 158, identifier:debug; 159, argument_list; 159, 160; 159, 161; 160, string:'Discarding reply: %s'; 161, identifier:reply; 162, for_statement; 162, 163; 162, 164; 162, 167; 163, identifier:warning; 164, attribute; 164, 165; 164, 166; 165, identifier:reply; 166, identifier:warnings; 167, block; 167, 168; 168, expression_statement; 168, 169; 169, call; 169, 170; 169, 171; 170, identifier:warn; 171, argument_list; 171, 172; 172, string:f"{warning.kind}: {warning.body}"; 173, if_statement; 173, 174; 173, 179; 173, 189; 174, call; 174, 175; 174, 176; 175, identifier:isinstance; 176, argument_list; 176, 177; 176, 178; 177, identifier:reply; 178, identifier:RPCError; 179, block; 179, 180; 180, raise_statement; 180, 181; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:utils; 184, identifier:RPCError; 185, argument_list; 185, 186; 186, attribute; 186, 187; 186, 188; 187, identifier:reply; 188, identifier:error; 189, else_clause; 189, 190; 190, block; 190, 191; 191, return_statement; 191, 192; 192, attribute; 192, 193; 192, 194; 193, identifier:reply; 194, identifier:result | def call(self, method_name: str, *args, rpc_timeout: float = None, **kwargs):
request = utils.rpc_request(method_name, *args, **kwargs)
_log.debug("Sending request: %s", request)
self._socket.send_multipart([to_msgpack(request)])
if rpc_timeout is None:
rpc_timeout = self.rpc_timeout
start_time = time.time()
while True:
timeout = max((start_time + rpc_timeout - time.time()) * 1000, 0) if rpc_timeout is not None else None
if self._socket.poll(timeout) == 0:
raise TimeoutError(f"Timeout on client {self.endpoint}, method name {method_name}, class info: {self}")
raw_reply, = self._socket.recv_multipart()
reply = from_msgpack(raw_reply)
_log.debug("Received reply: %s", reply)
if reply.id == request.id:
break
else:
_log.debug('Discarding reply: %s', reply)
for warning in reply.warnings:
warn(f"{warning.kind}: {warning.body}")
if isinstance(reply, RPCError):
raise utils.RPCError(reply.error)
else:
return reply.result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:init_process_dut; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:contextlist; 5, identifier:conf; 6, identifier:index; 7, identifier:args; 8, block; 8, 9; 8, 311; 8, 320; 9, if_statement; 9, 10; 9, 17; 9, 97; 10, boolean_operator:and; 10, 11; 10, 14; 11, comparison_operator:in; 11, 12; 11, 13; 12, string:"subtype"; 13, identifier:conf; 14, subscript; 14, 15; 14, 16; 15, identifier:conf; 16, string:"subtype"; 17, block; 17, 18; 17, 50; 17, 54; 17, 65; 17, 74; 17, 91; 18, if_statement; 18, 19; 18, 24; 19, comparison_operator:!=; 19, 20; 19, 23; 20, subscript; 20, 21; 20, 22; 21, identifier:conf; 22, string:"subtype"; 23, string:"console"; 24, block; 24, 25; 24, 29; 24, 45; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:msg; 28, string:"Unrecognized process subtype: {}"; 29, expression_statement; 29, 30; 30, call; 30, 31; 30, 36; 31, attribute; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:contextlist; 34, identifier:logger; 35, identifier:error; 36, argument_list; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:msg; 40, identifier:format; 41, argument_list; 41, 42; 42, subscript; 42, 43; 42, 44; 43, identifier:conf; 44, string:"subtype"; 45, raise_statement; 45, 46; 46, call; 46, 47; 46, 48; 47, identifier:ResourceInitError; 48, argument_list; 48, 49; 49, string:"Unrecognized process subtype: {}"; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:config; 53, None; 54, if_statement; 54, 55; 54, 58; 55, comparison_operator:in; 55, 56; 55, 57; 56, string:"application"; 57, identifier:conf; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:config; 62, subscript; 62, 63; 62, 64; 63, identifier:conf; 64, string:"application"; 65, expression_statement; 65, 66; 66, call; 66, 67; 66, 72; 67, attribute; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:contextlist; 70, identifier:logger; 71, identifier:debug; 72, argument_list; 72, 73; 73, string:"Starting a remote console"; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:dut; 77, call; 77, 78; 77, 79; 78, identifier:DutConsole; 79, argument_list; 79, 80; 79, 85; 79, 88; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:name; 82, binary_operator:%; 82, 83; 82, 84; 83, string:"D%d"; 84, identifier:index; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:conf; 87, identifier:config; 88, keyword_argument; 88, 89; 88, 90; 89, identifier:params; 90, identifier:args; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:dut; 95, identifier:index; 96, identifier:index; 97, else_clause; 97, 98; 98, block; 98, 99; 98, 107; 98, 113; 98, 123; 98, 133; 98, 144; 98, 161; 98, 167; 98, 173; 98, 200; 98, 224; 98, 252; 98, 276; 98, 287; 98, 299; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:binary; 102, subscript; 102, 103; 102, 106; 103, subscript; 103, 104; 103, 105; 104, identifier:conf; 105, string:"application"; 106, string:'bin'; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:app_config; 110, subscript; 110, 111; 110, 112; 111, identifier:conf; 112, string:"application"; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:init_cli_cmds; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:app_config; 119, identifier:get; 120, argument_list; 120, 121; 120, 122; 121, string:"init_cli_cmds"; 122, None; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:post_cli_cmds; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:app_config; 129, identifier:get; 130, argument_list; 130, 131; 130, 132; 131, string:"post_cli_cmds"; 132, None; 133, expression_statement; 133, 134; 134, call; 134, 135; 134, 140; 135, attribute; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:contextlist; 138, identifier:logger; 139, identifier:debug; 140, argument_list; 140, 141; 141, binary_operator:%; 141, 142; 141, 143; 142, string:"Starting process '%s'"; 143, identifier:binary; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:dut; 147, call; 147, 148; 147, 149; 148, identifier:DutProcess; 149, argument_list; 149, 150; 149, 155; 149, 158; 150, keyword_argument; 150, 151; 150, 152; 151, identifier:name; 152, binary_operator:%; 152, 153; 152, 154; 153, string:"D%d"; 154, identifier:index; 155, keyword_argument; 155, 156; 155, 157; 156, identifier:config; 157, identifier:conf; 158, keyword_argument; 158, 159; 158, 160; 159, identifier:params; 160, identifier:args; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:dut; 165, identifier:index; 166, identifier:index; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:dut; 171, identifier:command; 172, identifier:binary; 173, if_statement; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:args; 176, identifier:valgrind; 177, block; 177, 178; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:dut; 182, identifier:use_valgrind; 183, argument_list; 183, 184; 183, 187; 183, 191; 183, 194; 183, 197; 184, attribute; 184, 185; 184, 186; 185, identifier:args; 186, identifier:valgrind_tool; 187, not_operator; 187, 188; 188, attribute; 188, 189; 188, 190; 189, identifier:args; 190, identifier:valgrind_text; 191, attribute; 191, 192; 191, 193; 192, identifier:args; 193, identifier:valgrind_console; 194, attribute; 194, 195; 194, 196; 195, identifier:args; 196, identifier:valgrind_track_origins; 197, attribute; 197, 198; 197, 199; 198, identifier:args; 199, identifier:valgrind_extra_params; 200, if_statement; 200, 201; 200, 206; 201, comparison_operator:==; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:args; 204, identifier:gdb; 205, identifier:index; 206, block; 206, 207; 206, 213; 207, expression_statement; 207, 208; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:dut; 211, identifier:use_gdb; 212, argument_list; 213, expression_statement; 213, 214; 214, call; 214, 215; 214, 220; 215, attribute; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:contextlist; 218, identifier:logger; 219, identifier:info; 220, argument_list; 220, 221; 221, binary_operator:%; 221, 222; 221, 223; 222, string:"GDB is activated for node %i"; 223, identifier:index; 224, if_statement; 224, 225; 224, 230; 225, comparison_operator:==; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:args; 228, identifier:gdbs; 229, identifier:index; 230, block; 230, 231; 230, 241; 231, expression_statement; 231, 232; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:dut; 235, identifier:use_gdbs; 236, argument_list; 236, 237; 236, 238; 237, True; 238, attribute; 238, 239; 238, 240; 239, identifier:args; 240, identifier:gdbs_port; 241, expression_statement; 241, 242; 242, call; 242, 243; 242, 248; 243, attribute; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:contextlist; 246, identifier:logger; 247, identifier:info; 248, argument_list; 248, 249; 249, binary_operator:%; 249, 250; 249, 251; 250, string:"GDBserver is activated for node %i"; 251, identifier:index; 252, if_statement; 252, 253; 252, 258; 253, comparison_operator:==; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:args; 256, identifier:vgdb; 257, identifier:index; 258, block; 258, 259; 258, 265; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:dut; 263, identifier:use_vgdb; 264, argument_list; 265, expression_statement; 265, 266; 266, call; 266, 267; 266, 272; 267, attribute; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:contextlist; 270, identifier:logger; 271, identifier:info; 272, argument_list; 272, 273; 273, binary_operator:%; 273, 274; 273, 275; 274, string:"VGDB is activated for node %i"; 275, identifier:index; 276, if_statement; 276, 277; 276, 280; 277, attribute; 277, 278; 277, 279; 278, identifier:args; 279, identifier:nobuf; 280, block; 280, 281; 281, expression_statement; 281, 282; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:dut; 285, identifier:no_std_buf; 286, argument_list; 287, if_statement; 287, 288; 287, 291; 288, comparison_operator:is; 288, 289; 288, 290; 289, identifier:init_cli_cmds; 290, None; 291, block; 291, 292; 292, expression_statement; 292, 293; 293, call; 293, 294; 293, 297; 294, attribute; 294, 295; 294, 296; 295, identifier:dut; 296, identifier:set_init_cli_cmds; 297, argument_list; 297, 298; 298, identifier:init_cli_cmds; 299, if_statement; 299, 300; 299, 303; 300, comparison_operator:is; 300, 301; 300, 302; 301, identifier:post_cli_cmds; 302, None; 303, block; 303, 304; 304, expression_statement; 304, 305; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:dut; 308, identifier:set_post_cli_cmds; 309, argument_list; 309, 310; 310, identifier:post_cli_cmds; 311, expression_statement; 311, 312; 312, call; 312, 313; 312, 318; 313, attribute; 313, 314; 313, 317; 314, attribute; 314, 315; 314, 316; 315, identifier:contextlist; 316, identifier:duts; 317, identifier:append; 318, argument_list; 318, 319; 319, identifier:dut; 320, expression_statement; 320, 321; 321, call; 321, 322; 321, 327; 322, attribute; 322, 323; 322, 326; 323, attribute; 323, 324; 323, 325; 324, identifier:contextlist; 325, identifier:dutinformations; 326, identifier:append; 327, argument_list; 327, 328; 328, call; 328, 329; 328, 332; 329, attribute; 329, 330; 329, 331; 330, identifier:dut; 331, identifier:get_info; 332, argument_list | def init_process_dut(contextlist, conf, index, args):
if "subtype" in conf and conf["subtype"]:
if conf["subtype"] != "console":
msg = "Unrecognized process subtype: {}"
contextlist.logger.error(msg.format(conf["subtype"]))
raise ResourceInitError("Unrecognized process subtype: {}")
config = None
if "application" in conf:
config = conf["application"]
contextlist.logger.debug("Starting a remote console")
dut = DutConsole(name="D%d" % index, conf=config, params=args)
dut.index = index
else:
binary = conf["application"]['bin']
app_config = conf["application"]
init_cli_cmds = app_config.get("init_cli_cmds", None)
post_cli_cmds = app_config.get("post_cli_cmds", None)
contextlist.logger.debug("Starting process '%s'" % binary)
dut = DutProcess(name="D%d" % index, config=conf, params=args)
dut.index = index
dut.command = binary
if args.valgrind:
dut.use_valgrind(args.valgrind_tool,
not args.valgrind_text,
args.valgrind_console,
args.valgrind_track_origins,
args.valgrind_extra_params)
if args.gdb == index:
dut.use_gdb()
contextlist.logger.info("GDB is activated for node %i" % index)
if args.gdbs == index:
dut.use_gdbs(True, args.gdbs_port)
contextlist.logger.info("GDBserver is activated for node %i" % index)
if args.vgdb == index:
dut.use_vgdb()
contextlist.logger.info("VGDB is activated for node %i" % index)
if args.nobuf:
dut.no_std_buf()
if init_cli_cmds is not None:
dut.set_init_cli_cmds(init_cli_cmds)
if post_cli_cmds is not None:
dut.set_post_cli_cmds(post_cli_cmds)
contextlist.duts.append(dut)
contextlist.dutinformations.append(dut.get_info()) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:allocate; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:dut_configuration_list; 6, default_parameter; 6, 7; 6, 8; 7, identifier:args; 8, None; 9, block; 9, 10; 9, 18; 9, 31; 9, 81; 9, 116; 9, 122; 9, 126; 9, 173; 9, 181; 9, 189; 9, 197; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:dut_config_list; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:dut_configuration_list; 16, identifier:get_dut_configuration; 17, argument_list; 18, if_statement; 18, 19; 18, 25; 19, not_operator; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:isinstance; 22, argument_list; 22, 23; 22, 24; 23, identifier:dut_config_list; 24, identifier:list; 25, block; 25, 26; 26, raise_statement; 26, 27; 27, call; 27, 28; 27, 29; 28, identifier:AllocationError; 29, argument_list; 29, 30; 30, string:"Invalid dut configuration format!"; 31, if_statement; 31, 32; 31, 50; 32, call; 32, 33; 32, 34; 33, identifier:next; 34, argument_list; 34, 35; 34, 49; 35, generator_expression; 35, 36; 35, 37; 35, 40; 36, identifier:item; 37, for_in_clause; 37, 38; 37, 39; 38, identifier:item; 39, identifier:dut_config_list; 40, if_clause; 40, 41; 41, comparison_operator:==; 41, 42; 41, 48; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:item; 45, identifier:get; 46, argument_list; 46, 47; 47, string:"type"; 48, string:"hardware"; 49, False; 50, block; 50, 51; 50, 63; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:_available_devices; 56, call; 56, 57; 56, 62; 57, attribute; 57, 58; 57, 61; 58, call; 58, 59; 58, 60; 59, identifier:DutDetection; 60, argument_list; 61, identifier:get_available_devices; 62, argument_list; 63, if_statement; 63, 64; 63, 75; 64, comparison_operator:<; 64, 65; 64, 71; 65, call; 65, 66; 65, 67; 66, identifier:len; 67, argument_list; 67, 68; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:_available_devices; 71, call; 71, 72; 71, 73; 72, identifier:len; 73, argument_list; 73, 74; 74, identifier:dut_config_list; 75, block; 75, 76; 76, raise_statement; 76, 77; 77, call; 77, 78; 77, 79; 78, identifier:AllocationError; 79, argument_list; 79, 80; 80, string:"Required amount of devices not available."; 81, try_statement; 81, 82; 81, 112; 82, block; 82, 83; 83, for_statement; 83, 84; 83, 85; 83, 86; 84, identifier:dut_config; 85, identifier:dut_config_list; 86, block; 86, 87; 86, 105; 87, if_statement; 87, 88; 87, 99; 88, not_operator; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:can_allocate; 93, argument_list; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:dut_config; 97, identifier:get_requirements; 98, argument_list; 99, block; 99, 100; 100, raise_statement; 100, 101; 101, call; 101, 102; 101, 103; 102, identifier:AllocationError; 103, argument_list; 103, 104; 104, string:"Resource type is not supported"; 105, expression_statement; 105, 106; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:_allocate; 110, argument_list; 110, 111; 111, identifier:dut_config; 112, except_clause; 112, 113; 112, 114; 113, identifier:AllocationError; 114, block; 114, 115; 115, raise_statement; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:alloc_list; 119, call; 119, 120; 119, 121; 120, identifier:AllocationContextList; 121, argument_list; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:res_id; 125, None; 126, for_statement; 126, 127; 126, 128; 126, 129; 127, identifier:conf; 128, identifier:dut_config_list; 129, block; 129, 130; 129, 154; 129, 166; 130, if_statement; 130, 131; 130, 139; 131, comparison_operator:==; 131, 132; 131, 138; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:conf; 135, identifier:get; 136, argument_list; 136, 137; 137, string:"type"; 138, string:"mbed"; 139, block; 139, 140; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:res_id; 143, call; 143, 144; 143, 152; 144, attribute; 144, 145; 144, 151; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:conf; 148, identifier:get; 149, argument_list; 149, 150; 150, string:"allocated"; 151, identifier:get; 152, argument_list; 152, 153; 153, string:"target_id"; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:context; 157, call; 157, 158; 157, 159; 158, identifier:AllocationContext; 159, argument_list; 159, 160; 159, 163; 160, keyword_argument; 160, 161; 160, 162; 161, identifier:resource_id; 162, identifier:res_id; 163, keyword_argument; 163, 164; 163, 165; 164, identifier:alloc_data; 165, identifier:conf; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:alloc_list; 170, identifier:append; 171, argument_list; 171, 172; 172, identifier:context; 173, expression_statement; 173, 174; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:alloc_list; 177, identifier:set_dut_init_function; 178, argument_list; 178, 179; 178, 180; 179, string:"serial"; 180, identifier:init_generic_serial_dut; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:alloc_list; 185, identifier:set_dut_init_function; 186, argument_list; 186, 187; 186, 188; 187, string:"process"; 188, identifier:init_process_dut; 189, expression_statement; 189, 190; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:alloc_list; 193, identifier:set_dut_init_function; 194, argument_list; 194, 195; 194, 196; 195, string:"mbed"; 196, identifier:init_mbed_dut; 197, return_statement; 197, 198; 198, identifier:alloc_list | def allocate(self, dut_configuration_list, args=None):
dut_config_list = dut_configuration_list.get_dut_configuration()
if not isinstance(dut_config_list, list):
raise AllocationError("Invalid dut configuration format!")
if next((item for item in dut_config_list if item.get("type") == "hardware"), False):
self._available_devices = DutDetection().get_available_devices()
if len(self._available_devices) < len(dut_config_list):
raise AllocationError("Required amount of devices not available.")
try:
for dut_config in dut_config_list:
if not self.can_allocate(dut_config.get_requirements()):
raise AllocationError("Resource type is not supported")
self._allocate(dut_config)
except AllocationError:
raise
alloc_list = AllocationContextList()
res_id = None
for conf in dut_config_list:
if conf.get("type") == "mbed":
res_id = conf.get("allocated").get("target_id")
context = AllocationContext(resource_id=res_id, alloc_data=conf)
alloc_list.append(context)
alloc_list.set_dut_init_function("serial", init_generic_serial_dut)
alloc_list.set_dut_init_function("process", init_process_dut)
alloc_list.set_dut_init_function("mbed", init_mbed_dut)
return alloc_list |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_allocate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dut_configuration; 6, block; 6, 7; 6, 22; 6, 271; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:==; 8, 9; 8, 12; 9, subscript; 9, 10; 9, 11; 10, identifier:dut_configuration; 11, string:"type"; 12, string:"hardware"; 13, block; 13, 14; 14, expression_statement; 14, 15; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:dut_configuration; 18, identifier:set; 19, argument_list; 19, 20; 19, 21; 20, string:"type"; 21, string:"mbed"; 22, if_statement; 22, 23; 22, 28; 22, 214; 23, comparison_operator:==; 23, 24; 23, 27; 24, subscript; 24, 25; 24, 26; 25, identifier:dut_configuration; 26, string:"type"; 27, string:"mbed"; 28, block; 28, 29; 28, 40; 28, 48; 28, 59; 28, 70; 28, 83; 28, 98; 28, 209; 29, if_statement; 29, 30; 29, 34; 30, not_operator; 30, 31; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:_available_devices; 34, block; 34, 35; 35, raise_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:AllocationError; 38, argument_list; 38, 39; 39, string:"No available devices to allocate from"; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:dut_reqs; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:dut_configuration; 46, identifier:get_requirements; 47, argument_list; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:platforms; 51, conditional_expression:if; 51, 52; 51, 53; 51, 56; 52, None; 53, comparison_operator:not; 53, 54; 53, 55; 54, string:'allowed_platforms'; 55, identifier:dut_reqs; 56, subscript; 56, 57; 56, 58; 57, identifier:dut_reqs; 58, string:'allowed_platforms'; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:platform_name; 62, conditional_expression:if; 62, 63; 62, 64; 62, 67; 63, None; 64, comparison_operator:not; 64, 65; 64, 66; 65, string:'platform_name'; 66, identifier:dut_reqs; 67, subscript; 67, 68; 67, 69; 68, identifier:dut_reqs; 69, string:"platform_name"; 70, if_statement; 70, 71; 70, 76; 71, boolean_operator:and; 71, 72; 71, 75; 72, comparison_operator:is; 72, 73; 72, 74; 73, identifier:platform_name; 74, None; 75, identifier:platforms; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:platform_name; 80, subscript; 80, 81; 80, 82; 81, identifier:platforms; 82, integer:0; 83, if_statement; 83, 84; 83, 87; 84, boolean_operator:and; 84, 85; 84, 86; 85, identifier:platform_name; 86, identifier:platforms; 87, block; 87, 88; 88, if_statement; 88, 89; 88, 92; 89, comparison_operator:not; 89, 90; 89, 91; 90, identifier:platform_name; 91, identifier:platforms; 92, block; 92, 93; 93, raise_statement; 93, 94; 94, call; 94, 95; 94, 96; 95, identifier:AllocationError; 96, argument_list; 96, 97; 97, string:"Platform name not in allowed platforms."; 98, for_statement; 98, 99; 98, 100; 98, 103; 99, identifier:dev; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:_available_devices; 103, block; 103, 104; 103, 132; 103, 154; 104, if_statement; 104, 105; 104, 112; 105, boolean_operator:and; 105, 106; 105, 107; 106, identifier:platform_name; 107, comparison_operator:!=; 107, 108; 107, 111; 108, subscript; 108, 109; 108, 110; 109, identifier:dev; 110, string:"platform_name"; 111, identifier:platform_name; 112, block; 112, 113; 112, 131; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 120; 115, attribute; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:logger; 119, identifier:debug; 120, argument_list; 120, 121; 120, 124; 120, 127; 120, 128; 121, concatenated_string; 121, 122; 121, 123; 122, string:"Skipping device %s because of mismatching platform. "; 123, string:"Required %s but device was %s"; 124, subscript; 124, 125; 124, 126; 125, identifier:dev; 126, string:'target_id'; 127, identifier:platform_name; 128, subscript; 128, 129; 128, 130; 129, identifier:dev; 130, string:'platform_name'; 131, continue_statement; 132, if_statement; 132, 133; 132, 138; 133, comparison_operator:==; 133, 134; 133, 137; 134, subscript; 134, 135; 134, 136; 135, identifier:dev; 136, string:'state'; 137, string:'allocated'; 138, block; 138, 139; 138, 153; 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:self; 144, identifier:logger; 145, identifier:debug; 146, argument_list; 146, 147; 146, 150; 147, concatenated_string; 147, 148; 147, 149; 148, string:"Skipping device %s because it was "; 149, string:"already allocated"; 150, subscript; 150, 151; 150, 152; 151, identifier:dev; 152, string:'target_id'; 153, continue_statement; 154, if_statement; 154, 155; 154, 163; 154, 190; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:DutDetection; 158, identifier:is_port_usable; 159, argument_list; 159, 160; 160, subscript; 160, 161; 160, 162; 161, identifier:dev; 162, string:'serial_port'; 163, block; 163, 164; 163, 170; 163, 176; 163, 188; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 169; 166, subscript; 166, 167; 166, 168; 167, identifier:dev; 168, string:'state'; 169, string:"allocated"; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 175; 172, subscript; 172, 173; 172, 174; 173, identifier:dut_reqs; 174, string:'allocated'; 175, identifier:dev; 176, expression_statement; 176, 177; 177, call; 177, 178; 177, 183; 178, attribute; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:self; 181, identifier:logger; 182, identifier:info; 183, argument_list; 183, 184; 183, 185; 184, string:"Allocated device %s"; 185, subscript; 185, 186; 185, 187; 186, identifier:dev; 187, string:'target_id'; 188, return_statement; 188, 189; 189, True; 190, else_clause; 190, 191; 191, block; 191, 192; 192, expression_statement; 192, 193; 193, call; 193, 194; 193, 199; 194, attribute; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:self; 197, identifier:logger; 198, identifier:info; 199, argument_list; 199, 200; 199, 203; 199, 206; 200, concatenated_string; 200, 201; 200, 202; 201, string:"Could not open serial port (%s) of "; 202, string:"allocated device %s"; 203, subscript; 203, 204; 203, 205; 204, identifier:dev; 205, string:'serial_port'; 206, subscript; 206, 207; 206, 208; 207, identifier:dev; 208, string:'target_id'; 209, raise_statement; 209, 210; 210, call; 210, 211; 210, 212; 211, identifier:AllocationError; 212, argument_list; 212, 213; 213, string:"No suitable local device available"; 214, elif_clause; 214, 215; 214, 220; 215, comparison_operator:==; 215, 216; 215, 219; 216, subscript; 216, 217; 216, 218; 217, identifier:dut_configuration; 218, string:"type"; 219, string:"serial"; 220, block; 220, 221; 220, 229; 220, 248; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:dut_reqs; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:dut_configuration; 227, identifier:get_requirements; 228, argument_list; 229, if_statement; 229, 230; 229, 237; 230, not_operator; 230, 231; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:dut_reqs; 234, identifier:get; 235, argument_list; 235, 236; 236, string:"serial_port"; 237, block; 237, 238; 238, raise_statement; 238, 239; 239, call; 239, 240; 239, 241; 240, identifier:AllocationError; 241, argument_list; 241, 242; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, string:"Serial port not defined for requirement {}"; 245, identifier:format; 246, argument_list; 246, 247; 247, identifier:dut_reqs; 248, if_statement; 248, 249; 248, 258; 249, not_operator; 249, 250; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:DutDetection; 253, identifier:is_port_usable; 254, argument_list; 254, 255; 255, subscript; 255, 256; 255, 257; 256, identifier:dut_reqs; 257, string:'serial_port'; 258, block; 258, 259; 259, raise_statement; 259, 260; 260, call; 260, 261; 260, 262; 261, identifier:AllocationError; 262, argument_list; 262, 263; 263, call; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, string:"Serial port {} not usable"; 266, identifier:format; 267, argument_list; 267, 268; 268, subscript; 268, 269; 268, 270; 269, identifier:dut_reqs; 270, string:'serial_port'; 271, return_statement; 271, 272; 272, True | def _allocate(self, dut_configuration):
if dut_configuration["type"] == "hardware":
dut_configuration.set("type", "mbed")
if dut_configuration["type"] == "mbed":
if not self._available_devices:
raise AllocationError("No available devices to allocate from")
dut_reqs = dut_configuration.get_requirements()
platforms = None if 'allowed_platforms' not in dut_reqs else dut_reqs[
'allowed_platforms']
platform_name = None if 'platform_name' not in dut_reqs else dut_reqs[
"platform_name"]
if platform_name is None and platforms:
platform_name = platforms[0]
if platform_name and platforms:
if platform_name not in platforms:
raise AllocationError("Platform name not in allowed platforms.")
for dev in self._available_devices:
if platform_name and dev["platform_name"] != platform_name:
self.logger.debug("Skipping device %s because of mismatching platform. "
"Required %s but device was %s", dev['target_id'],
platform_name, dev['platform_name'])
continue
if dev['state'] == 'allocated':
self.logger.debug("Skipping device %s because it was "
"already allocated", dev['target_id'])
continue
if DutDetection.is_port_usable(dev['serial_port']):
dev['state'] = "allocated"
dut_reqs['allocated'] = dev
self.logger.info("Allocated device %s", dev['target_id'])
return True
else:
self.logger.info("Could not open serial port (%s) of "
"allocated device %s", dev['serial_port'], dev['target_id'])
raise AllocationError("No suitable local device available")
elif dut_configuration["type"] == "serial":
dut_reqs = dut_configuration.get_requirements()
if not dut_reqs.get("serial_port"):
raise AllocationError("Serial port not defined for requirement {}".format(dut_reqs))
if not DutDetection.is_port_usable(dut_reqs['serial_port']):
raise AllocationError("Serial port {} not usable".format(dut_reqs['serial_port']))
return True |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__generate; 3, parameters; 3, 4; 4, identifier:results; 5, block; 5, 6; 5, 19; 5, 23; 5, 27; 5, 31; 5, 35; 5, 96; 5, 312; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 12; 8, pattern_list; 8, 9; 8, 10; 8, 11; 9, identifier:doc; 10, identifier:tag; 11, identifier:text; 12, call; 12, 13; 12, 18; 13, attribute; 13, 14; 13, 17; 14, call; 14, 15; 14, 16; 15, identifier:Doc; 16, argument_list; 17, identifier:tagtext; 18, argument_list; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:count; 22, integer:0; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:fails; 26, integer:0; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:errors; 30, integer:0; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:skips; 34, integer:0; 35, for_statement; 35, 36; 35, 37; 35, 38; 36, identifier:result; 37, identifier:results; 38, block; 38, 39; 38, 56; 38, 60; 39, if_statement; 39, 40; 39, 47; 40, comparison_operator:is; 40, 41; 40, 46; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:result; 44, identifier:passed; 45, argument_list; 46, False; 47, block; 47, 48; 48, if_statement; 48, 49; 48, 54; 49, comparison_operator:>; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:result; 52, identifier:retries_left; 53, integer:0; 54, block; 54, 55; 55, continue_statement; 56, expression_statement; 56, 57; 57, augmented_assignment:+=; 57, 58; 57, 59; 58, identifier:count; 59, integer:1; 60, if_statement; 60, 61; 60, 66; 60, 68; 60, 79; 60, 90; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:result; 64, identifier:passed; 65, argument_list; 66, block; 66, 67; 67, continue_statement; 68, elif_clause; 68, 69; 68, 74; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:result; 72, identifier:skipped; 73, argument_list; 74, block; 74, 75; 75, expression_statement; 75, 76; 76, augmented_assignment:+=; 76, 77; 76, 78; 77, identifier:skips; 78, integer:1; 79, elif_clause; 79, 80; 79, 85; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:result; 83, identifier:was_inconclusive; 84, argument_list; 85, block; 85, 86; 86, expression_statement; 86, 87; 87, augmented_assignment:+=; 87, 88; 87, 89; 88, identifier:errors; 89, integer:1; 90, else_clause; 90, 91; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, augmented_assignment:+=; 93, 94; 93, 95; 94, identifier:fails; 95, integer:1; 96, with_statement; 96, 97; 96, 127; 97, with_clause; 97, 98; 98, with_item; 98, 99; 99, call; 99, 100; 99, 101; 100, identifier:tag; 101, argument_list; 101, 102; 101, 103; 101, 109; 101, 115; 101, 121; 102, string:'testsuite'; 103, keyword_argument; 103, 104; 103, 105; 104, identifier:tests; 105, call; 105, 106; 105, 107; 106, identifier:str; 107, argument_list; 107, 108; 108, identifier:count; 109, keyword_argument; 109, 110; 109, 111; 110, identifier:failures; 111, call; 111, 112; 111, 113; 112, identifier:str; 113, argument_list; 113, 114; 114, identifier:fails; 115, keyword_argument; 115, 116; 115, 117; 116, identifier:errors; 117, call; 117, 118; 117, 119; 118, identifier:str; 119, argument_list; 119, 120; 120, identifier:errors; 121, keyword_argument; 121, 122; 121, 123; 122, identifier:skipped; 123, call; 123, 124; 123, 125; 124, identifier:str; 125, argument_list; 125, 126; 126, identifier:skips; 127, block; 127, 128; 128, for_statement; 128, 129; 128, 130; 128, 131; 129, identifier:result; 130, identifier:results; 131, block; 131, 132; 131, 148; 131, 156; 131, 164; 131, 175; 131, 183; 132, if_statement; 132, 133; 132, 146; 133, boolean_operator:and; 133, 134; 133, 141; 134, comparison_operator:is; 134, 135; 134, 140; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:result; 138, identifier:passed; 139, argument_list; 140, False; 141, comparison_operator:>; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:result; 144, identifier:retries_left; 145, integer:0; 146, block; 146, 147; 147, continue_statement; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:class_name; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:result; 154, identifier:get_tc_name; 155, argument_list; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:models; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:result; 162, identifier:get_dut_models; 163, argument_list; 164, if_statement; 164, 165; 164, 166; 165, identifier:models; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:class_name; 170, binary_operator:+; 170, 171; 170, 174; 171, binary_operator:+; 171, 172; 171, 173; 172, identifier:class_name; 173, string:"."; 174, identifier:models; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:name; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:result; 181, identifier:get_toolchain; 182, argument_list; 183, with_statement; 183, 184; 183, 206; 184, with_clause; 184, 185; 185, with_item; 185, 186; 186, call; 186, 187; 186, 188; 187, identifier:tag; 188, argument_list; 188, 189; 188, 190; 188, 193; 188, 196; 189, string:'testcase'; 190, keyword_argument; 190, 191; 190, 192; 191, identifier:classname; 192, identifier:class_name; 193, keyword_argument; 193, 194; 193, 195; 194, identifier:name; 195, identifier:name; 196, keyword_argument; 196, 197; 196, 198; 197, identifier:time; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:result; 201, identifier:get_duration; 202, argument_list; 202, 203; 203, keyword_argument; 203, 204; 203, 205; 204, identifier:seconds; 205, True; 206, block; 206, 207; 206, 227; 207, if_statement; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:result; 210, identifier:stdout; 211, block; 211, 212; 212, with_statement; 212, 213; 212, 219; 213, with_clause; 213, 214; 214, with_item; 214, 215; 215, call; 215, 216; 215, 217; 216, identifier:tag; 217, argument_list; 217, 218; 218, string:'system-out'; 219, block; 219, 220; 220, expression_statement; 220, 221; 221, call; 221, 222; 221, 223; 222, identifier:text; 223, argument_list; 223, 224; 224, attribute; 224, 225; 224, 226; 225, identifier:result; 226, identifier:stdout; 227, if_statement; 227, 228; 227, 233; 227, 235; 227, 257; 227, 287; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:result; 231, identifier:passed; 232, argument_list; 233, block; 233, 234; 234, continue_statement; 235, elif_clause; 235, 236; 235, 241; 236, call; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:result; 239, identifier:skipped; 240, argument_list; 241, block; 241, 242; 242, with_statement; 242, 243; 242, 249; 243, with_clause; 243, 244; 244, with_item; 244, 245; 245, call; 245, 246; 245, 247; 246, identifier:tag; 247, argument_list; 247, 248; 248, string:'skipped'; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 253; 252, identifier:text; 253, argument_list; 253, 254; 254, attribute; 254, 255; 254, 256; 255, identifier:result; 256, identifier:skip_reason; 257, elif_clause; 257, 258; 257, 263; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:result; 261, identifier:was_inconclusive; 262, argument_list; 263, block; 263, 264; 264, with_statement; 264, 265; 264, 279; 265, with_clause; 265, 266; 266, with_item; 266, 267; 267, call; 267, 268; 267, 269; 268, identifier:tag; 269, argument_list; 269, 270; 269, 271; 270, string:'error'; 271, keyword_argument; 271, 272; 271, 273; 272, identifier:message; 273, call; 273, 274; 273, 275; 274, identifier:hex_escape_str; 275, argument_list; 275, 276; 276, attribute; 276, 277; 276, 278; 277, identifier:result; 278, identifier:fail_reason; 279, block; 279, 280; 280, expression_statement; 280, 281; 281, call; 281, 282; 281, 283; 282, identifier:text; 283, argument_list; 283, 284; 284, attribute; 284, 285; 284, 286; 285, identifier:result; 286, identifier:stderr; 287, else_clause; 287, 288; 288, block; 288, 289; 289, with_statement; 289, 290; 289, 304; 290, with_clause; 290, 291; 291, with_item; 291, 292; 292, call; 292, 293; 292, 294; 293, identifier:tag; 294, argument_list; 294, 295; 294, 296; 295, string:'failure'; 296, keyword_argument; 296, 297; 296, 298; 297, identifier:message; 298, call; 298, 299; 298, 300; 299, identifier:hex_escape_str; 300, argument_list; 300, 301; 301, attribute; 301, 302; 301, 303; 302, identifier:result; 303, identifier:fail_reason; 304, block; 304, 305; 305, expression_statement; 305, 306; 306, call; 306, 307; 306, 308; 307, identifier:text; 308, argument_list; 308, 309; 309, attribute; 309, 310; 309, 311; 310, identifier:result; 311, identifier:stderr; 312, return_statement; 312, 313; 313, call; 313, 314; 313, 315; 314, identifier:indent; 315, argument_list; 315, 316; 315, 321; 316, call; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:doc; 319, identifier:getvalue; 320, argument_list; 321, keyword_argument; 321, 322; 321, 323; 322, identifier:indentation; 323, binary_operator:*; 323, 324; 323, 325; 324, string:' '; 325, integer:4 | def __generate(results):
doc, tag, text = Doc().tagtext()
count = 0
fails = 0
errors = 0
skips = 0
for result in results:
if result.passed() is False:
if result.retries_left > 0:
continue
count += 1
if result.passed():
continue
elif result.skipped():
skips += 1
elif result.was_inconclusive():
errors += 1
else:
fails += 1
with tag('testsuite',
tests=str(count),
failures=str(fails),
errors=str(errors),
skipped=str(skips)):
for result in results:
if result.passed() is False and result.retries_left > 0:
continue
class_name = result.get_tc_name()
models = result.get_dut_models()
if models:
class_name = class_name + "." + models
name = result.get_toolchain()
with tag('testcase', classname=class_name, name=name,
time=result.get_duration(seconds=True)):
if result.stdout:
with tag('system-out'):
text(result.stdout)
if result.passed():
continue
elif result.skipped():
with tag('skipped'):
text(result.skip_reason)
elif result.was_inconclusive():
with tag('error', message=hex_escape_str(result.fail_reason)):
text(result.stderr)
else:
with tag('failure', message=hex_escape_str(result.fail_reason)):
text(result.stderr)
return indent(
doc.getvalue(),
indentation=' '*4
) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:init_base_logging; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, default_parameter; 4, 5; 4, 6; 5, identifier:directory; 6, string:"./log"; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, integer:0; 10, default_parameter; 10, 11; 10, 12; 11, identifier:silent; 12, False; 13, default_parameter; 13, 14; 13, 15; 14, identifier:color; 15, False; 16, default_parameter; 16, 17; 16, 18; 17, identifier:no_file; 18, False; 19, default_parameter; 19, 20; 19, 21; 20, identifier:truncate; 21, True; 22, default_parameter; 22, 23; 22, 24; 23, identifier:config_location; 24, None; 25, block; 25, 26; 25, 28; 25, 30; 25, 32; 25, 34; 25, 36; 25, 38; 25, 87; 25, 115; 25, 124; 25, 130; 25, 139; 25, 147; 25, 175; 25, 312; 25, 316; 25, 320; 25, 376; 25, 426; 25, 433; 25, 437; 25, 449; 26, global_statement; 26, 27; 27, identifier:LOGPATHDIR; 28, global_statement; 28, 29; 29, identifier:STANDALONE_LOGGING; 30, global_statement; 30, 31; 31, identifier:TRUNCATE_LOG; 32, global_statement; 32, 33; 33, identifier:COLOR_ON; 34, global_statement; 34, 35; 35, identifier:SILENT_ON; 36, global_statement; 36, 37; 37, identifier:VERBOSE_LEVEL; 38, if_statement; 38, 39; 38, 40; 39, identifier:config_location; 40, block; 40, 41; 41, try_statement; 41, 42; 41, 48; 41, 65; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, call; 44, 45; 44, 46; 45, identifier:_read_config; 46, argument_list; 46, 47; 47, identifier:config_location; 48, except_clause; 48, 49; 48, 53; 49, as_pattern; 49, 50; 49, 51; 50, identifier:IOError; 51, as_pattern_target; 51, 52; 52, identifier:error; 53, block; 53, 54; 54, raise_statement; 54, 55; 55, call; 55, 56; 55, 57; 56, identifier:IOError; 57, argument_list; 57, 58; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, string:"Unable to read from configuration file {}: {}"; 61, identifier:format; 62, argument_list; 62, 63; 62, 64; 63, identifier:config_location; 64, identifier:error; 65, except_clause; 65, 66; 65, 72; 66, as_pattern; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:jsonschema; 69, identifier:SchemaError; 70, as_pattern_target; 70, 71; 71, identifier:error; 72, block; 72, 73; 73, raise_statement; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:jsonschema; 77, identifier:SchemaError; 78, argument_list; 78, 79; 79, call; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, concatenated_string; 81, 82; 81, 83; 82, string:"Logging configuration schema "; 83, string:"file malformed: {}"; 84, identifier:format; 85, argument_list; 85, 86; 86, identifier:error; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:LOGPATHDIR; 90, call; 90, 91; 90, 96; 91, attribute; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:os; 94, identifier:path; 95, identifier:join; 96, argument_list; 96, 97; 96, 98; 97, identifier:directory; 98, call; 98, 99; 98, 113; 99, attribute; 99, 100; 99, 112; 100, call; 100, 101; 100, 110; 101, attribute; 101, 102; 101, 109; 102, call; 102, 103; 102, 108; 103, attribute; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:datetime; 106, identifier:datetime; 107, identifier:now; 108, argument_list; 109, identifier:strftime; 110, argument_list; 110, 111; 111, string:"%Y-%m-%d_%H%M%S.%f"; 112, identifier:rstrip; 113, argument_list; 113, 114; 114, string:"0"; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:icetealogger; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:logging; 121, identifier:getLogger; 122, argument_list; 122, 123; 123, string:"icetea"; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:icetealogger; 128, identifier:propagate; 129, False; 130, expression_statement; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:icetealogger; 134, identifier:setLevel; 135, argument_list; 135, 136; 136, attribute; 136, 137; 136, 138; 137, identifier:logging; 138, identifier:DEBUG; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:stream_handler; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:logging; 145, identifier:StreamHandler; 146, argument_list; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:formatter; 150, call; 150, 151; 150, 152; 151, identifier:BenchFormatter; 152, argument_list; 152, 153; 152, 164; 153, call; 153, 154; 153, 162; 154, attribute; 154, 155; 154, 161; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:LOGGING_CONFIG; 158, identifier:get; 159, argument_list; 159, 160; 160, string:"IceteaManager"; 161, identifier:get; 162, argument_list; 162, 163; 163, string:"format"; 164, call; 164, 165; 164, 173; 165, attribute; 165, 166; 165, 172; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:LOGGING_CONFIG; 169, identifier:get; 170, argument_list; 170, 171; 171, string:"IceteaManager"; 172, identifier:get; 173, argument_list; 173, 174; 174, string:"dateformat"; 175, if_statement; 175, 176; 175, 178; 175, 186; 175, 199; 176, not_operator; 176, 177; 177, identifier:color; 178, block; 178, 179; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:stream_handler; 183, identifier:setFormatter; 184, argument_list; 184, 185; 185, identifier:formatter; 186, elif_clause; 186, 187; 186, 191; 187, boolean_operator:and; 187, 188; 187, 189; 188, identifier:color; 189, not_operator; 189, 190; 190, identifier:COLORS; 191, block; 191, 192; 192, raise_statement; 192, 193; 193, call; 193, 194; 193, 195; 194, identifier:ImportError; 195, argument_list; 195, 196; 196, concatenated_string; 196, 197; 196, 198; 197, string:"Missing coloredlogs module. Please install with "; 198, string:"pip to use colors in logging."; 199, else_clause; 199, 200; 200, block; 200, 201; 200, 275; 200, 279; 201, class_definition; 201, 202; 201, 203; 201, 207; 202, identifier:ColoredBenchFormatter; 203, argument_list; 203, 204; 204, attribute; 204, 205; 204, 206; 205, identifier:coloredlogs; 206, identifier:ColoredFormatter; 207, block; 207, 208; 207, 216; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 211; 210, identifier:converter; 211, attribute; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:datetime; 214, identifier:datetime; 215, identifier:fromtimestamp; 216, function_definition; 216, 217; 216, 218; 216, 224; 217, function_name:formatTime; 218, parameters; 218, 219; 218, 220; 218, 221; 219, identifier:self; 220, identifier:record; 221, default_parameter; 221, 222; 221, 223; 222, identifier:datefmt; 223, None; 224, block; 224, 225; 224, 241; 224, 264; 224, 273; 225, expression_statement; 225, 226; 226, assignment; 226, 227; 226, 228; 227, identifier:date_and_time; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:self; 231, identifier:converter; 232, argument_list; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:record; 235, identifier:created; 236, keyword_argument; 236, 237; 236, 238; 237, identifier:tz; 238, attribute; 238, 239; 238, 240; 239, identifier:pytz; 240, identifier:utc; 241, if_statement; 241, 242; 241, 245; 242, comparison_operator:in; 242, 243; 242, 244; 243, string:"%F"; 244, identifier:datefmt; 245, block; 245, 246; 245, 254; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 249; 248, identifier:msec; 249, binary_operator:%; 249, 250; 249, 251; 250, string:"%03d"; 251, attribute; 251, 252; 251, 253; 252, identifier:record; 253, identifier:msecs; 254, expression_statement; 254, 255; 255, assignment; 255, 256; 255, 257; 256, identifier:datefmt; 257, call; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:datefmt; 260, identifier:replace; 261, argument_list; 261, 262; 261, 263; 262, string:"%F"; 263, identifier:msec; 264, expression_statement; 264, 265; 265, assignment; 265, 266; 265, 267; 266, identifier:str_time; 267, call; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:date_and_time; 270, identifier:strftime; 271, argument_list; 271, 272; 272, identifier:datefmt; 273, return_statement; 273, 274; 274, identifier:str_time; 275, expression_statement; 275, 276; 276, assignment; 276, 277; 276, 278; 277, identifier:COLOR_ON; 278, identifier:color; 279, expression_statement; 279, 280; 280, call; 280, 281; 280, 284; 281, attribute; 281, 282; 281, 283; 282, identifier:stream_handler; 283, identifier:setFormatter; 284, argument_list; 284, 285; 285, call; 285, 286; 285, 287; 286, identifier:ColoredBenchFormatter; 287, argument_list; 287, 288; 287, 299; 287, 310; 287, 311; 288, call; 288, 289; 288, 297; 289, attribute; 289, 290; 289, 296; 290, call; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:LOGGING_CONFIG; 293, identifier:get; 294, argument_list; 294, 295; 295, string:"IceteaManager"; 296, identifier:get; 297, argument_list; 297, 298; 298, string:"format"; 299, call; 299, 300; 299, 308; 300, attribute; 300, 301; 300, 307; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:LOGGING_CONFIG; 304, identifier:get; 305, argument_list; 305, 306; 306, string:"IceteaManager"; 307, identifier:get; 308, argument_list; 308, 309; 309, string:"dateformat"; 310, identifier:LEVEL_FORMATS; 311, identifier:FIELD_STYLES; 312, expression_statement; 312, 313; 313, assignment; 313, 314; 313, 315; 314, identifier:SILENT_ON; 315, identifier:silent; 316, expression_statement; 316, 317; 317, assignment; 317, 318; 317, 319; 318, identifier:VERBOSE_LEVEL; 319, identifier:verbose; 320, if_statement; 320, 321; 320, 323; 321, not_operator; 321, 322; 322, identifier:no_file; 323, block; 323, 324; 323, 343; 323, 363; 324, try_statement; 324, 325; 324, 333; 325, block; 325, 326; 326, expression_statement; 326, 327; 327, call; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:os; 330, identifier:makedirs; 331, argument_list; 331, 332; 332, identifier:LOGPATHDIR; 333, except_clause; 333, 334; 333, 335; 334, identifier:OSError; 335, block; 335, 336; 336, raise_statement; 336, 337; 337, call; 337, 338; 337, 339; 338, identifier:OSError; 339, argument_list; 339, 340; 340, binary_operator:%; 340, 341; 340, 342; 341, string:"Log path %s already exists."; 342, identifier:LOGPATHDIR; 343, expression_statement; 343, 344; 344, assignment; 344, 345; 344, 346; 345, identifier:filename; 346, call; 346, 347; 346, 360; 347, attribute; 347, 348; 347, 359; 348, call; 348, 349; 348, 357; 349, attribute; 349, 350; 349, 356; 350, call; 350, 351; 350, 354; 351, attribute; 351, 352; 351, 353; 352, identifier:LOGGING_CONFIG; 353, identifier:get; 354, argument_list; 354, 355; 355, string:"IceteaManager"; 356, identifier:get; 357, argument_list; 357, 358; 358, string:"file"; 359, identifier:get; 360, argument_list; 360, 361; 360, 362; 361, string:"name"; 362, string:"icetea.log"; 363, expression_statement; 363, 364; 364, assignment; 364, 365; 364, 366; 365, identifier:icetealogger; 366, call; 366, 367; 366, 368; 367, identifier:_add_filehandler; 368, argument_list; 368, 369; 368, 370; 368, 374; 368, 375; 369, identifier:icetealogger; 370, call; 370, 371; 370, 372; 371, identifier:get_base_logfilename; 372, argument_list; 372, 373; 373, identifier:filename; 374, identifier:formatter; 375, string:"IceteaManager"; 376, if_statement; 376, 377; 376, 381; 376, 391; 376, 403; 377, boolean_operator:and; 377, 378; 377, 379; 378, identifier:verbose; 379, not_operator; 379, 380; 380, identifier:silent; 381, block; 381, 382; 382, expression_statement; 382, 383; 383, call; 383, 384; 383, 387; 384, attribute; 384, 385; 384, 386; 385, identifier:stream_handler; 386, identifier:setLevel; 387, argument_list; 387, 388; 388, attribute; 388, 389; 388, 390; 389, identifier:logging; 390, identifier:DEBUG; 391, elif_clause; 391, 392; 391, 393; 392, identifier:silent; 393, block; 393, 394; 394, expression_statement; 394, 395; 395, call; 395, 396; 395, 399; 396, attribute; 396, 397; 396, 398; 397, identifier:stream_handler; 398, identifier:setLevel; 399, argument_list; 399, 400; 400, attribute; 400, 401; 400, 402; 401, identifier:logging; 402, identifier:WARN; 403, else_clause; 403, 404; 404, block; 404, 405; 405, expression_statement; 405, 406; 406, call; 406, 407; 406, 410; 407, attribute; 407, 408; 407, 409; 408, identifier:stream_handler; 409, identifier:setLevel; 410, argument_list; 410, 411; 411, call; 411, 412; 411, 413; 412, identifier:getattr; 413, argument_list; 413, 414; 413, 415; 414, identifier:logging; 415, call; 415, 416; 415, 424; 416, attribute; 416, 417; 416, 423; 417, call; 417, 418; 417, 421; 418, attribute; 418, 419; 418, 420; 419, identifier:LOGGING_CONFIG; 420, identifier:get; 421, argument_list; 421, 422; 422, string:"IceteaManager"; 423, identifier:get; 424, argument_list; 424, 425; 425, string:"level"; 426, expression_statement; 426, 427; 427, call; 427, 428; 427, 431; 428, attribute; 428, 429; 428, 430; 429, identifier:icetealogger; 430, identifier:addHandler; 431, argument_list; 431, 432; 432, identifier:stream_handler; 433, expression_statement; 433, 434; 434, assignment; 434, 435; 434, 436; 435, identifier:TRUNCATE_LOG; 436, identifier:truncate; 437, if_statement; 437, 438; 437, 439; 438, identifier:TRUNCATE_LOG; 439, block; 439, 440; 440, expression_statement; 440, 441; 441, call; 441, 442; 441, 445; 442, attribute; 442, 443; 442, 444; 443, identifier:icetealogger; 444, identifier:addFilter; 445, argument_list; 445, 446; 446, call; 446, 447; 446, 448; 447, identifier:ContextFilter; 448, argument_list; 449, expression_statement; 449, 450; 450, assignment; 450, 451; 450, 452; 451, identifier:STANDALONE_LOGGING; 452, False | def init_base_logging(directory="./log", verbose=0, silent=False, color=False, no_file=False,
truncate=True, config_location=None):
global LOGPATHDIR
global STANDALONE_LOGGING
global TRUNCATE_LOG
global COLOR_ON
global SILENT_ON
global VERBOSE_LEVEL
if config_location:
try:
_read_config(config_location)
except IOError as error:
raise IOError("Unable to read from configuration file {}: {}".format(config_location,
error))
except jsonschema.SchemaError as error:
raise jsonschema.SchemaError("Logging configuration schema "
"file malformed: {}".format(error))
LOGPATHDIR = os.path.join(directory, datetime.datetime.now().strftime(
"%Y-%m-%d_%H%M%S.%f").rstrip("0"))
icetealogger = logging.getLogger("icetea")
icetealogger.propagate = False
icetealogger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
formatter = BenchFormatter(LOGGING_CONFIG.get("IceteaManager").get("format"),
LOGGING_CONFIG.get("IceteaManager").get("dateformat"))
if not color:
stream_handler.setFormatter(formatter)
elif color and not COLORS:
raise ImportError("Missing coloredlogs module. Please install with "
"pip to use colors in logging.")
else:
class ColoredBenchFormatter(coloredlogs.ColoredFormatter):
converter = datetime.datetime.fromtimestamp
def formatTime(self, record, datefmt=None):
date_and_time = self.converter(record.created, tz=pytz.utc)
if "%F" in datefmt:
msec = "%03d" % record.msecs
datefmt = datefmt.replace("%F", msec)
str_time = date_and_time.strftime(datefmt)
return str_time
COLOR_ON = color
stream_handler.setFormatter(ColoredBenchFormatter(
LOGGING_CONFIG.get("IceteaManager").get("format"),
LOGGING_CONFIG.get("IceteaManager").get("dateformat"),
LEVEL_FORMATS, FIELD_STYLES))
SILENT_ON = silent
VERBOSE_LEVEL = verbose
if not no_file:
try:
os.makedirs(LOGPATHDIR)
except OSError:
raise OSError("Log path %s already exists." % LOGPATHDIR)
filename = LOGGING_CONFIG.get("IceteaManager").get("file").get("name", "icetea.log")
icetealogger = _add_filehandler(icetealogger, get_base_logfilename(filename),
formatter, "IceteaManager")
if verbose and not silent:
stream_handler.setLevel(logging.DEBUG)
elif silent:
stream_handler.setLevel(logging.WARN)
else:
stream_handler.setLevel(getattr(logging, LOGGING_CONFIG.get("IceteaManager").get("level")))
icetealogger.addHandler(stream_handler)
TRUNCATE_LOG = truncate
if TRUNCATE_LOG:
icetealogger.addFilter(ContextFilter())
STANDALONE_LOGGING = False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:assertJsonContains; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:jsonStr; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:key; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:message; 12, None; 13, block; 13, 14; 14, if_statement; 14, 15; 14, 18; 14, 87; 15, comparison_operator:is; 15, 16; 15, 17; 16, identifier:jsonStr; 17, None; 18, block; 18, 19; 19, try_statement; 19, 20; 19, 61; 20, block; 20, 21; 20, 30; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:data; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:json; 27, identifier:loads; 28, argument_list; 28, 29; 29, identifier:jsonStr; 30, if_statement; 30, 31; 30, 34; 31, comparison_operator:not; 31, 32; 31, 33; 32, identifier:key; 33, identifier:data; 34, block; 34, 35; 35, raise_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:TestStepFail; 38, argument_list; 38, 39; 39, conditional_expression:if; 39, 40; 39, 44; 39, 47; 40, call; 40, 41; 40, 42; 41, identifier:format_message; 42, argument_list; 42, 43; 43, identifier:message; 44, comparison_operator:is; 44, 45; 44, 46; 45, identifier:message; 46, None; 47, binary_operator:%; 47, 48; 47, 52; 48, concatenated_string; 48, 49; 48, 50; 48, 51; 49, string:"Assert: "; 50, string:"Key : %s is not "; 51, string:"in : %s"; 52, tuple; 52, 53; 52, 57; 53, call; 53, 54; 53, 55; 54, identifier:str; 55, argument_list; 55, 56; 56, identifier:key; 57, call; 57, 58; 57, 59; 58, identifier:str; 59, argument_list; 59, 60; 60, identifier:jsonStr; 61, except_clause; 61, 62; 61, 68; 62, as_pattern; 62, 63; 62, 66; 63, tuple; 63, 64; 63, 65; 64, identifier:TypeError; 65, identifier:ValueError; 66, as_pattern_target; 66, 67; 67, identifier:e; 68, block; 68, 69; 69, raise_statement; 69, 70; 70, call; 70, 71; 70, 72; 71, identifier:TestStepFail; 72, argument_list; 72, 73; 73, conditional_expression:if; 73, 74; 73, 78; 73, 81; 74, call; 74, 75; 74, 76; 75, identifier:format_message; 76, argument_list; 76, 77; 77, identifier:message; 78, comparison_operator:is; 78, 79; 78, 80; 79, identifier:message; 80, None; 81, binary_operator:+; 81, 82; 81, 83; 82, string:"Unable to parse json "; 83, call; 83, 84; 83, 85; 84, identifier:str; 85, argument_list; 85, 86; 86, identifier:e; 87, else_clause; 87, 88; 88, block; 88, 89; 89, raise_statement; 89, 90; 90, call; 90, 91; 90, 92; 91, identifier:TestStepFail; 92, argument_list; 92, 93; 93, conditional_expression:if; 93, 94; 93, 98; 93, 101; 94, call; 94, 95; 94, 96; 95, identifier:format_message; 96, argument_list; 96, 97; 97, identifier:message; 98, comparison_operator:is; 98, 99; 98, 100; 99, identifier:message; 100, None; 101, string:"Json string is empty" | def assertJsonContains(jsonStr=None, key=None, message=None):
if jsonStr is not None:
try:
data = json.loads(jsonStr)
if key not in data:
raise TestStepFail(
format_message(message) if message is not None else "Assert: "
"Key : %s is not "
"in : %s" % (str(key),
str(jsonStr)))
except (TypeError, ValueError) as e:
raise TestStepFail(
format_message(message) if message is not None else "Unable to parse json "+str(e))
else:
raise TestStepFail(
format_message(message) if message is not None else "Json string is empty") |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_read_fd; 3, parameters; 3, 4; 4, identifier:file_descr; 5, block; 5, 6; 5, 58; 5, 172; 6, try_statement; 6, 7; 6, 20; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:line; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:os; 14, identifier:read; 15, argument_list; 15, 16; 15, 17; 16, identifier:file_descr; 17, binary_operator:*; 17, 18; 17, 19; 18, integer:1024; 19, integer:1024; 20, except_clause; 20, 21; 20, 22; 21, identifier:OSError; 22, block; 22, 23; 22, 32; 22, 56; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:stream_desc; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:NonBlockingStreamReader; 29, identifier:_get_sd; 30, argument_list; 30, 31; 31, identifier:file_descr; 32, if_statement; 32, 33; 32, 36; 33, comparison_operator:is; 33, 34; 33, 35; 34, identifier:stream_desc; 35, None; 36, block; 36, 37; 36, 43; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:stream_desc; 41, identifier:has_error; 42, True; 43, if_statement; 43, 44; 43, 49; 44, comparison_operator:is; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:stream_desc; 47, identifier:callback; 48, None; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:stream_desc; 54, identifier:callback; 55, argument_list; 56, return_statement; 56, 57; 57, integer:0; 58, if_statement; 58, 59; 58, 60; 59, identifier:line; 60, block; 60, 61; 60, 70; 60, 77; 60, 101; 60, 107; 60, 120; 60, 158; 60, 167; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:stream_desc; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:NonBlockingStreamReader; 67, identifier:_get_sd; 68, argument_list; 68, 69; 69, identifier:file_descr; 70, if_statement; 70, 71; 70, 74; 71, comparison_operator:is; 71, 72; 71, 73; 72, identifier:stream_desc; 73, None; 74, block; 74, 75; 75, return_statement; 75, 76; 76, integer:0; 77, if_statement; 77, 78; 77, 79; 78, identifier:IS_PYTHON3; 79, block; 79, 80; 80, try_statement; 80, 81; 80, 91; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:line; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:line; 88, identifier:decode; 89, argument_list; 89, 90; 90, string:"ascii"; 91, except_clause; 91, 92; 91, 93; 92, identifier:UnicodeDecodeError; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:line; 97, call; 97, 98; 97, 99; 98, identifier:repr; 99, argument_list; 99, 100; 100, identifier:line; 101, expression_statement; 101, 102; 102, augmented_assignment:+=; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:stream_desc; 105, identifier:buf; 106, identifier:line; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:split; 110, call; 110, 111; 110, 116; 111, attribute; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:stream_desc; 114, identifier:buf; 115, identifier:split; 116, argument_list; 116, 117; 117, attribute; 117, 118; 117, 119; 118, identifier:os; 119, identifier:linesep; 120, for_statement; 120, 121; 120, 122; 120, 128; 121, identifier:line; 122, subscript; 122, 123; 122, 124; 123, identifier:split; 124, slice; 124, 125; 124, 126; 125, colon; 126, unary_operator:-; 126, 127; 127, integer:1; 128, block; 128, 129; 128, 145; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 136; 131, attribute; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:stream_desc; 134, identifier:read_queue; 135, identifier:appendleft; 136, argument_list; 136, 137; 137, call; 137, 138; 137, 139; 138, identifier:strip_escape; 139, argument_list; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:line; 143, identifier:strip; 144, argument_list; 145, if_statement; 145, 146; 145, 151; 146, comparison_operator:is; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:stream_desc; 149, identifier:callback; 150, None; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:stream_desc; 156, identifier:callback; 157, argument_list; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:stream_desc; 162, identifier:buf; 163, subscript; 163, 164; 163, 165; 164, identifier:split; 165, unary_operator:-; 165, 166; 166, integer:1; 167, return_statement; 167, 168; 168, call; 168, 169; 168, 170; 169, identifier:len; 170, argument_list; 170, 171; 171, identifier:line; 172, return_statement; 172, 173; 173, integer:0 | def _read_fd(file_descr):
try:
line = os.read(file_descr, 1024 * 1024)
except OSError:
stream_desc = NonBlockingStreamReader._get_sd(file_descr)
if stream_desc is not None:
stream_desc.has_error = True
if stream_desc.callback is not None:
stream_desc.callback()
return 0
if line:
stream_desc = NonBlockingStreamReader._get_sd(file_descr)
if stream_desc is None:
return 0
if IS_PYTHON3:
try:
line = line.decode("ascii")
except UnicodeDecodeError:
line = repr(line)
stream_desc.buf += line
split = stream_desc.buf.split(os.linesep)
for line in split[:-1]:
stream_desc.read_queue.appendleft(strip_escape(line.strip()))
if stream_desc.callback is not None:
stream_desc.callback()
stream_desc.buf = split[-1]
return len(line)
return 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:args; 7, None; 8, block; 8, 9; 8, 15; 8, 26; 8, 36; 8, 60; 8, 66; 8, 99; 8, 116; 8, 129; 8, 179; 8, 228; 8, 263; 8, 274; 8, 326; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:retcodesummary; 12, attribute; 12, 13; 12, 14; 13, identifier:ExitCodes; 14, identifier:EXIT_SUCCESS; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:args; 20, conditional_expression:if; 20, 21; 20, 22; 20, 23; 21, identifier:args; 22, identifier:args; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:args; 26, if_statement; 26, 27; 26, 33; 27, not_operator; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:check_args; 32, argument_list; 33, block; 33, 34; 34, return_statement; 34, 35; 35, identifier:retcodesummary; 36, if_statement; 36, 37; 36, 42; 37, attribute; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:args; 41, identifier:clean; 42, block; 42, 43; 43, if_statement; 43, 44; 43, 57; 44, boolean_operator:and; 44, 45; 44, 51; 45, not_operator; 45, 46; 46, attribute; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:args; 50, identifier:tc; 51, not_operator; 51, 52; 52, attribute; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:args; 56, identifier:suite; 57, block; 57, 58; 58, return_statement; 58, 59; 59, identifier:retcodesummary; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:version; 63, call; 63, 64; 63, 65; 64, identifier:get_fw_version; 65, argument_list; 66, if_statement; 66, 67; 66, 74; 66, 82; 67, boolean_operator:and; 67, 68; 67, 73; 68, attribute; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:args; 72, identifier:version; 73, identifier:version; 74, block; 74, 75; 74, 80; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 78; 77, identifier:print; 78, argument_list; 78, 79; 79, identifier:version; 80, return_statement; 80, 81; 81, identifier:retcodesummary; 82, elif_clause; 82, 83; 82, 91; 83, boolean_operator:and; 83, 84; 83, 89; 84, attribute; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:args; 88, identifier:version; 89, not_operator; 89, 90; 90, identifier:version; 91, block; 91, 92; 91, 97; 92, expression_statement; 92, 93; 93, call; 93, 94; 93, 95; 94, identifier:print; 95, argument_list; 95, 96; 96, string:"Unable to get version. Have you installed Icetea correctly?"; 97, return_statement; 97, 98; 98, identifier:retcodesummary; 99, expression_statement; 99, 100; 100, call; 100, 101; 100, 106; 101, attribute; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:logger; 105, identifier:info; 106, argument_list; 106, 107; 107, conditional_expression:if; 107, 108; 107, 114; 107, 115; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, string:"Using Icetea version {}"; 111, identifier:format; 112, argument_list; 112, 113; 113, identifier:version; 114, identifier:version; 115, string:"Unable to get Icetea version. Is Icetea installed?"; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:cloud; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:_init_cloud; 123, argument_list; 123, 124; 124, attribute; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:self; 127, identifier:args; 128, identifier:cloud; 129, if_statement; 129, 130; 129, 135; 130, attribute; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:self; 133, identifier:args; 134, identifier:listsuites; 135, block; 135, 136; 135, 150; 135, 177; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:table; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:list_suites; 143, argument_list; 143, 144; 143, 149; 144, attribute; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:args; 148, identifier:suitedir; 149, identifier:cloud; 150, if_statement; 150, 151; 150, 154; 150, 170; 151, comparison_operator:is; 151, 152; 151, 153; 152, identifier:table; 153, None; 154, block; 154, 155; 154, 164; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 162; 157, attribute; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:logger; 161, identifier:error; 162, argument_list; 162, 163; 163, string:"No suites found!"; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:retcodesummary; 167, attribute; 167, 168; 167, 169; 168, identifier:ExitCodes; 169, identifier:EXIT_FAIL; 170, else_clause; 170, 171; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 175; 174, identifier:print; 175, argument_list; 175, 176; 176, identifier:table; 177, return_statement; 177, 178; 178, identifier:retcodesummary; 179, try_statement; 179, 180; 179, 200; 180, block; 180, 181; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 184; 183, identifier:testsuite; 184, call; 184, 185; 184, 186; 185, identifier:TestSuite; 186, argument_list; 186, 187; 186, 192; 186, 195; 187, keyword_argument; 187, 188; 187, 189; 188, identifier:logger; 189, attribute; 189, 190; 189, 191; 190, identifier:self; 191, identifier:logger; 192, keyword_argument; 192, 193; 192, 194; 193, identifier:cloud_module; 194, identifier:cloud; 195, keyword_argument; 195, 196; 195, 197; 196, identifier:args; 197, attribute; 197, 198; 197, 199; 198, identifier:self; 199, identifier:args; 200, except_clause; 200, 201; 200, 205; 201, as_pattern; 201, 202; 201, 203; 202, identifier:SuiteException; 203, as_pattern_target; 203, 204; 204, identifier:error; 205, block; 205, 206; 205, 220; 205, 226; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 213; 208, attribute; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:self; 211, identifier:logger; 212, identifier:error; 213, argument_list; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, string:"Something went wrong in suite creation! {}"; 217, identifier:format; 218, argument_list; 218, 219; 219, identifier:error; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 223; 222, identifier:retcodesummary; 223, attribute; 223, 224; 223, 225; 224, identifier:ExitCodes; 225, identifier:EXIT_INCONC; 226, return_statement; 226, 227; 227, identifier:retcodesummary; 228, if_statement; 228, 229; 228, 234; 229, attribute; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:self; 232, identifier:args; 233, identifier:list; 234, block; 234, 235; 234, 248; 234, 256; 234, 261; 235, if_statement; 235, 236; 235, 241; 236, attribute; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:self; 239, identifier:args; 240, identifier:cloud; 241, block; 241, 242; 242, expression_statement; 242, 243; 243, call; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:testsuite; 246, identifier:update_testcases; 247, argument_list; 248, expression_statement; 248, 249; 249, assignment; 249, 250; 249, 251; 250, identifier:testcases; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:testsuite; 254, identifier:list_testcases; 255, argument_list; 256, expression_statement; 256, 257; 257, call; 257, 258; 257, 259; 258, identifier:print; 259, argument_list; 259, 260; 260, identifier:testcases; 261, return_statement; 261, 262; 262, identifier:retcodesummary; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:results; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:self; 269, identifier:runtestsuite; 270, argument_list; 270, 271; 271, keyword_argument; 271, 272; 271, 273; 272, identifier:testsuite; 273, identifier:testsuite; 274, if_statement; 274, 275; 274, 277; 274, 284; 274, 305; 275, not_operator; 275, 276; 276, identifier:results; 277, block; 277, 278; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:retcodesummary; 281, attribute; 281, 282; 281, 283; 282, identifier:ExitCodes; 283, identifier:EXIT_SUCCESS; 284, elif_clause; 284, 285; 284, 298; 285, boolean_operator:and; 285, 286; 285, 291; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:results; 289, identifier:failure_count; 290, argument_list; 291, comparison_operator:is; 291, 292; 291, 297; 292, attribute; 292, 293; 292, 296; 293, attribute; 293, 294; 293, 295; 294, identifier:self; 295, identifier:args; 296, identifier:failure_return_value; 297, True; 298, block; 298, 299; 299, expression_statement; 299, 300; 300, assignment; 300, 301; 300, 302; 301, identifier:retcodesummary; 302, attribute; 302, 303; 302, 304; 303, identifier:ExitCodes; 304, identifier:EXIT_FAIL; 305, elif_clause; 305, 306; 305, 319; 306, boolean_operator:and; 306, 307; 306, 312; 307, call; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:results; 310, identifier:inconclusive_count; 311, argument_list; 312, comparison_operator:is; 312, 313; 312, 318; 313, attribute; 313, 314; 313, 317; 314, attribute; 314, 315; 314, 316; 315, identifier:self; 316, identifier:args; 317, identifier:failure_return_value; 318, True; 319, block; 319, 320; 320, expression_statement; 320, 321; 321, assignment; 321, 322; 321, 323; 322, identifier:retcodesummary; 323, attribute; 323, 324; 323, 325; 324, identifier:ExitCodes; 325, identifier:EXIT_INCONC; 326, return_statement; 326, 327; 327, identifier:retcodesummary | def run(self, args=None):
retcodesummary = ExitCodes.EXIT_SUCCESS
self.args = args if args else self.args
if not self.check_args():
return retcodesummary
if self.args.clean:
if not self.args.tc and not self.args.suite:
return retcodesummary
version = get_fw_version()
if self.args.version and version:
print(version)
return retcodesummary
elif self.args.version and not version:
print("Unable to get version. Have you installed Icetea correctly?")
return retcodesummary
self.logger.info("Using Icetea version {}".format(version) if version
else "Unable to get Icetea version. Is Icetea installed?")
cloud = self._init_cloud(self.args.cloud)
if self.args.listsuites:
table = self.list_suites(self.args.suitedir, cloud)
if table is None:
self.logger.error("No suites found!")
retcodesummary = ExitCodes.EXIT_FAIL
else:
print(table)
return retcodesummary
try:
testsuite = TestSuite(logger=self.logger, cloud_module=cloud, args=self.args)
except SuiteException as error:
self.logger.error("Something went wrong in suite creation! {}".format(error))
retcodesummary = ExitCodes.EXIT_INCONC
return retcodesummary
if self.args.list:
if self.args.cloud:
testsuite.update_testcases()
testcases = testsuite.list_testcases()
print(testcases)
return retcodesummary
results = self.runtestsuite(testsuite=testsuite)
if not results:
retcodesummary = ExitCodes.EXIT_SUCCESS
elif results.failure_count() and self.args.failure_return_value is True:
retcodesummary = ExitCodes.EXIT_FAIL
elif results.inconclusive_count() and self.args.failure_return_value is True:
retcodesummary = ExitCodes.EXIT_INCONC
return retcodesummary |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:generate_object_graphs_by_class; 3, parameters; 3, 4; 4, identifier:classlist; 5, block; 5, 6; 5, 18; 5, 22; 5, 35; 6, try_statement; 6, 7; 6, 14; 7, block; 7, 8; 7, 11; 8, import_statement; 8, 9; 9, dotted_name; 9, 10; 10, identifier:objgraph; 11, import_statement; 11, 12; 12, dotted_name; 12, 13; 13, identifier:gc; 14, except_clause; 14, 15; 14, 16; 15, identifier:ImportError; 16, block; 16, 17; 17, return_statement; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:graphcount; 21, integer:0; 22, if_statement; 22, 23; 22, 29; 23, not_operator; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:isinstance; 26, argument_list; 26, 27; 26, 28; 27, identifier:classlist; 28, identifier:list; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:classlist; 33, list:[classlist]; 33, 34; 34, identifier:classlist; 35, for_statement; 35, 36; 35, 37; 35, 38; 36, identifier:class_item; 37, identifier:classlist; 38, block; 38, 39; 39, for_statement; 39, 40; 39, 41; 39, 46; 40, identifier:obj; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:gc; 44, identifier:get_objects; 45, argument_list; 46, block; 46, 47; 47, if_statement; 47, 48; 47, 53; 48, call; 48, 49; 48, 50; 49, identifier:isinstance; 50, argument_list; 50, 51; 50, 52; 51, identifier:obj; 52, identifier:class_item; 53, block; 53, 54; 53, 58; 53, 78; 54, expression_statement; 54, 55; 55, augmented_assignment:+=; 55, 56; 55, 57; 56, identifier:graphcount; 57, integer:1; 58, expression_statement; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:objgraph; 62, identifier:show_refs; 63, argument_list; 63, 64; 63, 66; 64, list:[obj]; 64, 65; 65, identifier:obj; 66, keyword_argument; 66, 67; 66, 68; 67, identifier:filename; 68, binary_operator:%; 68, 69; 68, 70; 69, string:'%d_%s_%d_refs.png'; 70, tuple; 70, 71; 70, 72; 70, 77; 71, identifier:ogcounter; 72, attribute; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:obj; 75, identifier:__class__; 76, identifier:__name__; 77, identifier:graphcount; 78, expression_statement; 78, 79; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:objgraph; 82, identifier:show_backrefs; 83, argument_list; 83, 84; 83, 86; 84, list:[obj]; 84, 85; 85, identifier:obj; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:filename; 88, binary_operator:%; 88, 89; 88, 90; 89, string:'%d_%s_%d_backrefs.png'; 90, tuple; 90, 91; 90, 92; 90, 97; 91, identifier:ogcounter; 92, attribute; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:obj; 95, identifier:__class__; 96, identifier:__name__; 97, identifier:graphcount | def generate_object_graphs_by_class(classlist):
try:
import objgraph
import gc
except ImportError:
return
graphcount = 0
if not isinstance(classlist, list):
classlist = [classlist]
for class_item in classlist:
for obj in gc.get_objects():
if isinstance(obj, class_item):
graphcount += 1
objgraph.show_refs([obj], filename='%d_%s_%d_refs.png' % (
ogcounter, obj.__class__.__name__, graphcount))
objgraph.show_backrefs([obj], filename='%d_%s_%d_backrefs.png' % (
ogcounter, obj.__class__.__name__, graphcount)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_wait_for_exec_ready; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 113; 5, 165; 5, 189; 5, 195; 6, while_statement; 6, 7; 6, 22; 7, boolean_operator:and; 7, 8; 7, 17; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:response_received; 14, identifier:wait; 15, argument_list; 15, 16; 16, integer:1; 17, comparison_operator:!=; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:query_timeout; 21, integer:0; 22, block; 22, 23; 22, 87; 22, 107; 23, if_statement; 23, 24; 23, 39; 24, boolean_operator:and; 24, 25; 24, 30; 25, comparison_operator:!=; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:query_timeout; 29, integer:0; 30, comparison_operator:<; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:query_timeout; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:get_time; 38, argument_list; 39, block; 39, 40; 39, 59; 39, 70; 39, 76; 40, if_statement; 40, 41; 40, 44; 40, 53; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:prev; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:cmd; 48, attribute; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:prev; 52, identifier:cmd; 53, else_clause; 53, 54; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:cmd; 58, string:"???"; 59, expression_statement; 59, 60; 60, call; 60, 61; 60, 66; 61, attribute; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:logger; 65, identifier:error; 66, argument_list; 66, 67; 67, binary_operator:+; 67, 68; 67, 69; 68, string:"CMD timeout: "; 69, identifier:cmd; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:query_timeout; 75, integer:0; 76, raise_statement; 76, 77; 77, call; 77, 78; 77, 79; 78, identifier:TestStepTimeout; 79, argument_list; 79, 80; 80, binary_operator:+; 80, 81; 80, 86; 81, binary_operator:+; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:name; 85, string:" CMD timeout: "; 86, identifier:cmd; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 94; 89, attribute; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:logger; 93, identifier:debug; 94, argument_list; 94, 95; 94, 98; 95, concatenated_string; 95, 96; 95, 97; 96, string:"Waiting for response... "; 97, string:"timeout=%d"; 98, binary_operator:-; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:self; 101, identifier:query_timeout; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:self; 105, identifier:get_time; 106, argument_list; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:_dut_is_alive; 112, argument_list; 113, if_statement; 113, 114; 113, 120; 114, comparison_operator:==; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:self; 117, identifier:response_coming_in; 118, unary_operator:-; 118, 119; 119, integer:1; 120, block; 120, 121; 120, 145; 120, 154; 121, if_statement; 121, 122; 121, 127; 122, comparison_operator:is; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:self; 125, identifier:query_async_response; 126, None; 127, block; 127, 128; 127, 139; 128, expression_statement; 128, 129; 129, call; 129, 130; 129, 135; 130, attribute; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:self; 133, identifier:query_async_response; 134, identifier:set_response; 135, argument_list; 135, 136; 136, call; 136, 137; 136, 138; 137, identifier:CliResponse; 138, argument_list; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:query_async_response; 144, None; 145, expression_statement; 145, 146; 146, call; 146, 147; 146, 152; 147, attribute; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:self; 150, identifier:logger; 151, identifier:error; 152, argument_list; 152, 153; 153, string:"No response received, DUT died"; 154, raise_statement; 154, 155; 155, call; 155, 156; 155, 157; 156, identifier:TestStepError; 157, argument_list; 157, 158; 158, binary_operator:+; 158, 159; 158, 164; 159, binary_operator:+; 159, 160; 159, 161; 160, string:"No response received, DUT "; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:name; 164, string:" died"; 165, if_statement; 165, 166; 165, 171; 166, comparison_operator:is; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:self; 169, identifier:query_async_response; 170, None; 171, block; 171, 172; 171, 183; 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:query_async_response; 178, identifier:set_response; 179, argument_list; 179, 180; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:response_coming_in; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:self; 187, identifier:query_async_response; 188, None; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:self; 193, identifier:query_timeout; 194, integer:0; 195, return_statement; 195, 196; 196, attribute; 196, 197; 196, 198; 197, identifier:self; 198, identifier:response_coming_in | def _wait_for_exec_ready(self):
while not self.response_received.wait(1) and self.query_timeout != 0:
if self.query_timeout != 0 and self.query_timeout < self.get_time():
if self.prev:
cmd = self.prev.cmd
else:
cmd = "???"
self.logger.error("CMD timeout: "+ cmd)
self.query_timeout = 0
raise TestStepTimeout(self.name + " CMD timeout: " + cmd)
self.logger.debug("Waiting for response... "
"timeout=%d", self.query_timeout - self.get_time())
self._dut_is_alive()
if self.response_coming_in == -1:
if self.query_async_response is not None:
self.query_async_response.set_response(CliResponse())
self.query_async_response = None
self.logger.error("No response received, DUT died")
raise TestStepError("No response received, DUT "+self.name+" died")
if self.query_async_response is not None:
self.query_async_response.set_response(self.response_coming_in)
self.query_async_response = None
self.query_timeout = 0
return self.response_coming_in |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:execute_command; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:req; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 88; 8, 149; 8, 157; 8, 176; 8, 182; 8, 193; 8, 218; 8, 233; 8, 240; 8, 270; 8, 313; 9, if_statement; 9, 10; 9, 15; 10, call; 10, 11; 10, 12; 11, identifier:isinstance; 12, argument_list; 12, 13; 12, 14; 13, identifier:req; 14, identifier:string_types; 15, block; 15, 16; 15, 20; 15, 24; 15, 28; 15, 65; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:timeout; 19, integer:50; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:wait; 23, True; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:asynchronous; 27, False; 28, for_statement; 28, 29; 28, 30; 28, 31; 29, identifier:key; 30, identifier:kwargs; 31, block; 31, 32; 32, if_statement; 32, 33; 32, 36; 32, 43; 32, 54; 33, comparison_operator:==; 33, 34; 33, 35; 34, identifier:key; 35, string:'wait'; 36, block; 36, 37; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:wait; 40, subscript; 40, 41; 40, 42; 41, identifier:kwargs; 42, identifier:key; 43, elif_clause; 43, 44; 43, 47; 44, comparison_operator:==; 44, 45; 44, 46; 45, identifier:key; 46, string:'timeout'; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:timeout; 51, subscript; 51, 52; 51, 53; 52, identifier:kwargs; 53, identifier:key; 54, elif_clause; 54, 55; 54, 58; 55, comparison_operator:==; 55, 56; 55, 57; 56, identifier:key; 57, string:'asynchronous'; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:asynchronous; 62, subscript; 62, 63; 62, 64; 63, identifier:kwargs; 64, identifier:key; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:req; 68, call; 68, 69; 68, 70; 69, identifier:CliRequest; 70, argument_list; 70, 71; 70, 72; 70, 79; 70, 82; 70, 85; 71, identifier:req; 72, keyword_argument; 72, 73; 72, 74; 73, identifier:timestamp; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:get_time; 78, argument_list; 79, keyword_argument; 79, 80; 79, 81; 80, identifier:wait; 81, identifier:wait; 82, keyword_argument; 82, 83; 82, 84; 83, identifier:timeout; 84, identifier:timeout; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:asynchronous; 87, identifier:asynchronous; 88, if_statement; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:req; 91, identifier:wait; 92, block; 92, 93; 92, 101; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:response; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:_wait_for_exec_ready; 100, argument_list; 101, if_statement; 101, 102; 101, 111; 102, boolean_operator:and; 102, 103; 102, 106; 103, comparison_operator:is; 103, 104; 103, 105; 104, identifier:response; 105, None; 106, comparison_operator:is; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:query_async_expected; 110, None; 111, block; 111, 112; 111, 143; 112, if_statement; 112, 113; 112, 120; 113, comparison_operator:!=; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:response; 116, identifier:retcode; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:query_async_expected; 120, block; 120, 121; 120, 138; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 128; 123, attribute; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:logger; 127, identifier:error; 128, argument_list; 128, 129; 128, 132; 128, 135; 129, concatenated_string; 129, 130; 129, 131; 130, string:"Asynch call returned unexpected result, "; 131, string:"expected %d was %d"; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:query_async_expected; 135, attribute; 135, 136; 135, 137; 136, identifier:response; 137, identifier:retcode; 138, raise_statement; 138, 139; 139, call; 139, 140; 139, 141; 140, identifier:TestStepFail; 141, argument_list; 141, 142; 142, string:"Asynch call returned unexpected result"; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:query_async_expected; 148, None; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 156; 151, attribute; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:response_received; 155, identifier:clear; 156, argument_list; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:query_timeout; 162, conditional_expression:if; 162, 163; 162, 172; 162, 175; 163, binary_operator:+; 163, 164; 163, 169; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:get_time; 168, argument_list; 169, attribute; 169, 170; 169, 171; 170, identifier:req; 171, identifier:timeout; 172, attribute; 172, 173; 172, 174; 173, identifier:req; 174, identifier:wait; 175, integer:0; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:self; 180, identifier:query; 181, identifier:req; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:msg; 185, conditional_expression:if; 185, 186; 185, 189; 185, 192; 186, concatenated_string; 186, 187; 186, 188; 187, string:"Async CMD {}, "; 188, string:"timeout={}, time={}"; 189, attribute; 189, 190; 189, 191; 190, identifier:req; 191, identifier:asynchronous; 192, string:"CMD {}, timeout={}, time={}"; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 196; 195, identifier:msg; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:msg; 199, identifier:format; 200, argument_list; 200, 201; 200, 204; 200, 210; 201, attribute; 201, 202; 201, 203; 202, identifier:req; 203, identifier:cmd; 204, call; 204, 205; 204, 206; 205, identifier:int; 206, argument_list; 206, 207; 207, attribute; 207, 208; 207, 209; 208, identifier:self; 209, identifier:query_timeout; 210, call; 210, 211; 210, 212; 211, identifier:int; 212, argument_list; 212, 213; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:self; 216, identifier:get_time; 217, argument_list; 218, expression_statement; 218, 219; 219, call; 219, 220; 219, 225; 220, attribute; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:self; 223, identifier:logger; 224, identifier:debug; 225, argument_list; 225, 226; 225, 227; 226, identifier:msg; 227, keyword_argument; 227, 228; 227, 229; 228, identifier:extra; 229, dictionary; 229, 230; 230, pair; 230, 231; 230, 232; 231, string:'type'; 232, string:'<->'; 233, expression_statement; 233, 234; 234, call; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:Dut; 237, identifier:process_dut; 238, argument_list; 238, 239; 239, identifier:self; 240, if_statement; 240, 241; 240, 246; 241, comparison_operator:is; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:req; 244, identifier:asynchronous; 245, True; 246, block; 246, 247; 246, 255; 246, 262; 246, 268; 247, expression_statement; 247, 248; 248, assignment; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:self; 251, identifier:query_async_expected; 252, attribute; 252, 253; 252, 254; 253, identifier:req; 254, identifier:expected_retcode; 255, expression_statement; 255, 256; 256, assignment; 256, 257; 256, 258; 257, identifier:async_response; 258, call; 258, 259; 258, 260; 259, identifier:CliAsyncResponse; 260, argument_list; 260, 261; 261, identifier:self; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:self; 266, identifier:query_async_response; 267, identifier:async_response; 268, return_statement; 268, 269; 269, identifier:async_response; 270, if_statement; 270, 271; 270, 276; 271, comparison_operator:is; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:req; 274, identifier:wait; 275, False; 276, block; 276, 277; 276, 285; 276, 303; 276, 309; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:self; 281, identifier:query_async_expected; 282, attribute; 282, 283; 282, 284; 283, identifier:req; 284, identifier:expected_retcode; 285, if_statement; 285, 286; 285, 291; 286, comparison_operator:is; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:self; 289, identifier:query_async_response; 290, None; 291, block; 291, 292; 292, expression_statement; 292, 293; 293, call; 293, 294; 293, 299; 294, attribute; 294, 295; 294, 298; 295, attribute; 295, 296; 295, 297; 296, identifier:self; 297, identifier:query_async_response; 298, identifier:set_response; 299, argument_list; 299, 300; 300, call; 300, 301; 300, 302; 301, identifier:CliResponse; 302, argument_list; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:self; 307, identifier:query_async_response; 308, None; 309, return_statement; 309, 310; 310, call; 310, 311; 310, 312; 311, identifier:CliResponse; 312, argument_list; 313, return_statement; 313, 314; 314, call; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:self; 317, identifier:_wait_for_exec_ready; 318, argument_list | def execute_command(self, req, **kwargs):
if isinstance(req, string_types):
timeout = 50
wait = True
asynchronous = False
for key in kwargs:
if key == 'wait':
wait = kwargs[key]
elif key == 'timeout':
timeout = kwargs[key]
elif key == 'asynchronous':
asynchronous = kwargs[key]
req = CliRequest(req,
timestamp=self.get_time(),
wait=wait,
timeout=timeout,
asynchronous=asynchronous)
if req.wait:
response = self._wait_for_exec_ready()
if response is not None and self.query_async_expected is not None:
if response.retcode != self.query_async_expected:
self.logger.error("Asynch call returned unexpected result, "
"expected %d was %d", self.query_async_expected,
response.retcode)
raise TestStepFail("Asynch call returned unexpected result")
self.query_async_expected = None
self.response_received.clear()
self.query_timeout = self.get_time() + req.timeout if req.wait else 0
self.query = req
msg = "Async CMD {}, " \
"timeout={}, time={}" if req.asynchronous else "CMD {}, timeout={}, time={}"
msg = msg.format(req.cmd, int(self.query_timeout), int(self.get_time()))
self.logger.debug(msg, extra={'type': '<->'})
Dut.process_dut(self)
if req.asynchronous is True:
self.query_async_expected = req.expected_retcode
async_response = CliAsyncResponse(self)
self.query_async_response = async_response
return async_response
if req.wait is False:
self.query_async_expected = req.expected_retcode
if self.query_async_response is not None:
self.query_async_response.set_response(CliResponse())
self.query_async_response = None
return CliResponse()
return self._wait_for_exec_ready() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:run; 3, parameters; 4, block; 4, 5; 4, 20; 4, 336; 5, expression_statement; 5, 6; 6, call; 6, 7; 6, 12; 7, attribute; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:Dut; 10, identifier:_logger; 11, identifier:debug; 12, argument_list; 12, 13; 12, 14; 13, string:"Start DUT communication"; 14, keyword_argument; 14, 15; 14, 16; 15, identifier:extra; 16, dictionary; 16, 17; 17, pair; 17, 18; 17, 19; 18, string:'type'; 19, string:'<->'; 20, while_statement; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:Dut; 23, identifier:_run; 24, block; 24, 25; 24, 33; 25, expression_statement; 25, 26; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:Dut; 30, identifier:_sem; 31, identifier:acquire; 32, argument_list; 33, try_statement; 33, 34; 33, 332; 34, block; 34, 35; 34, 45; 34, 133; 34, 233; 34, 262; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:dut; 38, call; 38, 39; 38, 44; 39, attribute; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:Dut; 42, identifier:_signalled_duts; 43, identifier:pop; 44, argument_list; 45, if_statement; 45, 46; 45, 51; 46, comparison_operator:is; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:dut; 49, identifier:waiting_for_response; 50, None; 51, block; 51, 52; 51, 58; 51, 68; 51, 76; 51, 103; 51, 109; 51, 124; 51, 132; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:item; 55, attribute; 55, 56; 55, 57; 56, identifier:dut; 57, identifier:waiting_for_response; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:dut; 62, identifier:response_coming_in; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:dut; 66, identifier:_read_response; 67, argument_list; 68, if_statement; 68, 69; 68, 74; 69, comparison_operator:is; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:dut; 72, identifier:response_coming_in; 73, None; 74, block; 74, 75; 75, continue_statement; 76, if_statement; 76, 77; 76, 84; 77, call; 77, 78; 77, 79; 78, identifier:isinstance; 79, argument_list; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:dut; 82, identifier:response_coming_in; 83, identifier:CliResponse; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:dut; 90, identifier:response_coming_in; 91, identifier:set_response_time; 92, argument_list; 92, 93; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:item; 96, identifier:get_timedelta; 97, argument_list; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:dut; 101, identifier:get_time; 102, argument_list; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:dut; 107, identifier:waiting_for_response; 108, None; 109, expression_statement; 109, 110; 110, call; 110, 111; 110, 116; 111, attribute; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:dut; 114, identifier:logger; 115, identifier:debug; 116, argument_list; 116, 117; 116, 118; 117, string:"Got response"; 118, keyword_argument; 118, 119; 118, 120; 119, identifier:extra; 120, dictionary; 120, 121; 121, pair; 121, 122; 121, 123; 122, string:'type'; 123, string:'<->'; 124, expression_statement; 124, 125; 125, call; 125, 126; 125, 131; 126, attribute; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:dut; 129, identifier:response_received; 130, identifier:set; 131, argument_list; 132, continue_statement; 133, if_statement; 133, 134; 133, 139; 134, comparison_operator:is; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:dut; 137, identifier:query; 138, None; 139, block; 139, 140; 139, 146; 139, 152; 139, 169; 139, 199; 139, 205; 139, 232; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:item; 143, attribute; 143, 144; 143, 145; 144, identifier:dut; 145, identifier:query; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:dut; 150, identifier:query; 151, None; 152, expression_statement; 152, 153; 153, call; 153, 154; 153, 159; 154, attribute; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:dut; 157, identifier:logger; 158, identifier:info; 159, argument_list; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:item; 162, identifier:cmd; 163, keyword_argument; 163, 164; 163, 165; 164, identifier:extra; 165, dictionary; 165, 166; 166, pair; 166, 167; 166, 168; 167, string:'type'; 168, string:'-->'; 169, try_statement; 169, 170; 169, 180; 170, block; 170, 171; 171, expression_statement; 171, 172; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:dut; 175, identifier:writeline; 176, argument_list; 176, 177; 177, attribute; 177, 178; 177, 179; 178, identifier:item; 179, identifier:cmd; 180, except_clause; 180, 181; 180, 182; 181, identifier:RuntimeError; 182, block; 182, 183; 182, 190; 182, 198; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:dut; 187, identifier:response_coming_in; 188, unary_operator:-; 188, 189; 189, integer:1; 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:dut; 195, identifier:response_received; 196, identifier:set; 197, argument_list; 198, continue_statement; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:dut; 203, identifier:prev; 204, identifier:item; 205, if_statement; 205, 206; 205, 209; 205, 216; 206, attribute; 206, 207; 206, 208; 207, identifier:item; 208, identifier:wait; 209, block; 209, 210; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:dut; 214, identifier:waiting_for_response; 215, identifier:item; 216, else_clause; 216, 217; 217, block; 217, 218; 217, 224; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:dut; 222, identifier:query_timeout; 223, integer:0; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 231; 226, attribute; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:dut; 229, identifier:response_received; 230, identifier:set; 231, argument_list; 232, continue_statement; 233, try_statement; 233, 234; 233, 243; 234, block; 234, 235; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:line; 238, call; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:dut; 241, identifier:readline; 242, argument_list; 243, except_clause; 243, 244; 243, 245; 244, identifier:RuntimeError; 245, block; 245, 246; 245, 253; 245, 261; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:dut; 250, identifier:response_coming_in; 251, unary_operator:-; 251, 252; 252, integer:1; 253, expression_statement; 253, 254; 254, call; 254, 255; 254, 260; 255, attribute; 255, 256; 255, 259; 256, attribute; 256, 257; 256, 258; 257, identifier:dut; 258, identifier:response_received; 259, identifier:set; 260, argument_list; 261, continue_statement; 262, if_statement; 262, 263; 262, 264; 263, identifier:line; 264, block; 264, 265; 264, 279; 264, 288; 264, 297; 264, 317; 265, if_statement; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:dut; 268, identifier:store_traces; 269, block; 269, 270; 270, expression_statement; 270, 271; 271, call; 271, 272; 271, 277; 272, attribute; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:dut; 275, identifier:traces; 276, identifier:append; 277, argument_list; 277, 278; 278, identifier:line; 279, expression_statement; 279, 280; 280, call; 280, 281; 280, 282; 281, identifier:EventObject; 282, argument_list; 282, 283; 282, 286; 282, 287; 283, attribute; 283, 284; 283, 285; 284, identifier:EventTypes; 285, identifier:DUT_LINE_RECEIVED; 286, identifier:dut; 287, identifier:line; 288, expression_statement; 288, 289; 289, assignment; 289, 290; 289, 291; 290, identifier:retcode; 291, call; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:dut; 294, identifier:check_retcode; 295, argument_list; 295, 296; 296, identifier:line; 297, if_statement; 297, 298; 297, 301; 298, comparison_operator:is; 298, 299; 298, 300; 299, identifier:retcode; 300, None; 301, block; 301, 302; 302, expression_statement; 302, 303; 303, call; 303, 304; 303, 309; 304, attribute; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:dut; 307, identifier:logger; 308, identifier:warning; 309, argument_list; 309, 310; 309, 311; 310, string:"unrequested retcode"; 311, keyword_argument; 311, 312; 311, 313; 312, identifier:extra; 313, dictionary; 313, 314; 314, pair; 314, 315; 314, 316; 315, string:'type'; 316, string:'!<-'; 317, expression_statement; 317, 318; 318, call; 318, 319; 318, 324; 319, attribute; 319, 320; 319, 323; 320, attribute; 320, 321; 320, 322; 321, identifier:dut; 322, identifier:logger; 323, identifier:debug; 324, argument_list; 324, 325; 324, 326; 325, identifier:line; 326, keyword_argument; 326, 327; 326, 328; 327, identifier:extra; 328, dictionary; 328, 329; 329, pair; 329, 330; 329, 331; 330, string:'type'; 331, string:'<<<'; 332, except_clause; 332, 333; 332, 334; 333, identifier:IndexError; 334, block; 334, 335; 335, pass_statement; 336, expression_statement; 336, 337; 337, call; 337, 338; 337, 343; 338, attribute; 338, 339; 338, 342; 339, attribute; 339, 340; 339, 341; 340, identifier:Dut; 341, identifier:_logger; 342, identifier:debug; 343, argument_list; 343, 344; 343, 345; 344, string:"End DUT communication"; 345, keyword_argument; 345, 346; 345, 347; 346, identifier:extra; 347, dictionary; 347, 348; 348, pair; 348, 349; 348, 350; 349, string:'type'; 350, string:'<->' | def run():
Dut._logger.debug("Start DUT communication", extra={'type': '<->'})
while Dut._run:
Dut._sem.acquire()
try:
dut = Dut._signalled_duts.pop()
if dut.waiting_for_response is not None:
item = dut.waiting_for_response
dut.response_coming_in = dut._read_response()
if dut.response_coming_in is None:
continue
if isinstance(dut.response_coming_in, CliResponse):
dut.response_coming_in.set_response_time(item.get_timedelta(dut.get_time()))
dut.waiting_for_response = None
dut.logger.debug("Got response", extra={'type': '<->'})
dut.response_received.set()
continue
if dut.query is not None:
item = dut.query
dut.query = None
dut.logger.info(item.cmd, extra={'type': '-->'})
try:
dut.writeline(item.cmd)
except RuntimeError:
dut.response_coming_in = -1
dut.response_received.set()
continue
dut.prev = item
if item.wait:
dut.waiting_for_response = item
else:
dut.query_timeout = 0
dut.response_received.set()
continue
try:
line = dut.readline()
except RuntimeError:
dut.response_coming_in = -1
dut.response_received.set()
continue
if line:
if dut.store_traces:
dut.traces.append(line)
EventObject(EventTypes.DUT_LINE_RECEIVED, dut, line)
retcode = dut.check_retcode(line)
if retcode is not None:
dut.logger.warning("unrequested retcode", extra={'type': '!<-'})
dut.logger.debug(line, extra={'type': '<<<'})
except IndexError:
pass
Dut._logger.debug("End DUT communication", extra={'type': '<->'}) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.