sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:check_base_suggested_attributes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dataset; 6, block; 6, 7; 6, 9; 6, 19; 6, 28; 6, 38; 6, 47; 6, 73; 6, 121; 6, 134; 6, 149; 6, 162; 6, 177; 6, 186; 6, 195; 6, 204; 6, 213; 6, 223; 6, 239; 6, 249; 6, 265; 7, expression_statement; 7, 8; 8, string:''' Check the global suggested attributes for 2.0 templates. These go an extra step besides just checking that they exist. :param netCDF4.Dataset dataset: An open netCDF dataset :creator_type = "" ; //........................................ SUGGESTED - Specifies type of creator with one of the following: 'person', 'group', 'institution', or 'position'. (ACDD) :creator_institution = "" ; //................................. SUGGESTED - The institution of the creator; should uniquely identify the creator's institution. (ACDD) :publisher_type = "" ; //...................................... SUGGESTED - Specifies type of publisher with one of the following: 'person', 'group', 'institution', or 'position'. (ACDD) :publisher_institution = "" ; //............................... SUGGESTED - The institution that presented the data file or equivalent product to users; should uniquely identify the institution. (ACDD) :program = "" ; //............................................. SUGGESTED - The overarching program(s) of which the dataset is a part. (ACDD) :contributor_name = "" ; //.................................... SUGGESTED - The name of any individuals, projects, or institutions that contributed to the creation of this data. (ACDD) :contributor_role = "" ; //.................................... SUGGESTED - The role of any individuals, projects, or institutions that contributed to the creation of this data. (ACDD) :geospatial_lat_units = "degrees_north" ; //.................. SUGGESTED - Units for the latitude axis described in "geospatial_lat_min" and "geospatial_lat_max" attributes. Use UDUNITS compatible units. (ACDD) :geospatial_lon_units = "degrees_east"; //..................... SUGGESTED - Units for the longitude axis described in "geospatial_lon_min" and "geospatial_lon_max" attributes. Use UDUNITS compatible units. (ACDD) :geospatial_vertical_units = "" ; //........................... SUGGESTED - Units for the vertical axis described in "geospatial_vertical_min" and "geospatial_vertical_max" attributes. The default is EPSG:4979. (ACDD) :date_modified = "" ; //....................................... SUGGESTED - The date on which the data was last modified. Note that this applies just to the data, not the metadata. Use ISO 8601:2004 for date and time. (ACDD) :date_issued = "" ; //......................................... SUGGESTED - The date on which this data (including all modifications) was formally issued (i.e., made available to a wider audience). Note that these apply just to the data, not the metadata. Use ISO 8601:2004 for date and time. (ACDD) :date_metadata_modified = "" ; //.............................. SUGGESTED - The date on which the metadata was last modified. Use ISO 8601:2004 for date and time. (ACDD) :product_version = "" ; //..................................... SUGGESTED - Version identifier of the data file or product as assigned by the data creator. (ACDD) :keywords_vocabulary = "" ; //................................. SUGGESTED - Identifies the controlled keyword vocabulary used to specify the values within the attribute "keywords". Example: 'GCMD:GCMD Keywords' ACDD) :platform = "" ; //............................................ SUGGESTED - Name of the platform(s) that supported the sensor data used to create this data set or product. Platforms can be of any type, including satellite, ship, station, aircraft or other. (ACDD) :platform_vocabulary = "" ; //................................. SUGGESTED - Controlled vocabulary for the names used in the "platform" attribute . Example: ‘NASA/GCMD Platform Keywords Version 8.1’ (ACDD) :instrument = "" ; //.......................................... SUGGESTED - Name of the contributing instrument(s) or sensor(s) used to create this data set or product. (ACDD) :instrument_vocabulary = "" ; //............................... SUGGESTED - Controlled vocabulary for the names used in the "instrument" attribute. Example: ‘NASA/GCMD Instrument Keywords Version 8.1’ (ACDD) :cdm_data_type = "Point" ; //.................................. SUGGESTED - The data type, as derived from Unidata's Common Data Model Scientific Data types and understood by THREDDS. (ACDD) :metadata_link = "" ; //....................................... SUGGESTED - A URL that gives the location of more complete metadata. A persistent URL is recommended for this attribute. (ACDD) :references = "" ; //.......................................... SUGGESTED - Published or web-based references that describe the data or methods used to produce it. Recommend URIs (such as a URL or DOI) for papers or other references. (CF) '''; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:suggested_ctx; 12, call; 12, 13; 12, 14; 13, identifier:TestCtx; 14, argument_list; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:BaseCheck; 17, identifier:LOW; 18, string:'Suggested global attributes'; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:platform_name; 22, call; 22, 23; 22, 24; 23, identifier:getattr; 24, argument_list; 24, 25; 24, 26; 24, 27; 25, identifier:dataset; 26, string:'platform'; 27, string:''; 28, expression_statement; 28, 29; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:suggested_ctx; 32, identifier:assert_true; 33, argument_list; 33, 34; 33, 37; 34, comparison_operator:!=; 34, 35; 34, 36; 35, identifier:platform_name; 36, string:''; 37, string:'platform should exist and point to a term in :platform_vocabulary.'; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:cdm_data_type; 41, call; 41, 42; 41, 43; 42, identifier:getattr; 43, argument_list; 43, 44; 43, 45; 43, 46; 44, identifier:dataset; 45, string:'cdm_data_type'; 46, string:''; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:suggested_ctx; 51, identifier:assert_true; 52, argument_list; 52, 53; 52, 67; 53, comparison_operator:in; 53, 54; 53, 59; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:cdm_data_type; 57, identifier:lower; 58, argument_list; 59, list:['grid', 'image', 'point', 'radial', 'station', 'swath', 'trajectory']; 59, 60; 59, 61; 59, 62; 59, 63; 59, 64; 59, 65; 59, 66; 60, string:'grid'; 61, string:'image'; 62, string:'point'; 63, string:'radial'; 64, string:'station'; 65, string:'swath'; 66, string:'trajectory'; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, string:'cdm_data_type must be one of Grid, Image, Point, Radial, Station, Swath, Trajectory: {}'; 70, identifier:format; 71, argument_list; 71, 72; 72, identifier:cdm_data_type; 73, for_statement; 73, 74; 73, 75; 73, 79; 74, identifier:attr; 75, list:['date_modified', 'date_issued', 'date_metadata_modified']; 75, 76; 75, 77; 75, 78; 76, string:'date_modified'; 77, string:'date_issued'; 78, string:'date_metadata_modified'; 79, block; 79, 80; 79, 89; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:attr_value; 83, call; 83, 84; 83, 85; 84, identifier:getattr; 85, argument_list; 85, 86; 85, 87; 85, 88; 86, identifier:dataset; 87, identifier:attr; 88, string:''; 89, try_statement; 89, 90; 89, 104; 90, block; 90, 91; 90, 96; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 94; 93, identifier:parse_datetime; 94, argument_list; 94, 95; 95, identifier:attr_value; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:suggested_ctx; 100, identifier:assert_true; 101, argument_list; 101, 102; 101, 103; 102, True; 103, string:''; 104, except_clause; 104, 105; 104, 106; 105, identifier:ISO8601Error; 106, block; 106, 107; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:suggested_ctx; 111, identifier:assert_true; 112, argument_list; 112, 113; 112, 114; 113, False; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, string:'{} should exist and be ISO-8601 format (example: PT1M30S), currently: {}'; 117, identifier:format; 118, argument_list; 118, 119; 118, 120; 119, identifier:attr; 120, identifier:attr_value; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:units; 124, call; 124, 125; 124, 133; 125, attribute; 125, 126; 125, 132; 126, call; 126, 127; 126, 128; 127, identifier:getattr; 128, argument_list; 128, 129; 128, 130; 128, 131; 129, identifier:dataset; 130, string:'geospatial_lat_units'; 131, string:''; 132, identifier:lower; 133, argument_list; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:suggested_ctx; 138, identifier:assert_true; 139, argument_list; 139, 140; 139, 143; 140, comparison_operator:==; 140, 141; 140, 142; 141, identifier:units; 142, string:'degrees_north'; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, string:'geospatial_lat_units attribute should be degrees_north: {}'; 146, identifier:format; 147, argument_list; 147, 148; 148, identifier:units; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:units; 152, call; 152, 153; 152, 161; 153, attribute; 153, 154; 153, 160; 154, call; 154, 155; 154, 156; 155, identifier:getattr; 156, argument_list; 156, 157; 156, 158; 156, 159; 157, identifier:dataset; 158, string:'geospatial_lon_units'; 159, string:''; 160, identifier:lower; 161, argument_list; 162, expression_statement; 162, 163; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:suggested_ctx; 166, identifier:assert_true; 167, argument_list; 167, 168; 167, 171; 168, comparison_operator:==; 168, 169; 168, 170; 169, identifier:units; 170, string:'degrees_east'; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, string:'geospatial_lon_units attribute should be degrees_east: {}'; 174, identifier:format; 175, argument_list; 175, 176; 176, identifier:units; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:contributor_name; 180, call; 180, 181; 180, 182; 181, identifier:getattr; 182, argument_list; 182, 183; 182, 184; 182, 185; 183, identifier:dataset; 184, string:'contributor_name'; 185, string:''; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:contributor_role; 189, call; 189, 190; 189, 191; 190, identifier:getattr; 191, argument_list; 191, 192; 191, 193; 191, 194; 192, identifier:dataset; 193, string:'contributor_role'; 194, string:''; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 198; 197, identifier:names; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:contributor_role; 201, identifier:split; 202, argument_list; 202, 203; 203, string:','; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 207; 206, identifier:roles; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:contributor_role; 210, identifier:split; 211, argument_list; 211, 212; 212, string:','; 213, expression_statement; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:suggested_ctx; 217, identifier:assert_true; 218, argument_list; 218, 219; 218, 222; 219, comparison_operator:!=; 219, 220; 219, 221; 220, identifier:contributor_name; 221, string:''; 222, string:'contributor_name should exist and not be empty.'; 223, expression_statement; 223, 224; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:suggested_ctx; 227, identifier:assert_true; 228, argument_list; 228, 229; 228, 238; 229, comparison_operator:==; 229, 230; 229, 234; 230, call; 230, 231; 230, 232; 231, identifier:len; 232, argument_list; 232, 233; 233, identifier:names; 234, call; 234, 235; 234, 236; 235, identifier:len; 236, argument_list; 236, 237; 237, identifier:roles; 238, string:'length of contributor names matches length of roles'; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:suggested_ctx; 243, identifier:assert_true; 244, argument_list; 244, 245; 244, 248; 245, comparison_operator:!=; 245, 246; 245, 247; 246, identifier:contributor_role; 247, string:''; 248, string:'contributor_role should exist and not be empty.'; 249, expression_statement; 249, 250; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:suggested_ctx; 253, identifier:assert_true; 254, argument_list; 254, 255; 254, 264; 255, comparison_operator:==; 255, 256; 255, 260; 256, call; 256, 257; 256, 258; 257, identifier:len; 258, argument_list; 258, 259; 259, identifier:names; 260, call; 260, 261; 260, 262; 261, identifier:len; 262, argument_list; 262, 263; 263, identifier:roles; 264, string:'length of contributor names matches length of roles'; 265, return_statement; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:suggested_ctx; 269, identifier:to_result; 270, argument_list
def check_base_suggested_attributes(self, dataset): ''' Check the global suggested attributes for 2.0 templates. These go an extra step besides just checking that they exist. :param netCDF4.Dataset dataset: An open netCDF dataset :creator_type = "" ; //........................................ SUGGESTED - Specifies type of creator with one of the following: 'person', 'group', 'institution', or 'position'. (ACDD) :creator_institution = "" ; //................................. SUGGESTED - The institution of the creator; should uniquely identify the creator's institution. (ACDD) :publisher_type = "" ; //...................................... SUGGESTED - Specifies type of publisher with one of the following: 'person', 'group', 'institution', or 'position'. (ACDD) :publisher_institution = "" ; //............................... SUGGESTED - The institution that presented the data file or equivalent product to users; should uniquely identify the institution. (ACDD) :program = "" ; //............................................. SUGGESTED - The overarching program(s) of which the dataset is a part. (ACDD) :contributor_name = "" ; //.................................... SUGGESTED - The name of any individuals, projects, or institutions that contributed to the creation of this data. (ACDD) :contributor_role = "" ; //.................................... SUGGESTED - The role of any individuals, projects, or institutions that contributed to the creation of this data. (ACDD) :geospatial_lat_units = "degrees_north" ; //.................. SUGGESTED - Units for the latitude axis described in "geospatial_lat_min" and "geospatial_lat_max" attributes. Use UDUNITS compatible units. (ACDD) :geospatial_lon_units = "degrees_east"; //..................... SUGGESTED - Units for the longitude axis described in "geospatial_lon_min" and "geospatial_lon_max" attributes. Use UDUNITS compatible units. (ACDD) :geospatial_vertical_units = "" ; //........................... SUGGESTED - Units for the vertical axis described in "geospatial_vertical_min" and "geospatial_vertical_max" attributes. The default is EPSG:4979. (ACDD) :date_modified = "" ; //....................................... SUGGESTED - The date on which the data was last modified. Note that this applies just to the data, not the metadata. Use ISO 8601:2004 for date and time. (ACDD) :date_issued = "" ; //......................................... SUGGESTED - The date on which this data (including all modifications) was formally issued (i.e., made available to a wider audience). Note that these apply just to the data, not the metadata. Use ISO 8601:2004 for date and time. (ACDD) :date_metadata_modified = "" ; //.............................. SUGGESTED - The date on which the metadata was last modified. Use ISO 8601:2004 for date and time. (ACDD) :product_version = "" ; //..................................... SUGGESTED - Version identifier of the data file or product as assigned by the data creator. (ACDD) :keywords_vocabulary = "" ; //................................. SUGGESTED - Identifies the controlled keyword vocabulary used to specify the values within the attribute "keywords". Example: 'GCMD:GCMD Keywords' ACDD) :platform = "" ; //............................................ SUGGESTED - Name of the platform(s) that supported the sensor data used to create this data set or product. Platforms can be of any type, including satellite, ship, station, aircraft or other. (ACDD) :platform_vocabulary = "" ; //................................. SUGGESTED - Controlled vocabulary for the names used in the "platform" attribute . Example: ‘NASA/GCMD Platform Keywords Version 8.1’ (ACDD) :instrument = "" ; //.......................................... SUGGESTED - Name of the contributing instrument(s) or sensor(s) used to create this data set or product. (ACDD) :instrument_vocabulary = "" ; //............................... SUGGESTED - Controlled vocabulary for the names used in the "instrument" attribute. Example: ‘NASA/GCMD Instrument Keywords Version 8.1’ (ACDD) :cdm_data_type = "Point" ; //.................................. SUGGESTED - The data type, as derived from Unidata's Common Data Model Scientific Data types and understood by THREDDS. (ACDD) :metadata_link = "" ; //....................................... SUGGESTED - A URL that gives the location of more complete metadata. A persistent URL is recommended for this attribute. (ACDD) :references = "" ; //.......................................... SUGGESTED - Published or web-based references that describe the data or methods used to produce it. Recommend URIs (such as a URL or DOI) for papers or other references. (CF) ''' suggested_ctx = TestCtx(BaseCheck.LOW, 'Suggested global attributes') platform_name = getattr(dataset, 'platform', '') suggested_ctx.assert_true(platform_name != '', 'platform should exist and point to a term in :platform_vocabulary.') cdm_data_type = getattr(dataset, 'cdm_data_type', '') suggested_ctx.assert_true(cdm_data_type.lower() in ['grid', 'image', 'point', 'radial', 'station', 'swath', 'trajectory'], 'cdm_data_type must be one of Grid, Image, Point, Radial, Station, Swath, Trajectory: {}'.format(cdm_data_type)) for attr in ['date_modified', 'date_issued', 'date_metadata_modified']: attr_value = getattr(dataset, attr, '') try: parse_datetime(attr_value) suggested_ctx.assert_true(True, '') except ISO8601Error: suggested_ctx.assert_true(False, '{} should exist and be ISO-8601 format (example: PT1M30S), currently: {}'.format(attr, attr_value)) units = getattr(dataset, 'geospatial_lat_units', '').lower() suggested_ctx.assert_true(units == 'degrees_north', 'geospatial_lat_units attribute should be degrees_north: {}'.format(units)) units = getattr(dataset, 'geospatial_lon_units', '').lower() suggested_ctx.assert_true(units == 'degrees_east', 'geospatial_lon_units attribute should be degrees_east: {}'.format(units)) contributor_name = getattr(dataset, 'contributor_name', '') contributor_role = getattr(dataset, 'contributor_role', '') names = contributor_role.split(',') roles = contributor_role.split(',') suggested_ctx.assert_true(contributor_name != '', 'contributor_name should exist and not be empty.') suggested_ctx.assert_true(len(names) == len(roles), 'length of contributor names matches length of roles') suggested_ctx.assert_true(contributor_role != '', 'contributor_role should exist and not be empty.') suggested_ctx.assert_true(len(names) == len(roles), 'length of contributor names matches length of roles') return suggested_ctx.to_result()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:load_from_args_as_dataframe; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 8; 5, 21; 5, 58; 5, 67; 5, 71; 5, 185; 5, 281; 5, 290; 5, 313; 5, 323; 5, 346; 5, 365; 5, 387; 5, 409; 5, 424; 5, 453; 6, expression_statement; 6, 7; 7, string:''' Given parsed variant-loading arguments, return a pandas DataFrame. If no variant loading arguments are specified, return None. '''; 8, if_statement; 8, 9; 8, 18; 9, boolean_operator:and; 9, 10; 9, 14; 10, not_operator; 10, 11; 11, attribute; 11, 12; 11, 13; 12, identifier:args; 13, identifier:variants; 14, not_operator; 14, 15; 15, attribute; 15, 16; 15, 17; 16, identifier:args; 17, identifier:single_variant; 18, block; 18, 19; 19, return_statement; 19, 20; 20, None; 21, if_statement; 21, 22; 21, 25; 21, 45; 22, attribute; 22, 23; 22, 24; 23, identifier:args; 24, identifier:variant_source_name; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:variant_source_names; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:util; 32, identifier:expand; 33, argument_list; 33, 34; 33, 37; 33, 38; 33, 39; 34, attribute; 34, 35; 34, 36; 35, identifier:args; 36, identifier:variant_source_name; 37, string:'variant_source_name'; 38, string:'variant source'; 39, call; 39, 40; 39, 41; 40, identifier:len; 41, argument_list; 41, 42; 42, attribute; 42, 43; 42, 44; 43, identifier:args; 44, identifier:variants; 45, else_clause; 45, 46; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:variant_source_names; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:util; 53, identifier:drop_prefix; 54, argument_list; 54, 55; 55, attribute; 55, 56; 55, 57; 56, identifier:args; 57, identifier:variants; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:variant_to_sources; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:collections; 64, identifier:defaultdict; 65, argument_list; 65, 66; 66, identifier:list; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:dfs; 70, list:[]; 71, for_statement; 71, 72; 71, 73; 71, 82; 72, identifier:i; 73, call; 73, 74; 73, 75; 74, identifier:range; 75, argument_list; 75, 76; 76, call; 76, 77; 76, 78; 77, identifier:len; 78, argument_list; 78, 79; 79, attribute; 79, 80; 79, 81; 80, identifier:args; 81, identifier:variants; 82, block; 82, 83; 82, 89; 82, 106; 82, 139; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:name; 86, subscript; 86, 87; 86, 88; 87, identifier:variant_source_names; 88, identifier:i; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:prefix; 92, parenthesized_expression; 92, 93; 93, conditional_expression:if; 93, 94; 93, 95; 93, 103; 94, string:'metadata:'; 95, comparison_operator:==; 95, 96; 95, 102; 96, call; 96, 97; 96, 98; 97, identifier:len; 98, argument_list; 98, 99; 99, attribute; 99, 100; 99, 101; 100, identifier:args; 101, identifier:variants; 102, integer:1; 103, binary_operator:%; 103, 104; 103, 105; 104, string:"metadata:%s:"; 105, identifier:name; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:df; 109, call; 109, 110; 109, 111; 110, identifier:load_as_dataframe; 111, argument_list; 111, 112; 111, 117; 111, 120; 111, 125; 111, 130; 111, 136; 112, subscript; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:args; 115, identifier:variants; 116, identifier:i; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:name; 119, identifier:name; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:genome; 122, attribute; 122, 123; 122, 124; 123, identifier:args; 124, identifier:genome; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:max_variants; 127, attribute; 127, 128; 127, 129; 128, identifier:args; 129, identifier:max_variants_per_source; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:only_passing; 132, not_operator; 132, 133; 133, attribute; 133, 134; 133, 135; 134, identifier:args; 135, identifier:include_failing_variants; 136, keyword_argument; 136, 137; 136, 138; 137, identifier:metadata_column_prefix; 138, identifier:prefix; 139, if_statement; 139, 140; 139, 147; 139, 161; 140, comparison_operator:==; 140, 141; 140, 146; 141, subscript; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:df; 144, identifier:shape; 145, integer:0; 146, integer:0; 147, block; 147, 148; 148, expression_statement; 148, 149; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:logging; 152, identifier:warn; 153, argument_list; 153, 154; 154, binary_operator:%; 154, 155; 154, 156; 155, string:"No variants loaded from: %s"; 156, subscript; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:args; 159, identifier:variants; 160, identifier:i; 161, else_clause; 161, 162; 162, block; 162, 163; 162, 178; 163, for_statement; 163, 164; 163, 165; 163, 168; 164, identifier:variant; 165, attribute; 165, 166; 165, 167; 166, identifier:df; 167, identifier:variant; 168, block; 168, 169; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 176; 171, attribute; 171, 172; 171, 175; 172, subscript; 172, 173; 172, 174; 173, identifier:variant_to_sources; 174, identifier:variant; 175, identifier:append; 176, argument_list; 176, 177; 177, identifier:name; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:dfs; 182, identifier:append; 183, argument_list; 183, 184; 184, identifier:df; 185, if_statement; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:args; 188, identifier:single_variant; 189, block; 189, 190; 189, 194; 189, 198; 189, 219; 189, 271; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:variants; 193, list:[]; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:extra_args; 197, dictionary; 198, if_statement; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:args; 201, identifier:genome; 202, block; 202, 203; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:extra_args; 206, dictionary; 206, 207; 207, pair; 207, 208; 207, 209; 208, string:'ensembl'; 209, call; 209, 210; 209, 215; 210, attribute; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:varcode; 213, identifier:reference; 214, identifier:infer_genome; 215, argument_list; 215, 216; 216, attribute; 216, 217; 216, 218; 217, identifier:args; 218, identifier:genome; 219, for_statement; 219, 220; 219, 224; 219, 227; 220, tuple_pattern; 220, 221; 220, 222; 220, 223; 221, identifier:locus_str; 222, identifier:ref; 223, identifier:alt; 224, attribute; 224, 225; 224, 226; 225, identifier:args; 226, identifier:single_variant; 227, block; 227, 228; 227, 237; 227, 255; 227, 262; 228, expression_statement; 228, 229; 229, assignment; 229, 230; 229, 231; 230, identifier:locus; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:Locus; 234, identifier:parse; 235, argument_list; 235, 236; 236, identifier:locus_str; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:variant; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:varcode; 243, identifier:Variant; 244, argument_list; 244, 245; 244, 248; 244, 251; 244, 252; 244, 253; 245, attribute; 245, 246; 245, 247; 246, identifier:locus; 247, identifier:contig; 248, attribute; 248, 249; 248, 250; 249, identifier:locus; 250, identifier:inclusive_start; 251, identifier:ref; 252, identifier:alt; 253, dictionary_splat; 253, 254; 254, identifier:extra_args; 255, expression_statement; 255, 256; 256, call; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:variants; 259, identifier:append; 260, argument_list; 260, 261; 261, identifier:variant; 262, expression_statement; 262, 263; 263, call; 263, 264; 263, 269; 264, attribute; 264, 265; 264, 268; 265, subscript; 265, 266; 265, 267; 266, identifier:variant_to_sources; 267, identifier:variant; 268, identifier:append; 269, argument_list; 269, 270; 270, string:"commandline"; 271, expression_statement; 271, 272; 272, call; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:dfs; 275, identifier:append; 276, argument_list; 276, 277; 277, call; 277, 278; 277, 279; 278, identifier:variants_to_dataframe; 279, argument_list; 279, 280; 280, identifier:variants; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 284; 283, identifier:df; 284, call; 284, 285; 284, 288; 285, attribute; 285, 286; 285, 287; 286, identifier:dfs; 287, identifier:pop; 288, argument_list; 288, 289; 289, integer:0; 290, for_statement; 290, 291; 290, 292; 290, 293; 291, identifier:other_df; 292, identifier:dfs; 293, block; 293, 294; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 297; 296, identifier:df; 297, call; 297, 298; 297, 301; 298, attribute; 298, 299; 298, 300; 299, identifier:pandas; 300, identifier:merge; 301, argument_list; 301, 302; 301, 303; 301, 304; 301, 307; 302, identifier:df; 303, identifier:other_df; 304, keyword_argument; 304, 305; 304, 306; 305, identifier:how; 306, string:'outer'; 307, keyword_argument; 307, 308; 307, 309; 308, identifier:on; 309, binary_operator:+; 309, 310; 309, 312; 310, list:["variant"]; 310, 311; 311, string:"variant"; 312, identifier:STANDARD_DATAFRAME_COLUMNS; 313, expression_statement; 313, 314; 314, assignment; 314, 315; 314, 316; 315, identifier:genomes; 316, call; 316, 317; 316, 322; 317, attribute; 317, 318; 317, 321; 318, subscript; 318, 319; 318, 320; 319, identifier:df; 320, string:"genome"; 321, identifier:unique; 322, argument_list; 323, if_statement; 323, 324; 323, 330; 324, comparison_operator:>; 324, 325; 324, 329; 325, call; 325, 326; 325, 327; 326, identifier:len; 327, argument_list; 327, 328; 328, identifier:genomes; 329, integer:1; 330, block; 330, 331; 331, raise_statement; 331, 332; 332, call; 332, 333; 332, 334; 333, identifier:ValueError; 334, argument_list; 334, 335; 335, binary_operator:%; 335, 336; 335, 339; 336, concatenated_string; 336, 337; 336, 338; 337, string:"Mixing references is not supported. "; 338, string:"Reference genomes: %s"; 339, parenthesized_expression; 339, 340; 340, call; 340, 341; 340, 344; 341, attribute; 341, 342; 341, 343; 342, string:", "; 343, identifier:join; 344, argument_list; 344, 345; 345, identifier:genomes; 346, expression_statement; 346, 347; 347, assignment; 347, 348; 347, 351; 348, subscript; 348, 349; 348, 350; 349, identifier:df; 350, string:"sources"; 351, list_comprehension; 351, 352; 351, 360; 352, call; 352, 353; 352, 356; 353, attribute; 353, 354; 353, 355; 354, string:" "; 355, identifier:join; 356, argument_list; 356, 357; 357, subscript; 357, 358; 357, 359; 358, identifier:variant_to_sources; 359, identifier:v; 360, for_in_clause; 360, 361; 360, 362; 361, identifier:v; 362, attribute; 362, 363; 362, 364; 363, identifier:df; 364, identifier:variant; 365, if_statement; 365, 366; 365, 369; 366, attribute; 366, 367; 366, 368; 367, identifier:args; 368, identifier:ref; 369, block; 369, 370; 370, expression_statement; 370, 371; 371, assignment; 371, 372; 371, 373; 372, identifier:df; 373, subscript; 373, 374; 373, 377; 374, attribute; 374, 375; 374, 376; 375, identifier:df; 376, identifier:ix; 377, call; 377, 378; 377, 383; 378, attribute; 378, 379; 378, 382; 379, attribute; 379, 380; 379, 381; 380, identifier:df; 381, identifier:ref; 382, identifier:isin; 383, argument_list; 383, 384; 384, attribute; 384, 385; 384, 386; 385, identifier:args; 386, identifier:ref; 387, if_statement; 387, 388; 387, 391; 388, attribute; 388, 389; 388, 390; 389, identifier:args; 390, identifier:alt; 391, block; 391, 392; 392, expression_statement; 392, 393; 393, assignment; 393, 394; 393, 395; 394, identifier:df; 395, subscript; 395, 396; 395, 399; 396, attribute; 396, 397; 396, 398; 397, identifier:df; 398, identifier:ix; 399, call; 399, 400; 399, 405; 400, attribute; 400, 401; 400, 404; 401, attribute; 401, 402; 401, 403; 402, identifier:df; 403, identifier:alt; 404, identifier:isin; 405, argument_list; 405, 406; 406, attribute; 406, 407; 406, 408; 407, identifier:args; 408, identifier:alt; 409, expression_statement; 409, 410; 410, assignment; 410, 411; 410, 412; 411, identifier:loci; 412, call; 412, 413; 412, 416; 413, attribute; 413, 414; 413, 415; 414, identifier:loci_util; 415, identifier:load_from_args; 416, argument_list; 416, 417; 417, call; 417, 418; 417, 421; 418, attribute; 418, 419; 418, 420; 419, identifier:util; 420, identifier:remove_prefix_from_parsed_args; 421, argument_list; 421, 422; 421, 423; 422, identifier:args; 423, string:"variant"; 424, if_statement; 424, 425; 424, 428; 425, comparison_operator:is; 425, 426; 425, 427; 426, identifier:loci; 427, None; 428, block; 428, 429; 429, expression_statement; 429, 430; 430, assignment; 430, 431; 430, 432; 431, identifier:df; 432, subscript; 432, 433; 432, 436; 433, attribute; 433, 434; 433, 435; 434, identifier:df; 435, identifier:ix; 436, list_comprehension; 436, 437; 436, 448; 437, call; 437, 438; 437, 441; 438, attribute; 438, 439; 438, 440; 439, identifier:loci; 440, identifier:intersects; 441, argument_list; 441, 442; 442, call; 442, 443; 442, 446; 443, attribute; 443, 444; 443, 445; 444, identifier:pileup_collection; 445, identifier:to_locus; 446, argument_list; 446, 447; 447, identifier:v; 448, for_in_clause; 448, 449; 448, 450; 449, identifier:v; 450, attribute; 450, 451; 450, 452; 451, identifier:df; 452, identifier:variant; 453, return_statement; 453, 454; 454, identifier:df
def load_from_args_as_dataframe(args): ''' Given parsed variant-loading arguments, return a pandas DataFrame. If no variant loading arguments are specified, return None. ''' if not args.variants and not args.single_variant: return None if args.variant_source_name: variant_source_names = util.expand( args.variant_source_name, 'variant_source_name', 'variant source', len(args.variants)) else: variant_source_names = util.drop_prefix(args.variants) variant_to_sources = collections.defaultdict(list) dfs = [] for i in range(len(args.variants)): name = variant_source_names[i] prefix = ( 'metadata:' if len(args.variants) == 1 else "metadata:%s:" % name) df = load_as_dataframe( args.variants[i], name=name, genome=args.genome, max_variants=args.max_variants_per_source, only_passing=not args.include_failing_variants, metadata_column_prefix=prefix) if df.shape[0] == 0: logging.warn("No variants loaded from: %s" % args.variants[i]) else: for variant in df.variant: variant_to_sources[variant].append(name) dfs.append(df) if args.single_variant: variants = [] extra_args = {} if args.genome: extra_args = { 'ensembl': varcode.reference.infer_genome(args.genome) } for (locus_str, ref, alt) in args.single_variant: locus = Locus.parse(locus_str) variant = varcode.Variant( locus.contig, locus.inclusive_start, ref, alt, **extra_args) variants.append(variant) variant_to_sources[variant].append("commandline") dfs.append(variants_to_dataframe(variants)) df = dfs.pop(0) for other_df in dfs: df = pandas.merge( df, other_df, how='outer', on=["variant"] + STANDARD_DATAFRAME_COLUMNS) genomes = df["genome"].unique() if len(genomes) > 1: raise ValueError( "Mixing references is not supported. " "Reference genomes: %s" % (", ".join(genomes))) df["sources"] = [" ".join(variant_to_sources[v]) for v in df.variant] if args.ref: df = df.ix[df.ref.isin(args.ref)] if args.alt: df = df.ix[df.alt.isin(args.alt)] loci = loci_util.load_from_args( util.remove_prefix_from_parsed_args(args, "variant")) if loci is not None: df = df.ix[[ loci.intersects(pileup_collection.to_locus(v)) for v in df.variant ]] return df
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:protected; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:tests; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 20; 9, 32; 9, 42; 9, 52; 9, 62; 9, 72; 9, 83; 9, 87; 9, 91; 9, 387; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:_role; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:kwargs; 16, identifier:pop; 17, argument_list; 17, 18; 17, 19; 18, string:'role'; 19, None; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:_roles; 23, boolean_operator:or; 23, 24; 23, 31; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:kwargs; 27, identifier:pop; 28, argument_list; 28, 29; 28, 30; 29, string:'roles'; 30, None; 31, list:[]; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:_csrf; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:kwargs; 38, identifier:pop; 39, argument_list; 39, 40; 39, 41; 40, string:'csrf'; 41, None; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:_url_sign_in; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:kwargs; 48, identifier:pop; 49, argument_list; 49, 50; 49, 51; 50, string:'url_sign_in'; 51, None; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:_request; 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:'request'; 61, None; 62, if_statement; 62, 63; 62, 64; 63, identifier:_role; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:_roles; 69, identifier:append; 70, argument_list; 70, 71; 71, identifier:_role; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:_roles; 75, list_comprehension; 75, 76; 75, 80; 76, call; 76, 77; 76, 78; 77, identifier:to_unicode; 78, argument_list; 78, 79; 79, identifier:r; 80, for_in_clause; 80, 81; 80, 82; 81, identifier:r; 82, identifier:_roles; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:_tests; 86, identifier:tests; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:_user_tests; 90, identifier:kwargs; 91, function_definition; 91, 92; 91, 93; 91, 95; 92, function_name:decorator; 93, parameters; 93, 94; 94, identifier:f; 95, block; 95, 96; 95, 385; 96, decorated_definition; 96, 97; 96, 104; 97, decorator; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:functools; 101, identifier:wraps; 102, argument_list; 102, 103; 103, identifier:f; 104, function_definition; 104, 105; 104, 106; 104, 111; 105, function_name:wrapper; 106, parameters; 106, 107; 106, 109; 107, list_splat_pattern; 107, 108; 108, identifier:args; 109, dictionary_splat_pattern; 109, 110; 110, identifier:kwargs; 111, block; 111, 112; 111, 121; 111, 135; 111, 145; 111, 153; 111, 165; 111, 226; 111, 267; 111, 322; 111, 328; 111, 377; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:logger; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:logging; 118, identifier:getLogger; 119, argument_list; 119, 120; 120, identifier:__name__; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:request; 124, boolean_operator:or; 124, 125; 124, 130; 125, boolean_operator:or; 125, 126; 125, 127; 126, identifier:_request; 127, attribute; 127, 128; 127, 129; 128, identifier:self; 129, identifier:request; 130, boolean_operator:and; 130, 131; 130, 132; 131, identifier:args; 132, subscript; 132, 133; 132, 134; 133, identifier:args; 134, integer:0; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:url_sign_in; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:_get_url_sign_in; 142, argument_list; 142, 143; 142, 144; 143, identifier:request; 144, identifier:_url_sign_in; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:user; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:get_user; 152, argument_list; 153, if_statement; 153, 154; 153, 156; 154, not_operator; 154, 155; 155, identifier:user; 156, block; 156, 157; 157, return_statement; 157, 158; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:_login_required; 162, argument_list; 162, 163; 162, 164; 163, identifier:request; 164, identifier:url_sign_in; 165, if_statement; 165, 166; 165, 173; 166, boolean_operator:and; 166, 167; 166, 172; 167, call; 167, 168; 167, 169; 168, identifier:hasattr; 169, argument_list; 169, 170; 169, 171; 170, identifier:user; 171, string:'has_role'; 172, identifier:_roles; 173, block; 173, 174; 174, if_statement; 174, 175; 174, 183; 175, not_operator; 175, 176; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:user; 179, identifier:has_role; 180, argument_list; 180, 181; 181, list_splat; 181, 182; 182, identifier:_roles; 183, block; 183, 184; 183, 198; 183, 218; 184, expression_statement; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:logger; 188, identifier:debug; 189, argument_list; 189, 190; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, string:u'User `{0}`: has_role fail'; 193, identifier:format; 194, argument_list; 194, 195; 195, attribute; 195, 196; 195, 197; 196, identifier:user; 197, identifier:login; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:logger; 202, identifier:debug; 203, argument_list; 203, 204; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, string:u'User roles: {0}'; 207, identifier:format; 208, argument_list; 208, 209; 209, list_comprehension; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:r; 212, identifier:name; 213, for_in_clause; 213, 214; 213, 215; 214, identifier:r; 215, attribute; 215, 216; 215, 217; 216, identifier:user; 217, identifier:roles; 218, return_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:wsgi; 224, identifier:raise_forbidden; 225, argument_list; 226, for_statement; 226, 227; 226, 228; 226, 229; 227, identifier:test; 228, identifier:_tests; 229, block; 229, 230; 229, 241; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:test_pass; 233, call; 233, 234; 233, 235; 234, identifier:test; 235, argument_list; 235, 236; 235, 237; 235, 239; 236, identifier:user; 237, list_splat; 237, 238; 238, identifier:args; 239, dictionary_splat; 239, 240; 240, identifier:kwargs; 241, if_statement; 241, 242; 241, 244; 242, not_operator; 242, 243; 243, identifier:test_pass; 244, block; 244, 245; 244, 259; 245, expression_statement; 245, 246; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:logger; 249, identifier:debug; 250, argument_list; 250, 251; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, string:u'User `{0}`: test fail'; 254, identifier:format; 255, argument_list; 255, 256; 256, attribute; 256, 257; 256, 258; 257, identifier:user; 258, identifier:login; 259, return_statement; 259, 260; 260, call; 260, 261; 260, 266; 261, attribute; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:self; 264, identifier:wsgi; 265, identifier:raise_forbidden; 266, argument_list; 267, for_statement; 267, 268; 267, 271; 267, 276; 268, pattern_list; 268, 269; 268, 270; 269, identifier:name; 270, identifier:value; 271, call; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:_user_tests; 274, identifier:items; 275, argument_list; 276, block; 276, 277; 276, 285; 276, 296; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 280; 279, identifier:user_test; 280, call; 280, 281; 280, 282; 281, identifier:getattr; 282, argument_list; 282, 283; 282, 284; 283, identifier:user; 284, identifier:name; 285, expression_statement; 285, 286; 286, assignment; 286, 287; 286, 288; 287, identifier:test_pass; 288, call; 288, 289; 288, 290; 289, identifier:user_test; 290, argument_list; 290, 291; 290, 292; 290, 294; 291, identifier:value; 292, list_splat; 292, 293; 293, identifier:args; 294, dictionary_splat; 294, 295; 295, identifier:kwargs; 296, if_statement; 296, 297; 296, 299; 297, not_operator; 297, 298; 298, identifier:test_pass; 299, block; 299, 300; 299, 314; 300, expression_statement; 300, 301; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:logger; 304, identifier:debug; 305, argument_list; 305, 306; 306, call; 306, 307; 306, 310; 307, attribute; 307, 308; 307, 309; 308, string:u'User `{0}`: test fail'; 309, identifier:format; 310, argument_list; 310, 311; 311, attribute; 311, 312; 311, 313; 312, identifier:user; 313, identifier:login; 314, return_statement; 314, 315; 315, call; 315, 316; 315, 321; 316, attribute; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:self; 319, identifier:wsgi; 320, identifier:raise_forbidden; 321, argument_list; 322, expression_statement; 322, 323; 323, assignment; 323, 324; 323, 325; 324, identifier:disable_csrf; 325, comparison_operator:==; 325, 326; 325, 327; 326, identifier:_csrf; 327, False; 328, if_statement; 328, 329; 328, 344; 329, boolean_operator:or; 329, 330; 329, 343; 330, parenthesized_expression; 330, 331; 331, boolean_operator:and; 331, 332; 331, 341; 332, not_operator; 332, 333; 333, call; 333, 334; 333, 339; 334, attribute; 334, 335; 334, 338; 335, attribute; 335, 336; 335, 337; 336, identifier:self; 337, identifier:wsgi; 338, identifier:is_idempotent; 339, argument_list; 339, 340; 340, identifier:request; 341, not_operator; 341, 342; 342, identifier:disable_csrf; 343, identifier:_csrf; 344, block; 344, 345; 345, if_statement; 345, 346; 345, 353; 346, not_operator; 346, 347; 347, call; 347, 348; 347, 351; 348, attribute; 348, 349; 348, 350; 349, identifier:self; 350, identifier:csrf_token_is_valid; 351, argument_list; 351, 352; 352, identifier:request; 353, block; 353, 354; 353, 368; 354, expression_statement; 354, 355; 355, call; 355, 356; 355, 359; 356, attribute; 356, 357; 356, 358; 357, identifier:logger; 358, identifier:debug; 359, argument_list; 359, 360; 360, call; 360, 361; 360, 364; 361, attribute; 361, 362; 361, 363; 362, string:u'User `{0}`: invalid CSFR token'; 363, identifier:format; 364, argument_list; 364, 365; 365, attribute; 365, 366; 365, 367; 366, identifier:user; 367, identifier:login; 368, return_statement; 368, 369; 369, call; 369, 370; 369, 375; 370, attribute; 370, 371; 370, 374; 371, attribute; 371, 372; 371, 373; 372, identifier:self; 373, identifier:wsgi; 374, identifier:raise_forbidden; 375, argument_list; 375, 376; 376, string:"CSFR token isn't valid"; 377, return_statement; 377, 378; 378, call; 378, 379; 378, 380; 379, identifier:f; 380, argument_list; 380, 381; 380, 383; 381, list_splat; 381, 382; 382, identifier:args; 383, dictionary_splat; 383, 384; 384, identifier:kwargs; 385, return_statement; 385, 386; 386, identifier:wrapper; 387, return_statement; 387, 388; 388, identifier:decorator
def protected(self, *tests, **kwargs): _role = kwargs.pop('role', None) _roles = kwargs.pop('roles', None) or [] _csrf = kwargs.pop('csrf', None) _url_sign_in = kwargs.pop('url_sign_in', None) _request = kwargs.pop('request', None) if _role: _roles.append(_role) _roles = [to_unicode(r) for r in _roles] _tests = tests _user_tests = kwargs def decorator(f): @functools.wraps(f) def wrapper(*args, **kwargs): logger = logging.getLogger(__name__) request = _request or self.request or args and args[0] url_sign_in = self._get_url_sign_in(request, _url_sign_in) user = self.get_user() if not user: return self._login_required(request, url_sign_in) if hasattr(user, 'has_role') and _roles: if not user.has_role(*_roles): logger.debug(u'User `{0}`: has_role fail'.format(user.login)) logger.debug(u'User roles: {0}'.format([r.name for r in user.roles])) return self.wsgi.raise_forbidden() for test in _tests: test_pass = test(user, *args, **kwargs) if not test_pass: logger.debug(u'User `{0}`: test fail'.format(user.login)) return self.wsgi.raise_forbidden() for name, value in _user_tests.items(): user_test = getattr(user, name) test_pass = user_test(value, *args, **kwargs) if not test_pass: logger.debug(u'User `{0}`: test fail'.format(user.login)) return self.wsgi.raise_forbidden() disable_csrf = _csrf == False if (not self.wsgi.is_idempotent(request) and not disable_csrf) or _csrf: if not self.csrf_token_is_valid(request): logger.debug(u'User `{0}`: invalid CSFR token'.format(user.login)) return self.wsgi.raise_forbidden("CSFR token isn't valid") return f(*args, **kwargs) return wrapper return decorator
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_verify_multi; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:token; 6, identifier:verifying_keys; 7, default_parameter; 7, 8; 7, 9; 8, identifier:num_required; 9, None; 10, block; 10, 11; 10, 22; 10, 34; 10, 44; 10, 60; 10, 74; 10, 98; 10, 114; 10, 118; 10, 179; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 18; 13, pattern_list; 13, 14; 13, 15; 13, 16; 13, 17; 14, identifier:headers; 15, identifier:payload; 16, identifier:raw_signatures; 17, identifier:signing_inputs; 18, call; 18, 19; 18, 20; 19, identifier:_unpack_token_json; 20, argument_list; 20, 21; 21, identifier:token; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:is; 23, 24; 23, 25; 24, identifier:num_required; 25, None; 26, block; 26, 27; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:num_required; 30, call; 30, 31; 30, 32; 31, identifier:len; 32, argument_list; 32, 33; 33, identifier:raw_signatures; 34, if_statement; 34, 35; 34, 41; 35, comparison_operator:>; 35, 36; 35, 37; 36, identifier:num_required; 37, call; 37, 38; 37, 39; 38, identifier:len; 39, argument_list; 39, 40; 40, identifier:verifying_keys; 41, block; 41, 42; 42, return_statement; 42, 43; 43, False; 44, if_statement; 44, 45; 44, 54; 45, comparison_operator:!=; 45, 46; 45, 50; 46, call; 46, 47; 46, 48; 47, identifier:len; 48, argument_list; 48, 49; 49, identifier:headers; 50, call; 50, 51; 50, 52; 51, identifier:len; 52, argument_list; 52, 53; 53, identifier:raw_signatures; 54, block; 54, 55; 55, raise_statement; 55, 56; 56, call; 56, 57; 56, 58; 57, identifier:DecodeError; 58, argument_list; 58, 59; 59, string:'Header/signature mismatch'; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:verifying_keys; 63, list_comprehension; 63, 64; 63, 71; 64, call; 64, 65; 64, 66; 65, identifier:load_verifying_key; 66, argument_list; 66, 67; 66, 68; 67, identifier:vk; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:crypto_backend; 71, for_in_clause; 71, 72; 71, 73; 72, identifier:vk; 73, identifier:verifying_keys; 74, for_statement; 74, 75; 74, 76; 74, 77; 75, identifier:vk; 76, identifier:verifying_keys; 77, block; 77, 78; 78, if_statement; 78, 79; 78, 92; 79, comparison_operator:!=; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:vk; 83, identifier:curve; 84, identifier:name; 85, attribute; 85, 86; 85, 91; 86, attribute; 86, 87; 86, 90; 87, subscript; 87, 88; 87, 89; 88, identifier:verifying_keys; 89, integer:0; 90, identifier:curve; 91, identifier:name; 92, block; 92, 93; 93, raise_statement; 93, 94; 94, call; 94, 95; 94, 96; 95, identifier:DecodeError; 96, argument_list; 96, 97; 97, string:"TODO: only support using keys from one curve per JWT"; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:der_signatures; 101, list_comprehension; 101, 102; 101, 111; 102, call; 102, 103; 102, 104; 103, identifier:raw_to_der_signature; 104, argument_list; 104, 105; 104, 106; 105, identifier:rs; 106, attribute; 106, 107; 106, 110; 107, subscript; 107, 108; 107, 109; 108, identifier:verifying_keys; 109, integer:0; 110, identifier:curve; 111, for_in_clause; 111, 112; 111, 113; 112, identifier:rs; 113, identifier:raw_signatures; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:num_verified; 117, integer:0; 118, for_statement; 118, 119; 118, 122; 118, 127; 119, tuple_pattern; 119, 120; 119, 121; 120, identifier:signing_input; 121, identifier:der_sig; 122, call; 122, 123; 122, 124; 123, identifier:zip; 124, argument_list; 124, 125; 124, 126; 125, identifier:signing_inputs; 126, identifier:der_signatures; 127, block; 127, 128; 127, 173; 128, for_statement; 128, 129; 128, 130; 128, 131; 129, identifier:vk; 130, identifier:verifying_keys; 131, block; 131, 132; 131, 142; 131, 149; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:verifier; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:_get_verifier; 139, argument_list; 139, 140; 139, 141; 140, identifier:vk; 141, identifier:der_sig; 142, expression_statement; 142, 143; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:verifier; 146, identifier:update; 147, argument_list; 147, 148; 148, identifier:signing_input; 149, try_statement; 149, 150; 149, 169; 150, block; 150, 151; 150, 157; 150, 161; 150, 168; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:verifier; 155, identifier:verify; 156, argument_list; 157, expression_statement; 157, 158; 158, augmented_assignment:+=; 158, 159; 158, 160; 159, identifier:num_verified; 160, integer:1; 161, expression_statement; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:verifying_keys; 165, identifier:remove; 166, argument_list; 166, 167; 167, identifier:vk; 168, break_statement; 169, except_clause; 169, 170; 169, 171; 170, identifier:InvalidSignature; 171, block; 171, 172; 172, pass_statement; 173, if_statement; 173, 174; 173, 177; 174, comparison_operator:>=; 174, 175; 174, 176; 175, identifier:num_verified; 176, identifier:num_required; 177, block; 177, 178; 178, break_statement; 179, return_statement; 179, 180; 180, parenthesized_expression; 180, 181; 181, comparison_operator:>=; 181, 182; 181, 183; 182, identifier:num_verified; 183, identifier:num_required
def _verify_multi(self, token, verifying_keys, num_required=None): headers, payload, raw_signatures, signing_inputs = _unpack_token_json(token) if num_required is None: num_required = len(raw_signatures) if num_required > len(verifying_keys): return False if len(headers) != len(raw_signatures): raise DecodeError('Header/signature mismatch') verifying_keys = [load_verifying_key(vk, self.crypto_backend) for vk in verifying_keys] for vk in verifying_keys: if vk.curve.name != verifying_keys[0].curve.name: raise DecodeError("TODO: only support using keys from one curve per JWT") der_signatures = [raw_to_der_signature(rs, verifying_keys[0].curve) for rs in raw_signatures] num_verified = 0 for (signing_input, der_sig) in zip(signing_inputs, der_signatures): for vk in verifying_keys: verifier = self._get_verifier(vk, der_sig) verifier.update(signing_input) try: verifier.verify() num_verified += 1 verifying_keys.remove(vk) break except InvalidSignature: pass if num_verified >= num_required: break return (num_verified >= num_required)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:parse_pic_field; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:l; 5, identifier:c; 6, identifier:last_section_node; 7, identifier:last_vars; 8, identifier:line; 9, block; 9, 10; 9, 14; 9, 23; 9, 27; 9, 50; 9, 95; 9, 105; 9, 118; 9, 131; 9, 162; 9, 210; 9, 223; 9, 270; 9, 276; 9, 296; 9, 311; 9, 318; 9, 324; 9, 338; 9, 354; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:parent_node; 13, None; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:raw_tokens; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:line; 20, identifier:split; 21, argument_list; 21, 22; 22, string:" "; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:tokens; 26, list:[]; 27, for_statement; 27, 28; 27, 29; 27, 30; 28, identifier:t; 29, identifier:raw_tokens; 30, block; 30, 31; 31, if_statement; 31, 32; 31, 42; 32, boolean_operator:and; 32, 33; 32, 39; 33, not_operator; 33, 34; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:t; 37, identifier:isspace; 38, argument_list; 39, comparison_operator:!=; 39, 40; 39, 41; 40, identifier:t; 41, string:""; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:tokens; 47, identifier:append; 48, argument_list; 48, 49; 49, identifier:t; 50, try_statement; 50, 51; 50, 85; 50, 90; 51, block; 51, 52; 51, 79; 52, if_statement; 52, 53; 52, 62; 52, 67; 53, comparison_operator:==; 53, 54; 53, 61; 54, call; 54, 55; 54, 60; 55, attribute; 55, 56; 55, 59; 56, subscript; 56, 57; 56, 58; 57, identifier:tokens; 58, integer:0; 59, identifier:upper; 60, argument_list; 61, string:"FD"; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:lvl; 66, integer:1; 67, else_clause; 67, 68; 68, block; 68, 69; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:lvl; 72, call; 72, 73; 72, 74; 73, identifier:int; 74, argument_list; 74, 75; 74, 78; 75, subscript; 75, 76; 75, 77; 76, identifier:tokens; 77, integer:0; 78, integer:16; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:name; 82, subscript; 82, 83; 82, 84; 83, identifier:tokens; 84, integer:1; 85, except_clause; 85, 86; 85, 87; 86, identifier:ValueError; 87, block; 87, 88; 88, return_statement; 88, 89; 89, None; 90, except_clause; 90, 91; 90, 92; 91, identifier:IndexError; 92, block; 92, 93; 93, return_statement; 93, 94; 94, None; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:name; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:name; 101, identifier:replace; 102, argument_list; 102, 103; 102, 104; 103, string:"."; 104, string:""; 105, if_statement; 105, 106; 105, 115; 106, boolean_operator:or; 106, 107; 106, 110; 107, comparison_operator:in; 107, 108; 107, 109; 108, identifier:name; 109, identifier:ALL_KEYWORDS; 110, comparison_operator:in; 110, 111; 110, 112; 111, identifier:name; 112, list:['-', '/']; 112, 113; 112, 114; 113, string:'-'; 114, string:'/'; 115, block; 115, 116; 116, return_statement; 116, 117; 117, None; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 121; 120, identifier:m; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:re; 124, identifier:findall; 125, argument_list; 125, 126; 125, 127; 125, 128; 126, string:r'pic.*\.'; 127, identifier:line; 128, attribute; 128, 129; 128, 130; 129, identifier:re; 130, identifier:IGNORECASE; 131, if_statement; 131, 132; 131, 133; 131, 156; 132, identifier:m; 133, block; 133, 134; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:description; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, string:' '; 140, identifier:join; 141, argument_list; 141, 142; 142, list_comprehension; 142, 143; 142, 144; 142, 154; 143, identifier:t; 144, for_in_clause; 144, 145; 144, 146; 145, identifier:t; 146, call; 146, 147; 146, 152; 147, attribute; 147, 148; 147, 151; 148, subscript; 148, 149; 148, 150; 149, identifier:m; 150, integer:0; 151, identifier:split; 152, argument_list; 152, 153; 153, string:' '; 154, if_clause; 154, 155; 155, identifier:t; 156, else_clause; 156, 157; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:description; 161, identifier:line; 162, try_statement; 162, 163; 162, 177; 162, 190; 163, block; 163, 164; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:index; 167, call; 167, 168; 167, 175; 168, attribute; 168, 169; 168, 174; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:description; 172, identifier:lower; 173, argument_list; 174, identifier:index; 175, argument_list; 175, 176; 176, string:'value'; 177, except_clause; 177, 178; 177, 179; 178, identifier:ValueError; 179, block; 179, 180; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:description; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:description; 186, identifier:replace; 187, argument_list; 187, 188; 187, 189; 188, string:'.'; 189, string:''; 190, else_clause; 190, 191; 191, block; 191, 192; 192, expression_statement; 192, 193; 193, assignment; 193, 194; 193, 195; 194, identifier:description; 195, subscript; 195, 196; 195, 207; 196, call; 196, 197; 196, 204; 197, attribute; 197, 198; 197, 203; 198, subscript; 198, 199; 198, 200; 199, identifier:description; 200, slice; 200, 201; 200, 202; 201, identifier:index; 202, colon; 203, identifier:replace; 204, argument_list; 204, 205; 204, 206; 205, string:'value'; 206, string:''; 207, slice; 207, 208; 207, 209; 208, colon; 209, integer:80; 210, if_statement; 210, 211; 210, 218; 211, comparison_operator:==; 211, 212; 211, 213; 212, identifier:lvl; 213, call; 213, 214; 213, 215; 214, identifier:int; 215, argument_list; 215, 216; 215, 217; 216, string:'78'; 217, integer:16; 218, block; 218, 219; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 222; 221, identifier:lvl; 222, integer:1; 223, if_statement; 223, 224; 223, 227; 223, 238; 224, comparison_operator:==; 224, 225; 224, 226; 225, identifier:lvl; 226, integer:1; 227, block; 227, 228; 227, 232; 228, expression_statement; 228, 229; 229, assignment; 229, 230; 229, 231; 230, identifier:parent_node; 231, identifier:last_section_node; 232, expression_statement; 232, 233; 233, call; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:last_vars; 236, identifier:clear; 237, argument_list; 238, else_clause; 238, 239; 239, block; 239, 240; 239, 254; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 243; 242, identifier:levels; 243, call; 243, 244; 243, 245; 244, identifier:sorted; 245, argument_list; 245, 246; 245, 251; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:last_vars; 249, identifier:keys; 250, argument_list; 251, keyword_argument; 251, 252; 251, 253; 252, identifier:reverse; 253, True; 254, for_statement; 254, 255; 254, 256; 254, 257; 255, identifier:lv; 256, identifier:levels; 257, block; 257, 258; 258, if_statement; 258, 259; 258, 262; 259, comparison_operator:<; 259, 260; 259, 261; 260, identifier:lv; 261, identifier:lvl; 262, block; 262, 263; 262, 269; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:parent_node; 266, subscript; 266, 267; 266, 268; 267, identifier:last_vars; 268, identifier:lv; 269, break_statement; 270, if_statement; 270, 271; 270, 273; 271, not_operator; 271, 272; 272, identifier:parent_node; 273, block; 273, 274; 274, return_statement; 274, 275; 275, None; 276, if_statement; 276, 277; 276, 291; 277, boolean_operator:or; 277, 278; 277, 280; 278, not_operator; 278, 279; 279, identifier:name; 280, comparison_operator:==; 280, 281; 280, 290; 281, call; 281, 282; 281, 289; 282, attribute; 282, 283; 282, 288; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:name; 286, identifier:upper; 287, argument_list; 288, identifier:strip; 289, argument_list; 290, string:'PIC'; 291, block; 291, 292; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 295; 294, identifier:name; 295, string:'FILLER'; 296, expression_statement; 296, 297; 297, assignment; 297, 298; 297, 299; 298, identifier:node; 299, call; 299, 300; 299, 301; 300, identifier:Name; 301, argument_list; 301, 302; 301, 307; 301, 308; 301, 309; 301, 310; 302, attribute; 302, 303; 302, 306; 303, attribute; 303, 304; 303, 305; 304, identifier:Name; 305, identifier:Type; 306, identifier:Variable; 307, identifier:l; 308, identifier:c; 309, identifier:name; 310, identifier:description; 311, expression_statement; 311, 312; 312, call; 312, 313; 312, 316; 313, attribute; 313, 314; 313, 315; 314, identifier:parent_node; 315, identifier:add_child; 316, argument_list; 316, 317; 317, identifier:node; 318, expression_statement; 318, 319; 319, assignment; 319, 320; 319, 323; 320, subscript; 320, 321; 320, 322; 321, identifier:last_vars; 322, identifier:lvl; 323, identifier:node; 324, expression_statement; 324, 325; 325, assignment; 325, 326; 325, 327; 326, identifier:levels; 327, call; 327, 328; 327, 329; 328, identifier:sorted; 329, argument_list; 329, 330; 329, 335; 330, call; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:last_vars; 333, identifier:keys; 334, argument_list; 335, keyword_argument; 335, 336; 335, 337; 336, identifier:reverse; 337, True; 338, for_statement; 338, 339; 338, 340; 338, 341; 339, identifier:l; 340, identifier:levels; 341, block; 341, 342; 342, if_statement; 342, 343; 342, 346; 343, comparison_operator:>; 343, 344; 343, 345; 344, identifier:l; 345, identifier:lvl; 346, block; 346, 347; 347, expression_statement; 347, 348; 348, call; 348, 349; 348, 352; 349, attribute; 349, 350; 349, 351; 350, identifier:last_vars; 351, identifier:pop; 352, argument_list; 352, 353; 353, identifier:l; 354, return_statement; 354, 355; 355, identifier:node
def parse_pic_field(l, c, last_section_node, last_vars, line): parent_node = None raw_tokens = line.split(" ") tokens = [] for t in raw_tokens: if not t.isspace() and t != "": tokens.append(t) try: if tokens[0].upper() == "FD": lvl = 1 else: lvl = int(tokens[0], 16) name = tokens[1] except ValueError: return None except IndexError: return None name = name.replace(".", "") if name in ALL_KEYWORDS or name in ['-', '/']: return None m = re.findall(r'pic.*\.', line, re.IGNORECASE) if m: description = ' '.join([t for t in m[0].split(' ') if t]) else: description = line try: index = description.lower().index('value') except ValueError: description = description.replace('.', '') else: description = description[index:].replace('value', '')[:80] if lvl == int('78', 16): lvl = 1 if lvl == 1: parent_node = last_section_node last_vars.clear() else: levels = sorted(last_vars.keys(), reverse=True) for lv in levels: if lv < lvl: parent_node = last_vars[lv] break if not parent_node: return None if not name or name.upper().strip() == 'PIC': name = 'FILLER' node = Name(Name.Type.Variable, l, c, name, description) parent_node.add_child(node) last_vars[lvl] = node levels = sorted(last_vars.keys(), reverse=True) for l in levels: if l > lvl: last_vars.pop(l) return node
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:getgrouploansurl; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:idgroup; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 14; 9, 69; 9, 75; 9, 109; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:getparams; 13, list:[]; 14, if_statement; 14, 15; 14, 16; 15, identifier:kwargs; 16, block; 16, 17; 16, 49; 17, try_statement; 17, 18; 17, 42; 18, block; 18, 19; 19, if_statement; 19, 20; 19, 25; 19, 33; 20, comparison_operator:==; 20, 21; 20, 24; 21, subscript; 21, 22; 21, 23; 22, identifier:kwargs; 23, string:"fullDetails"; 24, True; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:getparams; 30, identifier:append; 31, argument_list; 31, 32; 32, string:"fullDetails=true"; 33, else_clause; 33, 34; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:getparams; 39, identifier:append; 40, argument_list; 40, 41; 41, string:"fullDetails=false"; 42, except_clause; 42, 43; 42, 47; 43, as_pattern; 43, 44; 43, 45; 44, identifier:Exception; 45, as_pattern_target; 45, 46; 46, identifier:ex; 47, block; 47, 48; 48, pass_statement; 49, try_statement; 49, 50; 49, 62; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:getparams; 55, identifier:append; 56, argument_list; 56, 57; 57, binary_operator:%; 57, 58; 57, 59; 58, string:"accountState=%s"; 59, subscript; 59, 60; 59, 61; 60, identifier:kwargs; 61, string:"accountState"; 62, except_clause; 62, 63; 62, 67; 63, as_pattern; 63, 64; 63, 65; 64, identifier:Exception; 65, as_pattern_target; 65, 66; 66, identifier:ex; 67, block; 67, 68; 68, pass_statement; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:groupidparam; 72, binary_operator:+; 72, 73; 72, 74; 73, string:"/"; 74, identifier:idgroup; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:url; 78, binary_operator:+; 78, 79; 78, 92; 79, binary_operator:+; 79, 80; 79, 91; 80, binary_operator:+; 80, 81; 80, 90; 81, binary_operator:+; 81, 82; 81, 89; 82, call; 82, 83; 82, 84; 83, identifier:getmambuurl; 84, argument_list; 84, 85; 84, 87; 85, list_splat; 85, 86; 86, identifier:args; 87, dictionary_splat; 87, 88; 88, identifier:kwargs; 89, string:"groups"; 90, identifier:groupidparam; 91, string:"/loans"; 92, parenthesized_expression; 92, 93; 93, conditional_expression:if; 93, 94; 93, 95; 93, 101; 94, string:""; 95, comparison_operator:==; 95, 96; 95, 100; 96, call; 96, 97; 96, 98; 97, identifier:len; 98, argument_list; 98, 99; 99, identifier:getparams; 100, integer:0; 101, binary_operator:+; 101, 102; 101, 103; 102, string:"?"; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, string:"&"; 106, identifier:join; 107, argument_list; 107, 108; 108, identifier:getparams; 109, return_statement; 109, 110; 110, identifier:url
def getgrouploansurl(idgroup, *args, **kwargs): getparams = [] if kwargs: try: if kwargs["fullDetails"] == True: getparams.append("fullDetails=true") else: getparams.append("fullDetails=false") except Exception as ex: pass try: getparams.append("accountState=%s" % kwargs["accountState"]) except Exception as ex: pass groupidparam = "/" + idgroup url = getmambuurl(*args,**kwargs) + "groups" + groupidparam + "/loans" + ( "" if len(getparams) == 0 else "?" + "&".join(getparams) ) return url
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:getclientloansurl; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:idclient; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 14; 9, 69; 9, 75; 9, 109; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:getparams; 13, list:[]; 14, if_statement; 14, 15; 14, 16; 15, identifier:kwargs; 16, block; 16, 17; 16, 49; 17, try_statement; 17, 18; 17, 42; 18, block; 18, 19; 19, if_statement; 19, 20; 19, 25; 19, 33; 20, comparison_operator:==; 20, 21; 20, 24; 21, subscript; 21, 22; 21, 23; 22, identifier:kwargs; 23, string:"fullDetails"; 24, True; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:getparams; 30, identifier:append; 31, argument_list; 31, 32; 32, string:"fullDetails=true"; 33, else_clause; 33, 34; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:getparams; 39, identifier:append; 40, argument_list; 40, 41; 41, string:"fullDetails=false"; 42, except_clause; 42, 43; 42, 47; 43, as_pattern; 43, 44; 43, 45; 44, identifier:Exception; 45, as_pattern_target; 45, 46; 46, identifier:ex; 47, block; 47, 48; 48, pass_statement; 49, try_statement; 49, 50; 49, 62; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:getparams; 55, identifier:append; 56, argument_list; 56, 57; 57, binary_operator:%; 57, 58; 57, 59; 58, string:"accountState=%s"; 59, subscript; 59, 60; 59, 61; 60, identifier:kwargs; 61, string:"accountState"; 62, except_clause; 62, 63; 62, 67; 63, as_pattern; 63, 64; 63, 65; 64, identifier:Exception; 65, as_pattern_target; 65, 66; 66, identifier:ex; 67, block; 67, 68; 68, pass_statement; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:clientidparam; 72, binary_operator:+; 72, 73; 72, 74; 73, string:"/"; 74, identifier:idclient; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:url; 78, binary_operator:+; 78, 79; 78, 92; 79, binary_operator:+; 79, 80; 79, 91; 80, binary_operator:+; 80, 81; 80, 90; 81, binary_operator:+; 81, 82; 81, 89; 82, call; 82, 83; 82, 84; 83, identifier:getmambuurl; 84, argument_list; 84, 85; 84, 87; 85, list_splat; 85, 86; 86, identifier:args; 87, dictionary_splat; 87, 88; 88, identifier:kwargs; 89, string:"clients"; 90, identifier:clientidparam; 91, string:"/loans"; 92, parenthesized_expression; 92, 93; 93, conditional_expression:if; 93, 94; 93, 95; 93, 101; 94, string:""; 95, comparison_operator:==; 95, 96; 95, 100; 96, call; 96, 97; 96, 98; 97, identifier:len; 98, argument_list; 98, 99; 99, identifier:getparams; 100, integer:0; 101, binary_operator:+; 101, 102; 101, 103; 102, string:"?"; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, string:"&"; 106, identifier:join; 107, argument_list; 107, 108; 108, identifier:getparams; 109, return_statement; 109, 110; 110, identifier:url
def getclientloansurl(idclient, *args, **kwargs): getparams = [] if kwargs: try: if kwargs["fullDetails"] == True: getparams.append("fullDetails=true") else: getparams.append("fullDetails=false") except Exception as ex: pass try: getparams.append("accountState=%s" % kwargs["accountState"]) except Exception as ex: pass clientidparam = "/" + idclient url = getmambuurl(*args,**kwargs) + "clients" + clientidparam + "/loans" + ( "" if len(getparams) == 0 else "?" + "&".join(getparams) ) return url
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:backup_db; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 9; 4, identifier:callback; 5, identifier:bool_func; 6, identifier:output_fname; 7, list_splat_pattern; 7, 8; 8, identifier:args; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, 12; 11, 17; 11, 32; 11, 48; 11, 66; 11, 101; 11, 111; 11, 121; 11, 128; 11, 226; 11, 264; 11, 270; 11, 313; 11, 365; 11, 370; 11, 385; 11, 405; 11, 419; 11, 457; 11, 473; 11, 494; 11, 510; 12, import_from_statement; 12, 13; 12, 15; 13, dotted_name; 13, 14; 14, identifier:datetime; 15, dotted_name; 15, 16; 16, identifier:datetime; 17, try_statement; 17, 18; 17, 25; 18, block; 18, 19; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:verbose; 22, subscript; 22, 23; 22, 24; 23, identifier:kwargs; 24, string:'verbose'; 25, except_clause; 25, 26; 25, 27; 26, identifier:KeyError; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:verbose; 31, False; 32, try_statement; 32, 33; 32, 40; 33, block; 33, 34; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:retries; 37, subscript; 37, 38; 37, 39; 38, identifier:kwargs; 39, string:'retries'; 40, except_clause; 40, 41; 40, 42; 41, identifier:KeyError; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:retries; 46, unary_operator:-; 46, 47; 47, integer:1; 48, try_statement; 48, 49; 48, 59; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:force_download_latest; 53, call; 53, 54; 53, 55; 54, identifier:bool; 55, argument_list; 55, 56; 56, subscript; 56, 57; 56, 58; 57, identifier:kwargs; 58, string:'force_download_latest'; 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:force_download_latest; 65, False; 66, if_statement; 66, 67; 66, 68; 67, identifier:verbose; 68, block; 68, 69; 68, 77; 68, 95; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:log; 72, call; 72, 73; 72, 74; 73, identifier:open; 74, argument_list; 74, 75; 74, 76; 75, string:'/tmp/log_mambu_backup'; 76, string:'a'; 77, expression_statement; 77, 78; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:log; 81, identifier:write; 82, argument_list; 82, 83; 83, binary_operator:+; 83, 84; 83, 94; 84, call; 84, 85; 84, 92; 85, attribute; 85, 86; 85, 91; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:datetime; 89, identifier:now; 90, argument_list; 91, identifier:strftime; 92, argument_list; 92, 93; 93, string:'%Y-%m-%d %H:%M:%S'; 94, string:" - Mambu DB Backup\n"; 95, expression_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:log; 99, identifier:flush; 100, argument_list; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:user; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:kwargs; 107, identifier:pop; 108, argument_list; 108, 109; 108, 110; 109, string:'user'; 110, identifier:apiuser; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:pwd; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:kwargs; 117, identifier:pop; 118, argument_list; 118, 119; 118, 120; 119, string:'pwd'; 120, identifier:apipwd; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:data; 124, dictionary; 124, 125; 125, pair; 125, 126; 125, 127; 126, string:'callback'; 127, identifier:callback; 128, try_statement; 128, 129; 128, 188; 129, block; 129, 130; 129, 145; 129, 165; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:posturl; 133, call; 133, 134; 133, 135; 134, identifier:iriToUri; 135, argument_list; 135, 136; 136, binary_operator:+; 136, 137; 136, 144; 137, call; 137, 138; 137, 139; 138, identifier:getmambuurl; 139, argument_list; 139, 140; 139, 142; 140, list_splat; 140, 141; 141, identifier:args; 142, dictionary_splat; 142, 143; 143, identifier:kwargs; 144, string:"database/backup"; 145, if_statement; 145, 146; 145, 147; 146, identifier:verbose; 147, block; 147, 148; 147, 159; 148, expression_statement; 148, 149; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:log; 152, identifier:write; 153, argument_list; 153, 154; 154, binary_operator:+; 154, 155; 154, 158; 155, binary_operator:+; 155, 156; 155, 157; 156, string:"open url: "; 157, identifier:posturl; 158, string:"\n"; 159, expression_statement; 159, 160; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:log; 163, identifier:flush; 164, argument_list; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:resp; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:requests; 171, identifier:post; 172, argument_list; 172, 173; 172, 174; 172, 177; 172, 183; 173, identifier:posturl; 174, keyword_argument; 174, 175; 174, 176; 175, identifier:data; 176, identifier:data; 177, keyword_argument; 177, 178; 177, 179; 178, identifier:headers; 179, dictionary; 179, 180; 180, pair; 180, 181; 180, 182; 181, string:'content-type'; 182, string:'application/json'; 183, keyword_argument; 183, 184; 183, 185; 184, identifier:auth; 185, tuple; 185, 186; 185, 187; 186, identifier:apiuser; 187, identifier:apipwd; 188, except_clause; 188, 189; 188, 193; 189, as_pattern; 189, 190; 189, 191; 190, identifier:Exception; 191, as_pattern_target; 191, 192; 192, identifier:ex; 193, block; 193, 194; 193, 203; 193, 221; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:mess; 197, binary_operator:%; 197, 198; 197, 199; 198, string:"Error requesting backup: %s"; 199, call; 199, 200; 199, 201; 200, identifier:repr; 201, argument_list; 201, 202; 202, identifier:ex; 203, if_statement; 203, 204; 203, 205; 204, identifier:verbose; 205, block; 205, 206; 205, 215; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:log; 210, identifier:write; 211, argument_list; 211, 212; 212, binary_operator:+; 212, 213; 212, 214; 213, identifier:mess; 214, string:"\n"; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:log; 219, identifier:close; 220, argument_list; 221, raise_statement; 221, 222; 222, call; 222, 223; 222, 224; 223, identifier:MambuError; 224, argument_list; 224, 225; 225, identifier:mess; 226, if_statement; 226, 227; 226, 232; 227, comparison_operator:!=; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:resp; 230, identifier:status_code; 231, integer:200; 232, block; 232, 233; 232, 241; 232, 259; 233, expression_statement; 233, 234; 234, assignment; 234, 235; 234, 236; 235, identifier:mess; 236, binary_operator:%; 236, 237; 236, 238; 237, string:"Error posting request for backup: %s"; 238, attribute; 238, 239; 238, 240; 239, identifier:resp; 240, identifier:content; 241, if_statement; 241, 242; 241, 243; 242, identifier:verbose; 243, block; 243, 244; 243, 253; 244, expression_statement; 244, 245; 245, call; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, identifier:log; 248, identifier:write; 249, argument_list; 249, 250; 250, binary_operator:+; 250, 251; 250, 252; 251, identifier:mess; 252, string:"\n"; 253, expression_statement; 253, 254; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:log; 257, identifier:close; 258, argument_list; 259, raise_statement; 259, 260; 260, call; 260, 261; 260, 262; 261, identifier:MambuCommError; 262, argument_list; 262, 263; 263, identifier:mess; 264, expression_statement; 264, 265; 265, assignment; 265, 266; 265, 269; 266, subscript; 266, 267; 266, 268; 267, identifier:data; 268, string:'latest'; 269, True; 270, while_statement; 270, 271; 270, 277; 271, boolean_operator:and; 271, 272; 271, 273; 272, identifier:retries; 273, not_operator; 273, 274; 274, call; 274, 275; 274, 276; 275, identifier:bool_func; 276, argument_list; 277, block; 277, 278; 277, 294; 277, 299; 277, 303; 278, if_statement; 278, 279; 278, 280; 279, identifier:verbose; 280, block; 280, 281; 280, 288; 281, expression_statement; 281, 282; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:log; 285, identifier:write; 286, argument_list; 286, 287; 287, string:"waiting...\n"; 288, expression_statement; 288, 289; 289, call; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:log; 292, identifier:flush; 293, argument_list; 294, expression_statement; 294, 295; 295, call; 295, 296; 295, 297; 296, identifier:sleep; 297, argument_list; 297, 298; 298, integer:10; 299, expression_statement; 299, 300; 300, augmented_assignment:-=; 300, 301; 300, 302; 301, identifier:retries; 302, integer:1; 303, if_statement; 303, 304; 303, 307; 304, comparison_operator:<; 304, 305; 304, 306; 305, identifier:retries; 306, integer:0; 307, block; 307, 308; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:retries; 311, unary_operator:-; 311, 312; 312, integer:1; 313, if_statement; 313, 314; 313, 316; 314, not_operator; 314, 315; 315, identifier:retries; 316, block; 316, 317; 316, 321; 316, 339; 317, expression_statement; 317, 318; 318, assignment; 318, 319; 318, 320; 319, identifier:mess; 320, string:"Tired of waiting, giving up..."; 321, if_statement; 321, 322; 321, 323; 322, identifier:verbose; 323, block; 323, 324; 323, 333; 324, expression_statement; 324, 325; 325, call; 325, 326; 325, 329; 326, attribute; 326, 327; 326, 328; 327, identifier:log; 328, identifier:write; 329, argument_list; 329, 330; 330, binary_operator:+; 330, 331; 330, 332; 331, identifier:mess; 332, string:"\n"; 333, expression_statement; 333, 334; 334, call; 334, 335; 334, 338; 335, attribute; 335, 336; 335, 337; 336, identifier:log; 337, identifier:flush; 338, argument_list; 339, if_statement; 339, 340; 339, 342; 339, 357; 340, not_operator; 340, 341; 341, identifier:force_download_latest; 342, block; 342, 343; 342, 352; 343, if_statement; 343, 344; 343, 345; 344, identifier:verbose; 345, block; 345, 346; 346, expression_statement; 346, 347; 347, call; 347, 348; 347, 351; 348, attribute; 348, 349; 348, 350; 349, identifier:log; 350, identifier:close; 351, argument_list; 352, raise_statement; 352, 353; 353, call; 353, 354; 353, 355; 354, identifier:MambuError; 355, argument_list; 355, 356; 356, identifier:mess; 357, else_clause; 357, 358; 358, block; 358, 359; 359, expression_statement; 359, 360; 360, assignment; 360, 361; 360, 364; 361, subscript; 361, 362; 361, 363; 362, identifier:data; 363, string:'latest'; 364, False; 365, expression_statement; 365, 366; 366, call; 366, 367; 366, 368; 367, identifier:sleep; 368, argument_list; 368, 369; 369, integer:30; 370, expression_statement; 370, 371; 371, assignment; 371, 372; 371, 373; 372, identifier:geturl; 373, call; 373, 374; 373, 375; 374, identifier:iriToUri; 375, argument_list; 375, 376; 376, binary_operator:+; 376, 377; 376, 384; 377, call; 377, 378; 377, 379; 378, identifier:getmambuurl; 379, argument_list; 379, 380; 379, 382; 380, list_splat; 380, 381; 381, identifier:args; 382, dictionary_splat; 382, 383; 383, identifier:kwargs; 384, string:"database/backup/LATEST"; 385, if_statement; 385, 386; 385, 387; 386, identifier:verbose; 387, block; 387, 388; 387, 399; 388, expression_statement; 388, 389; 389, call; 389, 390; 389, 393; 390, attribute; 390, 391; 390, 392; 391, identifier:log; 392, identifier:write; 393, argument_list; 393, 394; 394, binary_operator:+; 394, 395; 394, 398; 395, binary_operator:+; 395, 396; 395, 397; 396, string:"open url: "; 397, identifier:geturl; 398, string:"\n"; 399, expression_statement; 399, 400; 400, call; 400, 401; 400, 404; 401, attribute; 401, 402; 401, 403; 402, identifier:log; 403, identifier:flush; 404, argument_list; 405, expression_statement; 405, 406; 406, assignment; 406, 407; 406, 408; 407, identifier:resp; 408, call; 408, 409; 408, 412; 409, attribute; 409, 410; 409, 411; 410, identifier:requests; 411, identifier:get; 412, argument_list; 412, 413; 412, 414; 413, identifier:geturl; 414, keyword_argument; 414, 415; 414, 416; 415, identifier:auth; 416, tuple; 416, 417; 416, 418; 417, identifier:apiuser; 418, identifier:apipwd; 419, if_statement; 419, 420; 419, 425; 420, comparison_operator:!=; 420, 421; 420, 424; 421, attribute; 421, 422; 421, 423; 422, identifier:resp; 423, identifier:status_code; 424, integer:200; 425, block; 425, 426; 425, 434; 425, 452; 426, expression_statement; 426, 427; 427, assignment; 427, 428; 427, 429; 428, identifier:mess; 429, binary_operator:%; 429, 430; 429, 431; 430, string:"Error getting database backup: %s"; 431, attribute; 431, 432; 431, 433; 432, identifier:resp; 433, identifier:content; 434, if_statement; 434, 435; 434, 436; 435, identifier:verbose; 436, block; 436, 437; 436, 446; 437, expression_statement; 437, 438; 438, call; 438, 439; 438, 442; 439, attribute; 439, 440; 439, 441; 440, identifier:log; 441, identifier:write; 442, argument_list; 442, 443; 443, binary_operator:+; 443, 444; 443, 445; 444, identifier:mess; 445, string:"\n"; 446, expression_statement; 446, 447; 447, call; 447, 448; 447, 451; 448, attribute; 448, 449; 448, 450; 449, identifier:log; 450, identifier:close; 451, argument_list; 452, raise_statement; 452, 453; 453, call; 453, 454; 453, 455; 454, identifier:MambuCommError; 455, argument_list; 455, 456; 456, identifier:mess; 457, if_statement; 457, 458; 457, 459; 458, identifier:verbose; 459, block; 459, 460; 459, 467; 460, expression_statement; 460, 461; 461, call; 461, 462; 461, 465; 462, attribute; 462, 463; 462, 464; 463, identifier:log; 464, identifier:write; 465, argument_list; 465, 466; 466, string:"saving...\n"; 467, expression_statement; 467, 468; 468, call; 468, 469; 468, 472; 469, attribute; 469, 470; 469, 471; 470, identifier:log; 471, identifier:flush; 472, argument_list; 473, with_statement; 473, 474; 473, 484; 474, with_clause; 474, 475; 475, with_item; 475, 476; 476, as_pattern; 476, 477; 476, 482; 477, call; 477, 478; 477, 479; 478, identifier:open; 479, argument_list; 479, 480; 479, 481; 480, identifier:output_fname; 481, string:"w"; 482, as_pattern_target; 482, 483; 483, identifier:fw; 484, block; 484, 485; 485, expression_statement; 485, 486; 486, call; 486, 487; 486, 490; 487, attribute; 487, 488; 487, 489; 488, identifier:fw; 489, identifier:write; 490, argument_list; 490, 491; 491, attribute; 491, 492; 491, 493; 492, identifier:resp; 493, identifier:content; 494, if_statement; 494, 495; 494, 496; 495, identifier:verbose; 496, block; 496, 497; 496, 504; 497, expression_statement; 497, 498; 498, call; 498, 499; 498, 502; 499, attribute; 499, 500; 499, 501; 500, identifier:log; 501, identifier:write; 502, argument_list; 502, 503; 503, string:"DONE!\n"; 504, expression_statement; 504, 505; 505, call; 505, 506; 505, 509; 506, attribute; 506, 507; 506, 508; 507, identifier:log; 508, identifier:close; 509, argument_list; 510, return_statement; 510, 511; 511, identifier:data
def backup_db(callback, bool_func, output_fname, *args, **kwargs): from datetime import datetime try: verbose = kwargs['verbose'] except KeyError: verbose = False try: retries = kwargs['retries'] except KeyError: retries = -1 try: force_download_latest = bool(kwargs['force_download_latest']) except KeyError: force_download_latest = False if verbose: log = open('/tmp/log_mambu_backup','a') log.write(datetime.now().strftime('%Y-%m-%d %H:%M:%S') + " - Mambu DB Backup\n") log.flush() user = kwargs.pop('user', apiuser) pwd = kwargs.pop('pwd', apipwd) data = {'callback' : callback} try: posturl = iriToUri(getmambuurl(*args, **kwargs) + "database/backup") if verbose: log.write("open url: "+posturl+"\n") log.flush() resp = requests.post(posturl, data=data, headers={'content-type': 'application/json'}, auth=(apiuser, apipwd)) except Exception as ex: mess = "Error requesting backup: %s" % repr(ex) if verbose: log.write(mess + "\n") log.close() raise MambuError(mess) if resp.status_code != 200: mess = "Error posting request for backup: %s" % resp.content if verbose: log.write(mess + "\n") log.close() raise MambuCommError(mess) data['latest'] = True while retries and not bool_func(): if verbose: log.write("waiting...\n") log.flush() sleep(10) retries -= 1 if retries < 0: retries = -1 if not retries: mess = "Tired of waiting, giving up..." if verbose: log.write(mess + "\n") log.flush() if not force_download_latest: if verbose: log.close() raise MambuError(mess) else: data['latest'] = False sleep(30) geturl = iriToUri(getmambuurl(*args, **kwargs) + "database/backup/LATEST") if verbose: log.write("open url: "+geturl+"\n") log.flush() resp = requests.get(geturl, auth=(apiuser, apipwd)) if resp.status_code != 200: mess = "Error getting database backup: %s" % resp.content if verbose: log.write(mess + "\n") log.close() raise MambuCommError(mess) if verbose: log.write("saving...\n") log.flush() with open(output_fname, "w") as fw: fw.write(resp.content) if verbose: log.write("DONE!\n") log.close() return data
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:send; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:stack; 7, type; 7, 8; 8, identifier:Layers; 9, block; 9, 10; 9, 25; 9, 96; 9, 135; 9, 188; 9, 224; 10, if_statement; 10, 11; 10, 17; 11, not_operator; 11, 12; 12, call; 12, 13; 12, 14; 13, identifier:isinstance; 14, argument_list; 14, 15; 14, 16; 15, identifier:stack; 16, identifier:Stack; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:stack; 21, call; 21, 22; 21, 23; 22, identifier:Stack; 23, argument_list; 23, 24; 24, identifier:stack; 25, if_statement; 25, 26; 25, 38; 26, boolean_operator:and; 26, 27; 26, 32; 27, comparison_operator:in; 27, 28; 27, 29; 28, string:'callback_query'; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:_update; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:stack; 35, identifier:has_layer; 36, argument_list; 36, 37; 37, identifier:Update; 38, block; 38, 39; 38, 48; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:layer; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:stack; 45, identifier:get_layer; 46, argument_list; 46, 47; 47, identifier:Update; 48, try_statement; 48, 49; 48, 60; 48, 76; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:msg; 53, subscript; 53, 54; 53, 59; 54, subscript; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:_update; 58, string:'callback_query'; 59, string:'message'; 60, except_clause; 60, 61; 60, 62; 61, identifier:KeyError; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 68; 64, 69; 65, attribute; 65, 66; 65, 67; 66, identifier:layer; 67, identifier:inline_message_id; 68, line_continuation:\; 69, subscript; 69, 70; 69, 75; 70, subscript; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:_update; 74, string:'callback_query'; 75, string:'inline_message_id'; 76, else_clause; 76, 77; 77, block; 77, 78; 77, 88; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:layer; 82, identifier:chat_id; 83, subscript; 83, 84; 83, 87; 84, subscript; 84, 85; 84, 86; 85, identifier:msg; 86, string:'chat'; 87, string:'id'; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:layer; 92, identifier:message_id; 93, subscript; 93, 94; 93, 95; 94, identifier:msg; 95, string:'message_id'; 96, if_statement; 96, 97; 96, 103; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:stack; 100, identifier:has_layer; 101, argument_list; 101, 102; 102, identifier:AnswerCallbackQuery; 103, block; 103, 104; 103, 115; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:_acq; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:stack; 112, identifier:get_layer; 113, argument_list; 113, 114; 114, identifier:AnswerCallbackQuery; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:stack; 118, call; 118, 119; 118, 120; 119, identifier:Stack; 120, argument_list; 120, 121; 121, list_comprehension; 121, 122; 121, 123; 121, 128; 122, identifier:l; 123, for_in_clause; 123, 124; 123, 125; 124, identifier:l; 125, attribute; 125, 126; 125, 127; 126, identifier:stack; 127, identifier:layers; 128, if_clause; 128, 129; 129, not_operator; 129, 130; 130, call; 130, 131; 130, 132; 131, identifier:isinstance; 132, argument_list; 132, 133; 132, 134; 133, identifier:l; 134, identifier:AnswerCallbackQuery; 135, if_statement; 135, 136; 135, 142; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:stack; 139, identifier:has_layer; 140, argument_list; 140, 141; 141, identifier:Reply; 142, block; 142, 143; 142, 152; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 146; 145, identifier:layer; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:stack; 149, identifier:get_layer; 150, argument_list; 150, 151; 151, identifier:Reply; 152, if_statement; 152, 153; 152, 158; 152, 169; 153, comparison_operator:in; 153, 154; 153, 155; 154, string:'message'; 155, attribute; 155, 156; 155, 157; 156, identifier:self; 157, identifier:_update; 158, block; 158, 159; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:layer; 163, identifier:message; 164, subscript; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:_update; 168, string:'message'; 169, elif_clause; 169, 170; 169, 175; 170, comparison_operator:in; 170, 171; 170, 172; 171, string:'callback_query'; 172, attribute; 172, 173; 172, 174; 173, identifier:self; 174, identifier:_update; 175, block; 175, 176; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:layer; 180, identifier:message; 181, subscript; 181, 182; 181, 187; 182, subscript; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:self; 185, identifier:_update; 186, string:'callback_query'; 187, string:'message'; 188, if_statement; 188, 189; 188, 202; 189, boolean_operator:and; 189, 190; 189, 195; 189, 196; 190, comparison_operator:in; 190, 191; 190, 192; 191, string:'inline_query'; 192, attribute; 192, 193; 192, 194; 193, identifier:self; 194, identifier:_update; 195, line_continuation:\; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:stack; 199, identifier:has_layer; 200, argument_list; 200, 201; 201, identifier:AnswerInlineQuery; 202, block; 202, 203; 202, 212; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:a; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:stack; 209, identifier:get_layer; 210, argument_list; 210, 211; 211, identifier:AnswerInlineQuery; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:a; 216, identifier:inline_query_id; 217, subscript; 217, 218; 217, 223; 218, subscript; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:self; 221, identifier:_update; 222, string:'inline_query'; 223, string:'id'; 224, if_statement; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:stack; 227, identifier:layers; 228, block; 228, 229; 229, return_statement; 229, 230; 230, call; 230, 231; 230, 238; 231, attribute; 231, 232; 231, 237; 232, call; 232, 233; 232, 234; 233, identifier:super; 234, argument_list; 234, 235; 234, 236; 235, identifier:TelegramResponder; 236, identifier:self; 237, identifier:send; 238, argument_list; 238, 239; 239, identifier:stack
def send(self, stack: Layers): if not isinstance(stack, Stack): stack = Stack(stack) if 'callback_query' in self._update and stack.has_layer(Update): layer = stack.get_layer(Update) try: msg = self._update['callback_query']['message'] except KeyError: layer.inline_message_id = \ self._update['callback_query']['inline_message_id'] else: layer.chat_id = msg['chat']['id'] layer.message_id = msg['message_id'] if stack.has_layer(AnswerCallbackQuery): self._acq = stack.get_layer(AnswerCallbackQuery) stack = Stack([ l for l in stack.layers if not isinstance(l, AnswerCallbackQuery) ]) if stack.has_layer(Reply): layer = stack.get_layer(Reply) if 'message' in self._update: layer.message = self._update['message'] elif 'callback_query' in self._update: layer.message = self._update['callback_query']['message'] if 'inline_query' in self._update \ and stack.has_layer(AnswerInlineQuery): a = stack.get_layer(AnswerInlineQuery) a.inline_query_id = self._update['inline_query']['id'] if stack.layers: return super(TelegramResponder, self).send(stack)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:_send_text; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 13; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:request; 7, type; 7, 8; 8, identifier:Request; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:stack; 11, type; 11, 12; 12, identifier:Stack; 13, typed_default_parameter; 13, 14; 13, 15; 13, 21; 14, identifier:parse_mode; 15, type; 15, 16; 16, generic_type; 16, 17; 16, 18; 17, identifier:Optional; 18, type_parameter; 18, 19; 19, type; 19, 20; 20, identifier:Text; 21, None; 22, block; 22, 23; 22, 27; 22, 37; 22, 77; 22, 100; 22, 113; 22, 124; 22, 132; 22, 164; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:parts; 26, list:[]; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:chat_id; 30, call; 30, 31; 30, 36; 31, attribute; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:request; 34, identifier:message; 35, identifier:get_chat_id; 36, argument_list; 37, for_statement; 37, 38; 37, 39; 37, 42; 38, identifier:layer; 39, attribute; 39, 40; 39, 41; 40, identifier:stack; 41, identifier:layers; 42, block; 42, 43; 43, if_statement; 43, 44; 43, 58; 44, call; 44, 45; 44, 46; 45, identifier:isinstance; 46, argument_list; 46, 47; 46, 48; 47, identifier:layer; 48, tuple; 48, 49; 48, 52; 48, 55; 49, attribute; 49, 50; 49, 51; 50, identifier:lyr; 51, identifier:Text; 52, attribute; 52, 53; 52, 54; 53, identifier:lyr; 54, identifier:RawText; 55, attribute; 55, 56; 55, 57; 56, identifier:lyr; 57, identifier:Markdown; 58, block; 58, 59; 58, 70; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:text; 62, await; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:render; 65, argument_list; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:layer; 68, identifier:text; 69, identifier:request; 70, expression_statement; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:parts; 74, identifier:append; 75, argument_list; 75, 76; 76, identifier:text; 77, for_statement; 77, 78; 77, 79; 77, 85; 78, identifier:part; 79, subscript; 79, 80; 79, 81; 80, identifier:parts; 81, slice; 81, 82; 81, 83; 82, colon; 83, unary_operator:-; 83, 84; 84, integer:1; 85, block; 85, 86; 86, expression_statement; 86, 87; 87, await; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:call; 92, argument_list; 92, 93; 92, 94; 92, 97; 93, string:'sendMessage'; 94, keyword_argument; 94, 95; 94, 96; 95, identifier:text; 96, identifier:part; 97, keyword_argument; 97, 98; 97, 99; 98, identifier:chat_id; 99, identifier:chat_id; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:msg; 103, dictionary; 103, 104; 103, 110; 104, pair; 104, 105; 104, 106; 105, string:'text'; 106, subscript; 106, 107; 106, 108; 107, identifier:parts; 108, unary_operator:-; 108, 109; 109, integer:1; 110, pair; 110, 111; 110, 112; 111, string:'chat_id'; 112, identifier:chat_id; 113, if_statement; 113, 114; 113, 117; 114, comparison_operator:is; 114, 115; 114, 116; 115, identifier:parse_mode; 116, None; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:msg; 122, string:'parse_mode'; 123, identifier:parse_mode; 124, expression_statement; 124, 125; 125, await; 125, 126; 126, call; 126, 127; 126, 128; 127, identifier:set_reply_markup; 128, argument_list; 128, 129; 128, 130; 128, 131; 129, identifier:msg; 130, identifier:request; 131, identifier:stack; 132, if_statement; 132, 133; 132, 139; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:stack; 136, identifier:has_layer; 137, argument_list; 137, 138; 138, identifier:Reply; 139, block; 139, 140; 139, 149; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:reply; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:stack; 146, identifier:get_layer; 147, argument_list; 147, 148; 148, identifier:Reply; 149, if_statement; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:reply; 152, identifier:message; 153, block; 153, 154; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 159; 156, subscript; 156, 157; 156, 158; 157, identifier:msg; 158, string:'reply_to_message_id'; 159, subscript; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:reply; 162, identifier:message; 163, string:'message_id'; 164, if_statement; 164, 165; 164, 171; 164, 220; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:stack; 168, identifier:has_layer; 169, argument_list; 169, 170; 170, identifier:Update; 171, block; 171, 172; 171, 181; 171, 208; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:update; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:stack; 178, identifier:get_layer; 179, argument_list; 179, 180; 180, identifier:Update; 181, if_statement; 181, 182; 181, 185; 181, 198; 182, attribute; 182, 183; 182, 184; 183, identifier:update; 184, identifier:inline_message_id; 185, block; 185, 186; 185, 194; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 191; 188, subscript; 188, 189; 188, 190; 189, identifier:msg; 190, string:'inline_message_id'; 191, attribute; 191, 192; 191, 193; 192, identifier:update; 193, identifier:inline_message_id; 194, delete_statement; 194, 195; 195, subscript; 195, 196; 195, 197; 196, identifier:msg; 197, string:'chat_id'; 198, else_clause; 198, 199; 199, block; 199, 200; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 205; 202, subscript; 202, 203; 202, 204; 203, identifier:msg; 204, string:'message_id'; 205, attribute; 205, 206; 205, 207; 206, identifier:update; 207, identifier:message_id; 208, expression_statement; 208, 209; 209, await; 209, 210; 210, call; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:self; 213, identifier:call; 214, argument_list; 214, 215; 214, 216; 214, 218; 215, string:'editMessageText'; 216, set; 216, 217; 217, string:'Bad Request: message is not modified'; 218, dictionary_splat; 218, 219; 219, identifier:msg; 220, else_clause; 220, 221; 221, block; 221, 222; 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:call; 228, argument_list; 228, 229; 228, 230; 229, string:'sendMessage'; 230, dictionary_splat; 230, 231; 231, identifier:msg
async def _send_text(self, request: Request, stack: Stack, parse_mode: Optional[Text] = None): parts = [] chat_id = request.message.get_chat_id() for layer in stack.layers: if isinstance(layer, (lyr.Text, lyr.RawText, lyr.Markdown)): text = await render(layer.text, request) parts.append(text) for part in parts[:-1]: await self.call( 'sendMessage', text=part, chat_id=chat_id, ) msg = { 'text': parts[-1], 'chat_id': chat_id, } if parse_mode is not None: msg['parse_mode'] = parse_mode await set_reply_markup(msg, request, stack) if stack.has_layer(Reply): reply = stack.get_layer(Reply) if reply.message: msg['reply_to_message_id'] = reply.message['message_id'] if stack.has_layer(Update): update = stack.get_layer(Update) if update.inline_message_id: msg['inline_message_id'] = update.inline_message_id del msg['chat_id'] else: msg['message_id'] = update.message_id await self.call( 'editMessageText', {'Bad Request: message is not modified'}, **msg ) else: await self.call('sendMessage', **msg)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:setRepayments; 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, 33; 9, 88; 9, 102; 9, 108; 10, function_definition; 10, 11; 10, 12; 10, 14; 11, function_name:duedate; 12, parameters; 12, 13; 13, identifier:repayment; 14, block; 14, 15; 15, try_statement; 15, 16; 15, 21; 16, block; 16, 17; 17, return_statement; 17, 18; 18, subscript; 18, 19; 18, 20; 19, identifier:repayment; 20, string:'dueDate'; 21, except_clause; 21, 22; 21, 26; 22, as_pattern; 22, 23; 22, 24; 23, identifier:KeyError; 24, as_pattern_target; 24, 25; 25, identifier:kerr; 26, block; 26, 27; 27, return_statement; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:datetime; 31, identifier:now; 32, argument_list; 33, try_statement; 33, 34; 33, 52; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:reps; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:mamburepaymentsclass; 42, argument_list; 42, 43; 42, 48; 42, 50; 43, keyword_argument; 43, 44; 43, 45; 44, identifier:entid; 45, subscript; 45, 46; 45, 47; 46, identifier:self; 47, string:'id'; 48, list_splat; 48, 49; 49, identifier:args; 50, dictionary_splat; 50, 51; 51, identifier:kwargs; 52, except_clause; 52, 53; 52, 57; 53, as_pattern; 53, 54; 53, 55; 54, identifier:AttributeError; 55, as_pattern_target; 55, 56; 56, identifier:ae; 57, block; 57, 58; 57, 65; 57, 71; 58, import_from_statement; 58, 59; 58, 63; 59, relative_import; 59, 60; 59, 61; 60, import_prefix; 61, dotted_name; 61, 62; 62, identifier:mamburepayment; 63, dotted_name; 63, 64; 64, identifier:MambuRepayments; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:mamburepaymentsclass; 70, identifier:MambuRepayments; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:reps; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:mamburepaymentsclass; 78, argument_list; 78, 79; 78, 84; 78, 86; 79, keyword_argument; 79, 80; 79, 81; 80, identifier:entid; 81, subscript; 81, 82; 81, 83; 82, identifier:self; 83, string:'id'; 84, list_splat; 84, 85; 85, identifier:args; 86, dictionary_splat; 86, 87; 87, identifier:kwargs; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:reps; 92, identifier:attrs; 93, call; 93, 94; 93, 95; 94, identifier:sorted; 95, argument_list; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:reps; 98, identifier:attrs; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:key; 101, identifier:duedate; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 107; 104, subscript; 104, 105; 104, 106; 105, identifier:self; 106, string:'repayments'; 107, identifier:reps; 108, return_statement; 108, 109; 109, integer:1
def setRepayments(self, *args, **kwargs): def duedate(repayment): try: return repayment['dueDate'] except KeyError as kerr: return datetime.now() try: reps = self.mamburepaymentsclass(entid=self['id'], *args, **kwargs) except AttributeError as ae: from .mamburepayment import MambuRepayments self.mamburepaymentsclass = MambuRepayments reps = self.mamburepaymentsclass(entid=self['id'], *args, **kwargs) reps.attrs = sorted(reps.attrs, key=duedate) self['repayments'] = reps return 1
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:setTransactions; 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, 29; 9, 84; 9, 98; 9, 104; 10, function_definition; 10, 11; 10, 12; 10, 14; 11, function_name:transactionid; 12, parameters; 12, 13; 13, identifier:transaction; 14, block; 14, 15; 15, try_statement; 15, 16; 15, 21; 16, block; 16, 17; 17, return_statement; 17, 18; 18, subscript; 18, 19; 18, 20; 19, identifier:transaction; 20, string:'transactionId'; 21, except_clause; 21, 22; 21, 26; 22, as_pattern; 22, 23; 22, 24; 23, identifier:KeyError; 24, as_pattern_target; 24, 25; 25, identifier:kerr; 26, block; 26, 27; 27, return_statement; 27, 28; 28, None; 29, try_statement; 29, 30; 29, 48; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:trans; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:mambutransactionsclass; 38, argument_list; 38, 39; 38, 44; 38, 46; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:entid; 41, subscript; 41, 42; 41, 43; 42, identifier:self; 43, string:'id'; 44, list_splat; 44, 45; 45, identifier:args; 46, dictionary_splat; 46, 47; 47, identifier:kwargs; 48, except_clause; 48, 49; 48, 53; 49, as_pattern; 49, 50; 49, 51; 50, identifier:AttributeError; 51, as_pattern_target; 51, 52; 52, identifier:ae; 53, block; 53, 54; 53, 61; 53, 67; 54, import_from_statement; 54, 55; 54, 59; 55, relative_import; 55, 56; 55, 57; 56, import_prefix; 57, dotted_name; 57, 58; 58, identifier:mambutransaction; 59, dotted_name; 59, 60; 60, identifier:MambuTransactions; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:mambutransactionsclass; 66, identifier:MambuTransactions; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:trans; 70, call; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:mambutransactionsclass; 74, argument_list; 74, 75; 74, 80; 74, 82; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:entid; 77, subscript; 77, 78; 77, 79; 78, identifier:self; 79, string:'id'; 80, list_splat; 80, 81; 81, identifier:args; 82, dictionary_splat; 82, 83; 83, identifier:kwargs; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:trans; 88, identifier:attrs; 89, call; 89, 90; 89, 91; 90, identifier:sorted; 91, argument_list; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:trans; 94, identifier:attrs; 95, keyword_argument; 95, 96; 95, 97; 96, identifier:key; 97, identifier:transactionid; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 103; 100, subscript; 100, 101; 100, 102; 101, identifier:self; 102, string:'transactions'; 103, identifier:trans; 104, return_statement; 104, 105; 105, integer:1
def setTransactions(self, *args, **kwargs): def transactionid(transaction): try: return transaction['transactionId'] except KeyError as kerr: return None try: trans = self.mambutransactionsclass(entid=self['id'], *args, **kwargs) except AttributeError as ae: from .mambutransaction import MambuTransactions self.mambutransactionsclass = MambuTransactions trans = self.mambutransactionsclass(entid=self['id'], *args, **kwargs) trans.attrs = sorted(trans.attrs, key=transactionid) self['transactions'] = trans return 1
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_filter; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:environ; 6, identifier:params; 7, block; 7, 8; 7, 64; 7, 68; 7, 91; 7, 99; 7, 119; 7, 128; 7, 135; 7, 142; 7, 150; 7, 160; 7, 171; 7, 187; 7, 202; 7, 216; 7, 231; 7, 359; 7, 373; 7, 404; 7, 413; 7, 431; 8, if_statement; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:queries; 12, block; 12, 13; 12, 20; 12, 44; 12, 53; 13, if_statement; 13, 14; 13, 17; 14, comparison_operator:not; 14, 15; 14, 16; 15, string:'QUERY_STRING'; 16, identifier:environ; 17, block; 17, 18; 18, return_statement; 18, 19; 19, False; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:available; 23, call; 23, 24; 23, 25; 24, identifier:set; 25, generator_expression; 25, 26; 25, 34; 26, subscript; 26, 27; 26, 33; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:qstr; 30, identifier:partition; 31, argument_list; 31, 32; 32, string:'='; 33, integer:0; 34, for_in_clause; 34, 35; 34, 36; 35, identifier:qstr; 36, call; 36, 37; 36, 42; 37, attribute; 37, 38; 37, 41; 38, subscript; 38, 39; 38, 40; 39, identifier:environ; 40, string:'QUERY_STRING'; 41, identifier:split; 42, argument_list; 42, 43; 43, string:'&'; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:required; 47, call; 47, 48; 47, 49; 48, identifier:set; 49, argument_list; 49, 50; 50, attribute; 50, 51; 50, 52; 51, identifier:self; 52, identifier:queries; 53, if_statement; 53, 54; 53, 61; 54, not_operator; 54, 55; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:required; 58, identifier:issubset; 59, argument_list; 59, 60; 60, identifier:available; 61, block; 61, 62; 62, return_statement; 62, 63; 63, False; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:unused; 67, dictionary; 68, for_statement; 68, 69; 68, 72; 68, 77; 69, pattern_list; 69, 70; 69, 71; 70, identifier:key; 71, identifier:value; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:params; 75, identifier:items; 76, argument_list; 77, block; 77, 78; 78, if_statement; 78, 79; 78, 84; 79, comparison_operator:not; 79, 80; 79, 81; 80, identifier:key; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:use; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 90; 87, subscript; 87, 88; 87, 89; 88, identifier:unused; 89, identifier:key; 90, identifier:value; 91, for_statement; 91, 92; 91, 93; 91, 94; 92, identifier:key; 93, identifier:unused; 94, block; 94, 95; 95, delete_statement; 95, 96; 96, subscript; 96, 97; 96, 98; 97, identifier:params; 98, identifier:key; 99, try_statement; 99, 100; 99, 114; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:additional; 104, boolean_operator:or; 104, 105; 104, 113; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:filter; 109, argument_list; 109, 110; 109, 111; 109, 112; 110, identifier:environ; 111, identifier:params; 112, identifier:unused; 113, dictionary; 114, except_clause; 114, 115; 114, 116; 115, identifier:DeferLimit; 116, block; 116, 117; 117, return_statement; 117, 118; 118, False; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:key; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:self; 125, identifier:key; 126, argument_list; 126, 127; 127, identifier:params; 128, expression_statement; 128, 129; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:params; 132, identifier:update; 133, argument_list; 133, 134; 134, identifier:unused; 135, expression_statement; 135, 136; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:params; 139, identifier:update; 140, argument_list; 140, 141; 141, identifier:additional; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:now; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:time; 148, identifier:time; 149, argument_list; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 157; 152, attribute; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:self; 155, identifier:db; 156, identifier:expire; 157, argument_list; 157, 158; 157, 159; 158, identifier:key; 159, integer:60; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:update_uuid; 163, call; 163, 164; 163, 165; 164, identifier:str; 165, argument_list; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:uuid; 169, identifier:uuid4; 170, argument_list; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:update; 174, dictionary; 174, 175; 174, 178; 175, pair; 175, 176; 175, 177; 176, string:'uuid'; 177, identifier:update_uuid; 178, pair; 178, 179; 178, 180; 179, string:'update'; 180, dictionary; 180, 181; 180, 184; 181, pair; 181, 182; 181, 183; 182, string:'params'; 183, identifier:params; 184, pair; 184, 185; 184, 186; 185, string:'time'; 186, identifier:now; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 194; 189, attribute; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:self; 192, identifier:db; 193, identifier:rpush; 194, argument_list; 194, 195; 194, 196; 195, identifier:key; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:msgpack; 199, identifier:dumps; 200, argument_list; 200, 201; 201, identifier:update; 202, expression_statement; 202, 203; 203, assignment; 203, 204; 203, 205; 204, identifier:records; 205, call; 205, 206; 205, 211; 206, attribute; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:self; 209, identifier:db; 210, identifier:lrange; 211, argument_list; 211, 212; 211, 213; 211, 214; 212, identifier:key; 213, integer:0; 214, unary_operator:-; 214, 215; 215, integer:1; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:loader; 219, call; 219, 220; 219, 221; 220, identifier:BucketLoader; 221, argument_list; 221, 222; 221, 225; 221, 228; 221, 229; 221, 230; 222, attribute; 222, 223; 222, 224; 223, identifier:self; 224, identifier:bucket_class; 225, attribute; 225, 226; 225, 227; 226, identifier:self; 227, identifier:db; 228, identifier:self; 229, identifier:key; 230, identifier:records; 231, if_statement; 231, 232; 231, 235; 232, comparison_operator:in; 232, 233; 232, 234; 233, string:'turnstile.conf'; 234, identifier:environ; 235, block; 235, 236; 235, 244; 235, 264; 235, 284; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:config; 239, subscript; 239, 240; 239, 243; 240, subscript; 240, 241; 240, 242; 241, identifier:environ; 242, string:'turnstile.conf'; 243, string:'compactor'; 244, try_statement; 244, 245; 244, 255; 245, block; 245, 246; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 249; 248, identifier:max_updates; 249, call; 249, 250; 249, 251; 250, identifier:int; 251, argument_list; 251, 252; 252, subscript; 252, 253; 252, 254; 253, identifier:config; 254, string:'max_updates'; 255, except_clause; 255, 256; 255, 259; 256, tuple; 256, 257; 256, 258; 257, identifier:KeyError; 258, identifier:ValueError; 259, block; 259, 260; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 263; 262, identifier:max_updates; 263, None; 264, try_statement; 264, 265; 264, 275; 265, block; 265, 266; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 269; 268, identifier:max_age; 269, call; 269, 270; 269, 271; 270, identifier:int; 271, argument_list; 271, 272; 272, subscript; 272, 273; 272, 274; 273, identifier:config; 274, string:'max_age'; 275, except_clause; 275, 276; 275, 279; 276, tuple; 276, 277; 276, 278; 277, identifier:KeyError; 278, identifier:ValueError; 279, block; 279, 280; 280, expression_statement; 280, 281; 281, assignment; 281, 282; 281, 283; 282, identifier:max_age; 283, integer:600; 284, if_statement; 284, 285; 284, 295; 285, boolean_operator:and; 285, 286; 285, 287; 286, identifier:max_updates; 287, call; 287, 288; 287, 291; 288, attribute; 288, 289; 288, 290; 289, identifier:loader; 290, identifier:need_summary; 291, argument_list; 291, 292; 291, 293; 291, 294; 292, identifier:now; 293, identifier:max_updates; 294, identifier:max_age; 295, block; 295, 296; 295, 315; 295, 330; 295, 340; 296, expression_statement; 296, 297; 297, assignment; 297, 298; 297, 299; 298, identifier:summarize; 299, call; 299, 300; 299, 301; 300, identifier:dict; 301, argument_list; 301, 302; 301, 305; 302, keyword_argument; 302, 303; 302, 304; 303, identifier:summarize; 304, identifier:now; 305, keyword_argument; 305, 306; 305, 307; 306, identifier:uuid; 307, call; 307, 308; 307, 309; 308, identifier:str; 309, argument_list; 309, 310; 310, call; 310, 311; 310, 314; 311, attribute; 311, 312; 311, 313; 312, identifier:uuid; 313, identifier:uuid4; 314, argument_list; 315, expression_statement; 315, 316; 316, call; 316, 317; 316, 322; 317, attribute; 317, 318; 317, 321; 318, attribute; 318, 319; 318, 320; 319, identifier:self; 320, identifier:db; 321, identifier:rpush; 322, argument_list; 322, 323; 322, 324; 323, identifier:key; 324, call; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:msgpack; 327, identifier:dumps; 328, argument_list; 328, 329; 329, identifier:summarize; 330, expression_statement; 330, 331; 331, assignment; 331, 332; 331, 333; 332, identifier:compactor_key; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:config; 336, identifier:get; 337, argument_list; 337, 338; 337, 339; 338, string:'compactor_key'; 339, string:'compactor'; 340, expression_statement; 340, 341; 341, call; 341, 342; 341, 347; 342, attribute; 342, 343; 342, 346; 343, attribute; 343, 344; 343, 345; 344, identifier:self; 345, identifier:db; 346, identifier:zadd; 347, argument_list; 347, 348; 347, 349; 347, 358; 348, identifier:compactor_key; 349, call; 349, 350; 349, 351; 350, identifier:int; 351, argument_list; 351, 352; 352, call; 352, 353; 352, 356; 353, attribute; 353, 354; 353, 355; 354, identifier:math; 355, identifier:ceil; 356, argument_list; 356, 357; 357, identifier:now; 358, identifier:key; 359, expression_statement; 359, 360; 360, call; 360, 361; 360, 366; 361, attribute; 361, 362; 361, 365; 362, attribute; 362, 363; 362, 364; 363, identifier:self; 364, identifier:db; 365, identifier:expireat; 366, argument_list; 366, 367; 366, 368; 367, identifier:key; 368, attribute; 368, 369; 368, 372; 369, attribute; 369, 370; 369, 371; 370, identifier:loader; 371, identifier:bucket; 372, identifier:expire; 373, if_statement; 373, 374; 373, 379; 374, comparison_operator:is; 374, 375; 374, 378; 375, attribute; 375, 376; 375, 377; 376, identifier:loader; 377, identifier:delay; 378, None; 379, block; 379, 380; 379, 388; 380, expression_statement; 380, 381; 381, call; 381, 382; 381, 385; 382, attribute; 382, 383; 382, 384; 383, identifier:environ; 384, identifier:setdefault; 385, argument_list; 385, 386; 385, 387; 386, string:'turnstile.delay'; 387, list:[]; 388, expression_statement; 388, 389; 389, call; 389, 390; 389, 395; 390, attribute; 390, 391; 390, 394; 391, subscript; 391, 392; 391, 393; 392, identifier:environ; 393, string:'turnstile.delay'; 394, identifier:append; 395, argument_list; 395, 396; 396, tuple; 396, 397; 396, 400; 396, 401; 397, attribute; 397, 398; 397, 399; 398, identifier:loader; 399, identifier:delay; 400, identifier:self; 401, attribute; 401, 402; 401, 403; 402, identifier:loader; 403, identifier:bucket; 404, expression_statement; 404, 405; 405, assignment; 405, 406; 405, 407; 406, identifier:set_name; 407, call; 407, 408; 407, 411; 408, attribute; 408, 409; 408, 410; 409, identifier:environ; 410, identifier:get; 411, argument_list; 411, 412; 412, string:'turnstile.bucket_set'; 413, if_statement; 413, 414; 413, 415; 414, identifier:set_name; 415, block; 415, 416; 416, expression_statement; 416, 417; 417, call; 417, 418; 417, 423; 418, attribute; 418, 419; 418, 422; 419, attribute; 419, 420; 419, 421; 420, identifier:self; 421, identifier:db; 422, identifier:zadd; 423, argument_list; 423, 424; 423, 425; 423, 430; 424, identifier:set_name; 425, attribute; 425, 426; 425, 429; 426, attribute; 426, 427; 426, 428; 427, identifier:loader; 428, identifier:bucket; 429, identifier:expire; 430, identifier:key; 431, return_statement; 431, 432; 432, not_operator; 432, 433; 433, attribute; 433, 434; 433, 435; 434, identifier:self; 435, identifier:continue_scan
def _filter(self, environ, params): if self.queries: if 'QUERY_STRING' not in environ: return False available = set(qstr.partition('=')[0] for qstr in environ['QUERY_STRING'].split('&')) required = set(self.queries) if not required.issubset(available): return False unused = {} for key, value in params.items(): if key not in self.use: unused[key] = value for key in unused: del params[key] try: additional = self.filter(environ, params, unused) or {} except DeferLimit: return False key = self.key(params) params.update(unused) params.update(additional) now = time.time() self.db.expire(key, 60) update_uuid = str(uuid.uuid4()) update = { 'uuid': update_uuid, 'update': { 'params': params, 'time': now, }, } self.db.rpush(key, msgpack.dumps(update)) records = self.db.lrange(key, 0, -1) loader = BucketLoader(self.bucket_class, self.db, self, key, records) if 'turnstile.conf' in environ: config = environ['turnstile.conf']['compactor'] try: max_updates = int(config['max_updates']) except (KeyError, ValueError): max_updates = None try: max_age = int(config['max_age']) except (KeyError, ValueError): max_age = 600 if max_updates and loader.need_summary(now, max_updates, max_age): summarize = dict(summarize=now, uuid=str(uuid.uuid4())) self.db.rpush(key, msgpack.dumps(summarize)) compactor_key = config.get('compactor_key', 'compactor') self.db.zadd(compactor_key, int(math.ceil(now)), key) self.db.expireat(key, loader.bucket.expire) if loader.delay is not None: environ.setdefault('turnstile.delay', []) environ['turnstile.delay'].append((loader.delay, self, loader.bucket)) set_name = environ.get('turnstile.bucket_set') if set_name: self.db.zadd(set_name, loader.bucket.expire, key) return not self.continue_scan
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 41; 2, function_name:show; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 4, identifier:items; 5, default_parameter; 5, 6; 5, 7; 6, identifier:command; 7, string:'dmenu'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:bottom; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:fast; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:case_insensitive; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:lines; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:monitor; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:prompt; 25, None; 26, default_parameter; 26, 27; 26, 28; 27, identifier:font; 28, None; 29, default_parameter; 29, 30; 29, 31; 30, identifier:background; 31, None; 32, default_parameter; 32, 33; 32, 34; 33, identifier:foreground; 34, None; 35, default_parameter; 35, 36; 35, 37; 36, identifier:background_selected; 37, None; 38, default_parameter; 38, 39; 38, 40; 39, identifier:foreground_selected; 40, None; 41, block; 41, 42; 41, 44; 41, 49; 41, 59; 41, 69; 41, 79; 41, 96; 41, 113; 41, 127; 41, 141; 41, 155; 41, 169; 41, 183; 41, 197; 41, 238; 41, 267; 41, 289; 41, 299; 41, 306; 41, 324; 42, expression_statement; 42, 43; 43, string:'''Present a dmenu to the user. Args: items (Iterable[str]): defines the menu items being presented to the user. items should not contain the newline character. command (Optional[str]): defines the path to the dmenu executable. Defaults to 'dmenu'. bottom (Optional[bool]): dmenu appears at the bottom of the screen. fast (Optional[bool]): dmenu grabs the keyboard before reading stdin. This is faster, but will lock up X until stdin reaches end-of-file. case_insensitive (Optional[bool]): dmenu matches menu items case insensitively. lines (Optional[int]): dmenu lists items vertically, with the given number of lines. monitor (Optional[int]): dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0. prompt (Optional[str]): defines the prompt to be displayed to the left of the input field. font (Optional[str]): defines the font or font set used. eg. "fixed" or "Monospace-12:normal" (an xft font) background (Optional[str]): defines the normal background color. foreground (Optional[str]): defines the normal foreground color. background_selected (Optional[str]): defines the selected background color. foreground_selected (Optional[str]): defines the selected foreground color. Raises: DmenuCommandError DmenuUsageError Returns: The user's selected menu item, their own typed item, or None if they hit escape. Examples: >>> import dmenu >>> dmenu.show(['a', 'b', 'c']) 'a' >>> dmenu.show(['a', 'b', 'c'], prompt='pick a letter') 'b' >>> dmenu.show(['a', 'b', 'c']) None >>> dmenu.show(['a', 'b', 'c']) 'd' >>> dmenu.show(['a', 'b', 'c'], command='not_a_valid_dmenu') Traceback (most recent call last): ... dmenu.dmenu.DmenuCommandError: The provided dmenu command could not be used (['not_a_valid_dmenu']): [Errno 2] No such file or directory: 'not_a_valid_dmenu' >>> dmenu.show(['a', 'b', 'c'], monitor=2) Traceback (most recent call last): ... dmenu.dmenu.DmenuUsageError: This version of dmenu does not support your usage (['dmenu', '-m', '2']): usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-nb color] [-nf color] [-sb color] [-sf color] [-v] Consider configuring show using partial application: >>> import functools >>> show = functools.partial(dmenu.show, bottom=True) >>> show(['we', 'show', 'up', 'below']) >>> show(['us', 'too']) '''; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:args; 47, list:[command]; 47, 48; 48, identifier:command; 49, if_statement; 49, 50; 49, 51; 50, identifier:bottom; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:args; 56, identifier:append; 57, argument_list; 57, 58; 58, string:'-b'; 59, if_statement; 59, 60; 59, 61; 60, identifier:fast; 61, block; 61, 62; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:args; 66, identifier:append; 67, argument_list; 67, 68; 68, string:'-f'; 69, if_statement; 69, 70; 69, 71; 70, identifier:case_insensitive; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:args; 76, identifier:append; 77, argument_list; 77, 78; 78, string:'-i'; 79, if_statement; 79, 80; 79, 83; 80, comparison_operator:is; 80, 81; 80, 82; 81, identifier:lines; 82, None; 83, block; 83, 84; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:args; 88, identifier:extend; 89, argument_list; 89, 90; 90, tuple; 90, 91; 90, 92; 91, string:'-l'; 92, call; 92, 93; 92, 94; 93, identifier:str; 94, argument_list; 94, 95; 95, identifier:lines; 96, if_statement; 96, 97; 96, 100; 97, comparison_operator:is; 97, 98; 97, 99; 98, identifier:monitor; 99, None; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:args; 105, identifier:extend; 106, argument_list; 106, 107; 107, tuple; 107, 108; 107, 109; 108, string:'-m'; 109, call; 109, 110; 109, 111; 110, identifier:str; 111, argument_list; 111, 112; 112, identifier:monitor; 113, if_statement; 113, 114; 113, 117; 114, comparison_operator:is; 114, 115; 114, 116; 115, identifier:prompt; 116, None; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:args; 122, identifier:extend; 123, argument_list; 123, 124; 124, tuple; 124, 125; 124, 126; 125, string:'-p'; 126, identifier:prompt; 127, if_statement; 127, 128; 127, 131; 128, comparison_operator:is; 128, 129; 128, 130; 129, identifier:font; 130, None; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:args; 136, identifier:extend; 137, argument_list; 137, 138; 138, tuple; 138, 139; 138, 140; 139, string:'-fn'; 140, identifier:font; 141, if_statement; 141, 142; 141, 145; 142, comparison_operator:is; 142, 143; 142, 144; 143, identifier:background; 144, None; 145, block; 145, 146; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:args; 150, identifier:extend; 151, argument_list; 151, 152; 152, tuple; 152, 153; 152, 154; 153, string:'-nb'; 154, identifier:background; 155, if_statement; 155, 156; 155, 159; 156, comparison_operator:is; 156, 157; 156, 158; 157, identifier:foreground; 158, None; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:args; 164, identifier:extend; 165, argument_list; 165, 166; 166, tuple; 166, 167; 166, 168; 167, string:'-nf'; 168, identifier:foreground; 169, if_statement; 169, 170; 169, 173; 170, comparison_operator:is; 170, 171; 170, 172; 171, identifier:background_selected; 172, None; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:args; 178, identifier:extend; 179, argument_list; 179, 180; 180, tuple; 180, 181; 180, 182; 181, string:'-sb'; 182, identifier:background_selected; 183, if_statement; 183, 184; 183, 187; 184, comparison_operator:is; 184, 185; 184, 186; 185, identifier:foreground_selected; 186, None; 187, block; 187, 188; 188, expression_statement; 188, 189; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:args; 192, identifier:extend; 193, argument_list; 193, 194; 194, tuple; 194, 195; 194, 196; 195, string:'-sf'; 196, identifier:foreground_selected; 197, try_statement; 197, 198; 197, 226; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 202; 201, identifier:proc; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:subprocess; 205, identifier:Popen; 206, argument_list; 206, 207; 206, 208; 206, 211; 206, 216; 206, 221; 207, identifier:args; 208, keyword_argument; 208, 209; 208, 210; 209, identifier:universal_newlines; 210, True; 211, keyword_argument; 211, 212; 211, 213; 212, identifier:stdin; 213, attribute; 213, 214; 213, 215; 214, identifier:subprocess; 215, identifier:PIPE; 216, keyword_argument; 216, 217; 216, 218; 217, identifier:stdout; 218, attribute; 218, 219; 218, 220; 219, identifier:subprocess; 220, identifier:PIPE; 221, keyword_argument; 221, 222; 221, 223; 222, identifier:stderr; 223, attribute; 223, 224; 223, 225; 224, identifier:subprocess; 225, identifier:PIPE; 226, except_clause; 226, 227; 226, 231; 227, as_pattern; 227, 228; 227, 229; 228, identifier:OSError; 229, as_pattern_target; 229, 230; 230, identifier:err; 231, block; 231, 232; 232, raise_statement; 232, 233; 233, call; 233, 234; 233, 235; 234, identifier:DmenuCommandError; 235, argument_list; 235, 236; 235, 237; 236, identifier:args; 237, identifier:err; 238, with_statement; 238, 239; 238, 244; 239, with_clause; 239, 240; 240, with_item; 240, 241; 241, attribute; 241, 242; 241, 243; 242, identifier:proc; 243, identifier:stdin; 244, block; 244, 245; 245, for_statement; 245, 246; 245, 247; 245, 248; 246, identifier:item; 247, identifier:items; 248, block; 248, 249; 248, 258; 249, expression_statement; 249, 250; 250, call; 250, 251; 250, 256; 251, attribute; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:proc; 254, identifier:stdin; 255, identifier:write; 256, argument_list; 256, 257; 257, identifier:item; 258, expression_statement; 258, 259; 259, call; 259, 260; 259, 265; 260, attribute; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:proc; 263, identifier:stdin; 264, identifier:write; 265, argument_list; 265, 266; 266, string:'\n'; 267, if_statement; 267, 268; 267, 275; 268, comparison_operator:==; 268, 269; 268, 274; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:proc; 272, identifier:wait; 273, argument_list; 274, integer:0; 275, block; 275, 276; 276, return_statement; 276, 277; 277, call; 277, 278; 277, 287; 278, attribute; 278, 279; 278, 286; 279, call; 279, 280; 279, 285; 280, attribute; 280, 281; 280, 284; 281, attribute; 281, 282; 281, 283; 282, identifier:proc; 283, identifier:stdout; 284, identifier:read; 285, argument_list; 286, identifier:rstrip; 287, argument_list; 287, 288; 288, string:'\n'; 289, expression_statement; 289, 290; 290, assignment; 290, 291; 290, 292; 291, identifier:stderr; 292, call; 292, 293; 292, 298; 293, attribute; 293, 294; 293, 297; 294, attribute; 294, 295; 294, 296; 295, identifier:proc; 296, identifier:stderr; 297, identifier:read; 298, argument_list; 299, if_statement; 299, 300; 299, 303; 300, comparison_operator:==; 300, 301; 300, 302; 301, identifier:stderr; 302, string:''; 303, block; 303, 304; 304, return_statement; 304, 305; 305, None; 306, if_statement; 306, 307; 306, 317; 307, call; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:re; 310, identifier:match; 311, argument_list; 311, 312; 311, 313; 311, 314; 312, string:'usage'; 313, identifier:stderr; 314, attribute; 314, 315; 314, 316; 315, identifier:re; 316, identifier:I; 317, block; 317, 318; 318, raise_statement; 318, 319; 319, call; 319, 320; 319, 321; 320, identifier:DmenuUsageError; 321, argument_list; 321, 322; 321, 323; 322, identifier:args; 323, identifier:stderr; 324, raise_statement; 324, 325; 325, call; 325, 326; 325, 327; 326, identifier:DmenuCommandError; 327, argument_list; 327, 328; 327, 329; 328, identifier:args; 329, identifier:stderr
def show( items, command='dmenu', bottom=None, fast=None, case_insensitive=None, lines=None, monitor=None, prompt=None, font=None, background=None, foreground=None, background_selected=None, foreground_selected=None): '''Present a dmenu to the user. Args: items (Iterable[str]): defines the menu items being presented to the user. items should not contain the newline character. command (Optional[str]): defines the path to the dmenu executable. Defaults to 'dmenu'. bottom (Optional[bool]): dmenu appears at the bottom of the screen. fast (Optional[bool]): dmenu grabs the keyboard before reading stdin. This is faster, but will lock up X until stdin reaches end-of-file. case_insensitive (Optional[bool]): dmenu matches menu items case insensitively. lines (Optional[int]): dmenu lists items vertically, with the given number of lines. monitor (Optional[int]): dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0. prompt (Optional[str]): defines the prompt to be displayed to the left of the input field. font (Optional[str]): defines the font or font set used. eg. "fixed" or "Monospace-12:normal" (an xft font) background (Optional[str]): defines the normal background color. foreground (Optional[str]): defines the normal foreground color. background_selected (Optional[str]): defines the selected background color. foreground_selected (Optional[str]): defines the selected foreground color. Raises: DmenuCommandError DmenuUsageError Returns: The user's selected menu item, their own typed item, or None if they hit escape. Examples: >>> import dmenu >>> dmenu.show(['a', 'b', 'c']) 'a' >>> dmenu.show(['a', 'b', 'c'], prompt='pick a letter') 'b' >>> dmenu.show(['a', 'b', 'c']) None >>> dmenu.show(['a', 'b', 'c']) 'd' >>> dmenu.show(['a', 'b', 'c'], command='not_a_valid_dmenu') Traceback (most recent call last): ... dmenu.dmenu.DmenuCommandError: The provided dmenu command could not be used (['not_a_valid_dmenu']): [Errno 2] No such file or directory: 'not_a_valid_dmenu' >>> dmenu.show(['a', 'b', 'c'], monitor=2) Traceback (most recent call last): ... dmenu.dmenu.DmenuUsageError: This version of dmenu does not support your usage (['dmenu', '-m', '2']): usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-nb color] [-nf color] [-sb color] [-sf color] [-v] Consider configuring show using partial application: >>> import functools >>> show = functools.partial(dmenu.show, bottom=True) >>> show(['we', 'show', 'up', 'below']) >>> show(['us', 'too']) ''' args = [command] if bottom: args.append('-b') if fast: args.append('-f') if case_insensitive: args.append('-i') if lines is not None: args.extend(('-l', str(lines))) if monitor is not None: args.extend(('-m', str(monitor))) if prompt is not None: args.extend(('-p', prompt)) if font is not None: args.extend(('-fn', font)) if background is not None: args.extend(('-nb', background)) if foreground is not None: args.extend(('-nf', foreground)) if background_selected is not None: args.extend(('-sb', background_selected)) if foreground_selected is not None: args.extend(('-sf', foreground_selected)) try: proc = subprocess.Popen( args, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except OSError as err: raise DmenuCommandError(args, err) with proc.stdin: for item in items: proc.stdin.write(item) proc.stdin.write('\n') if proc.wait() == 0: return proc.stdout.read().rstrip('\n') stderr = proc.stderr.read() if stderr == '': return None if re.match('usage', stderr, re.I): raise DmenuUsageError(args, stderr) raise DmenuCommandError(args, stderr)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:clean_names; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:lines; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ensure_unique_names; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:strip_prefix; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, identifier:make_database_safe; 13, False; 14, block; 14, 15; 14, 19; 14, 167; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:names; 18, dictionary; 19, for_statement; 19, 20; 19, 21; 19, 22; 20, identifier:row; 21, identifier:lines; 22, block; 22, 23; 22, 75; 22, 150; 23, if_statement; 23, 24; 23, 25; 24, identifier:strip_prefix; 25, block; 25, 26; 25, 47; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 31; 28, subscript; 28, 29; 28, 30; 29, identifier:row; 30, string:'name'; 31, subscript; 31, 32; 31, 35; 32, subscript; 32, 33; 32, 34; 33, identifier:row; 34, string:'name'; 35, slice; 35, 36; 35, 46; 36, binary_operator:+; 36, 37; 36, 45; 37, call; 37, 38; 37, 43; 38, attribute; 38, 39; 38, 42; 39, subscript; 39, 40; 39, 41; 40, identifier:row; 41, string:'name'; 42, identifier:find; 43, argument_list; 43, 44; 44, string:'-'; 45, integer:1; 46, colon; 47, if_statement; 47, 48; 47, 53; 48, comparison_operator:is; 48, 49; 48, 52; 49, subscript; 49, 50; 49, 51; 50, identifier:row; 51, string:'indexed_by'; 52, None; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 59; 56, subscript; 56, 57; 56, 58; 57, identifier:row; 58, string:'indexed_by'; 59, subscript; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:row; 62, string:'indexed_by'; 63, slice; 63, 64; 63, 74; 64, binary_operator:+; 64, 65; 64, 73; 65, call; 65, 66; 65, 71; 66, attribute; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:row; 69, string:'indexed_by'; 70, identifier:find; 71, argument_list; 71, 72; 72, string:'-'; 73, integer:1; 74, colon; 75, if_statement; 75, 76; 75, 77; 76, identifier:ensure_unique_names; 77, block; 77, 78; 77, 82; 77, 108; 77, 130; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:i; 81, integer:1; 82, while_statement; 82, 83; 82, 103; 83, comparison_operator:in; 83, 84; 83, 102; 84, parenthesized_expression; 84, 85; 85, conditional_expression:if; 85, 86; 85, 89; 85, 92; 86, subscript; 86, 87; 86, 88; 87, identifier:row; 88, string:'name'; 89, comparison_operator:==; 89, 90; 89, 91; 90, identifier:i; 91, integer:1; 92, binary_operator:+; 92, 93; 92, 98; 93, binary_operator:+; 93, 94; 93, 97; 94, subscript; 94, 95; 94, 96; 95, identifier:row; 96, string:'name'; 97, string:"-"; 98, call; 98, 99; 98, 100; 99, identifier:str; 100, argument_list; 100, 101; 101, identifier:i; 102, identifier:names; 103, block; 103, 104; 104, expression_statement; 104, 105; 105, augmented_assignment:+=; 105, 106; 105, 107; 106, identifier:i; 107, integer:1; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 129; 110, subscript; 110, 111; 110, 112; 111, identifier:names; 112, conditional_expression:if; 112, 113; 112, 116; 112, 119; 113, subscript; 113, 114; 113, 115; 114, identifier:row; 115, string:'name'; 116, comparison_operator:==; 116, 117; 116, 118; 117, identifier:i; 118, integer:1; 119, binary_operator:+; 119, 120; 119, 125; 120, binary_operator:+; 120, 121; 120, 124; 121, subscript; 121, 122; 121, 123; 122, identifier:row; 123, string:'name'; 124, string:"-"; 125, call; 125, 126; 125, 127; 126, identifier:str; 127, argument_list; 127, 128; 128, identifier:i; 129, integer:1; 130, if_statement; 130, 131; 130, 134; 131, comparison_operator:>; 131, 132; 131, 133; 132, identifier:i; 133, integer:1; 134, block; 134, 135; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 140; 137, subscript; 137, 138; 137, 139; 138, identifier:row; 139, string:'name'; 140, binary_operator:+; 140, 141; 140, 146; 141, binary_operator:+; 141, 142; 141, 145; 142, subscript; 142, 143; 142, 144; 143, identifier:row; 144, string:'name'; 145, string:"-"; 146, call; 146, 147; 146, 148; 147, identifier:str; 148, argument_list; 148, 149; 149, identifier:i; 150, if_statement; 150, 151; 150, 152; 151, identifier:make_database_safe; 152, block; 152, 153; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 158; 155, subscript; 155, 156; 155, 157; 156, identifier:row; 157, string:'name'; 158, call; 158, 159; 158, 164; 159, attribute; 159, 160; 159, 163; 160, subscript; 160, 161; 160, 162; 161, identifier:row; 162, string:'name'; 163, identifier:replace; 164, argument_list; 164, 165; 164, 166; 165, string:"-"; 166, string:"_"; 167, return_statement; 167, 168; 168, identifier:lines
def clean_names(lines, ensure_unique_names=False, strip_prefix=False, make_database_safe=False): names = {} for row in lines: if strip_prefix: row['name'] = row['name'][row['name'].find('-') + 1:] if row['indexed_by'] is not None: row['indexed_by'] = row['indexed_by'][row['indexed_by'].find( '-') + 1:] if ensure_unique_names: i = 1 while (row['name'] if i == 1 else row['name'] + "-" + str(i)) in names: i += 1 names[row['name'] if i == 1 else row['name'] + "-" + str(i)] = 1 if i > 1: row['name'] = row['name'] + "-" + str(i) if make_database_safe: row['name'] = row['name'].replace("-", "_") return lines
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:do_help; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:arg; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 9; 7, 85; 8, identifier:arg; 9, block; 9, 10; 9, 81; 10, try_statement; 10, 11; 10, 22; 11, block; 11, 12; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:func; 15, call; 15, 16; 15, 17; 16, identifier:getattr; 17, argument_list; 17, 18; 17, 19; 18, identifier:self; 19, binary_operator:+; 19, 20; 19, 21; 20, string:'help_'; 21, identifier:arg; 22, except_clause; 22, 23; 22, 24; 23, identifier:AttributeError; 24, block; 24, 25; 24, 61; 24, 80; 25, try_statement; 25, 26; 25, 57; 26, block; 26, 27; 26, 39; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:doc; 30, attribute; 30, 31; 30, 38; 31, call; 31, 32; 31, 33; 32, identifier:getattr; 33, argument_list; 33, 34; 33, 35; 34, identifier:self; 35, binary_operator:+; 35, 36; 35, 37; 36, string:'do_'; 37, identifier:arg; 38, identifier:__doc__; 39, if_statement; 39, 40; 39, 41; 40, identifier:doc; 41, block; 41, 42; 41, 56; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:stdout; 48, identifier:write; 49, argument_list; 49, 50; 50, binary_operator:%; 50, 51; 50, 52; 51, string:"%s\n"; 52, call; 52, 53; 52, 54; 53, identifier:str; 54, argument_list; 54, 55; 55, identifier:doc; 56, return_statement; 57, except_clause; 57, 58; 57, 59; 58, identifier:AttributeError; 59, block; 59, 60; 60, pass_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:stdout; 67, identifier:write; 68, argument_list; 68, 69; 69, binary_operator:%; 69, 70; 69, 71; 70, string:"%s\n"; 71, call; 71, 72; 71, 73; 72, identifier:str; 73, argument_list; 73, 74; 74, binary_operator:%; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:nohelp; 78, tuple; 78, 79; 79, identifier:arg; 80, return_statement; 81, expression_statement; 81, 82; 82, call; 82, 83; 82, 84; 83, identifier:func; 84, argument_list; 85, else_clause; 85, 86; 86, block; 86, 87; 86, 95; 86, 99; 86, 103; 86, 107; 86, 130; 86, 136; 86, 140; 86, 212; 86, 228; 86, 240; 86, 259; 86, 271; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:names; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:get_names; 94, argument_list; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:cmds_doc; 98, list:[]; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:cmds_undoc; 102, list:[]; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:help_page; 106, dictionary; 107, for_statement; 107, 108; 107, 109; 107, 110; 108, identifier:name; 109, identifier:names; 110, block; 110, 111; 111, if_statement; 111, 112; 111, 119; 112, comparison_operator:==; 112, 113; 112, 118; 113, subscript; 113, 114; 113, 115; 114, identifier:name; 115, slice; 115, 116; 115, 117; 116, colon; 117, integer:5; 118, string:'help_'; 119, block; 119, 120; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 129; 122, subscript; 122, 123; 122, 124; 123, identifier:help_page; 124, subscript; 124, 125; 124, 126; 125, identifier:name; 126, slice; 126, 127; 126, 128; 127, integer:5; 128, colon; 129, integer:1; 130, expression_statement; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:names; 134, identifier:sort; 135, argument_list; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:prevname; 139, string:''; 140, for_statement; 140, 141; 140, 142; 140, 143; 141, identifier:name; 142, identifier:names; 143, block; 143, 144; 144, if_statement; 144, 145; 144, 152; 145, comparison_operator:==; 145, 146; 145, 151; 146, subscript; 146, 147; 146, 148; 147, identifier:name; 148, slice; 148, 149; 148, 150; 149, colon; 150, integer:3; 151, string:'do_'; 152, block; 152, 153; 152, 159; 152, 163; 152, 171; 153, if_statement; 153, 154; 153, 157; 154, comparison_operator:==; 154, 155; 154, 156; 155, identifier:name; 156, identifier:prevname; 157, block; 157, 158; 158, continue_statement; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:prevname; 162, identifier:name; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:cmd; 166, subscript; 166, 167; 166, 168; 167, identifier:name; 168, slice; 168, 169; 168, 170; 169, integer:3; 170, colon; 171, if_statement; 171, 172; 171, 175; 171, 187; 171, 203; 172, comparison_operator:in; 172, 173; 172, 174; 173, identifier:cmd; 174, identifier:help_page; 175, block; 175, 176; 175, 183; 176, expression_statement; 176, 177; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:cmds_doc; 180, identifier:append; 181, argument_list; 181, 182; 182, identifier:cmd; 183, delete_statement; 183, 184; 184, subscript; 184, 185; 184, 186; 185, identifier:help_page; 186, identifier:cmd; 187, elif_clause; 187, 188; 187, 195; 188, attribute; 188, 189; 188, 194; 189, call; 189, 190; 189, 191; 190, identifier:getattr; 191, argument_list; 191, 192; 191, 193; 192, identifier:self; 193, identifier:name; 194, identifier:__doc__; 195, block; 195, 196; 196, expression_statement; 196, 197; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:cmds_doc; 200, identifier:append; 201, argument_list; 201, 202; 202, identifier:cmd; 203, else_clause; 203, 204; 204, block; 204, 205; 205, expression_statement; 205, 206; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:cmds_undoc; 209, identifier:append; 210, argument_list; 210, 211; 211, identifier:cmd; 212, expression_statement; 212, 213; 213, call; 213, 214; 213, 219; 214, attribute; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:self; 217, identifier:stdout; 218, identifier:write; 219, argument_list; 219, 220; 220, binary_operator:%; 220, 221; 220, 222; 221, string:"%s\n"; 222, call; 222, 223; 222, 224; 223, identifier:str; 224, argument_list; 224, 225; 225, attribute; 225, 226; 225, 227; 226, identifier:self; 227, identifier:doc_leader; 228, expression_statement; 228, 229; 229, call; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:self; 232, identifier:print_topics; 233, argument_list; 233, 234; 233, 237; 233, 238; 233, 239; 234, attribute; 234, 235; 234, 236; 235, identifier:self; 236, identifier:doc_header; 237, identifier:cmds_doc; 238, integer:15; 239, integer:80; 240, expression_statement; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:self; 244, identifier:print_topics; 245, argument_list; 245, 246; 245, 249; 245, 257; 245, 258; 246, attribute; 246, 247; 246, 248; 247, identifier:self; 248, identifier:misc_header; 249, call; 249, 250; 249, 251; 250, identifier:list; 251, argument_list; 251, 252; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:help_page; 255, identifier:keys; 256, argument_list; 257, integer:15; 258, integer:80; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:self; 263, identifier:print_topics; 264, argument_list; 264, 265; 264, 268; 264, 269; 264, 270; 265, attribute; 265, 266; 265, 267; 266, identifier:self; 267, identifier:undoc_header; 268, identifier:cmds_undoc; 269, integer:15; 270, integer:80; 271, for_statement; 271, 272; 271, 273; 271, 276; 272, identifier:topic; 273, attribute; 273, 274; 273, 275; 274, identifier:self; 275, identifier:command_topics; 276, block; 276, 277; 276, 285; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 280; 279, identifier:topic_cmds; 280, subscript; 280, 281; 280, 284; 281, attribute; 281, 282; 281, 283; 282, identifier:self; 283, identifier:command_topics; 284, identifier:topic; 285, expression_statement; 285, 286; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:self; 289, identifier:print_topics; 290, argument_list; 290, 291; 290, 299; 290, 300; 290, 301; 291, call; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:string; 294, identifier:capwords; 295, argument_list; 295, 296; 296, binary_operator:+; 296, 297; 296, 298; 297, identifier:topic; 298, string:" commands"; 299, identifier:topic_cmds; 300, integer:15; 301, integer:80
def do_help(self, arg): if arg: try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc = getattr(self, 'do_' + arg).__doc__ if doc: self.stdout.write("%s\n" % str(doc)) return except AttributeError: pass self.stdout.write("%s\n" % str(self.nohelp % (arg,))) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] help_page = {} for name in names: if name[:5] == 'help_': help_page[name[5:]] = 1 names.sort() prevname = '' for name in names: if name[:3] == 'do_': if name == prevname: continue prevname = name cmd = name[3:] if cmd in help_page: cmds_doc.append(cmd) del help_page[cmd] elif getattr(self, name).__doc__: cmds_doc.append(cmd) else: cmds_undoc.append(cmd) self.stdout.write("%s\n" % str(self.doc_leader)) self.print_topics(self.doc_header, cmds_doc, 15, 80) self.print_topics(self.misc_header, list(help_page.keys()), 15, 80) self.print_topics(self.undoc_header, cmds_undoc, 15, 80) for topic in self.command_topics: topic_cmds = self.command_topics[topic] self.print_topics(string.capwords(topic + " commands"), topic_cmds, 15, 80)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:make_echoicefield; 3, parameters; 3, 4; 3, 5; 3, 7; 3, 10; 4, identifier:echoices; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, default_parameter; 7, 8; 7, 9; 8, identifier:klass_name; 9, None; 10, dictionary_splat_pattern; 10, 11; 11, identifier:kwargs; 12, block; 12, 13; 12, 19; 12, 27; 12, 80; 12, 112; 12, 142; 12, 151; 12, 163; 13, assert_statement; 13, 14; 14, call; 14, 15; 14, 16; 15, identifier:issubclass; 16, argument_list; 16, 17; 16, 18; 17, identifier:echoices; 18, identifier:EChoice; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:value_type; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:echoices; 25, identifier:__getvaluetype__; 26, argument_list; 27, if_statement; 27, 28; 27, 31; 27, 38; 27, 49; 27, 60; 27, 71; 28, comparison_operator:is; 28, 29; 28, 30; 29, identifier:value_type; 30, identifier:str; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:cls_; 35, attribute; 35, 36; 35, 37; 36, identifier:models; 37, identifier:CharField; 38, elif_clause; 38, 39; 38, 42; 39, comparison_operator:is; 39, 40; 39, 41; 40, identifier:value_type; 41, identifier:int; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:cls_; 46, attribute; 46, 47; 46, 48; 47, identifier:models; 48, identifier:IntegerField; 49, elif_clause; 49, 50; 49, 53; 50, comparison_operator:is; 50, 51; 50, 52; 51, identifier:value_type; 52, identifier:float; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:cls_; 57, attribute; 57, 58; 57, 59; 58, identifier:models; 59, identifier:FloatField; 60, elif_clause; 60, 61; 60, 64; 61, comparison_operator:is; 61, 62; 61, 63; 62, identifier:value_type; 63, identifier:bool; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:cls_; 68, attribute; 68, 69; 68, 70; 69, identifier:models; 70, identifier:BooleanField; 71, else_clause; 71, 72; 72, block; 72, 73; 73, raise_statement; 73, 74; 74, call; 74, 75; 74, 76; 75, identifier:NotImplementedError; 76, argument_list; 76, 77; 77, concatenated_string; 77, 78; 77, 79; 78, string:"Please open an issue if you wish your value type to be supported: "; 79, string:"https://github.com/mbourqui/django-echoices/issues/new"; 80, if_statement; 80, 81; 80, 94; 81, boolean_operator:and; 81, 82; 81, 83; 82, identifier:klass_name; 83, comparison_operator:<; 83, 84; 83, 90; 84, call; 84, 85; 84, 86; 85, identifier:StrictVersion; 86, argument_list; 86, 87; 87, call; 87, 88; 87, 89; 88, identifier:django_version; 89, argument_list; 90, call; 90, 91; 90, 92; 91, identifier:StrictVersion; 92, argument_list; 92, 93; 93, string:'1.9.0'; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:warnings; 99, identifier:warn; 100, argument_list; 100, 101; 100, 111; 101, call; 101, 102; 101, 107; 102, attribute; 102, 103; 102, 106; 103, concatenated_string; 103, 104; 103, 105; 104, string:"Django < 1.9 throws an 'ImportError' if the class name is not defined in the module. "; 105, string:"The provided klass_name will be replaced by {}"; 106, identifier:format; 107, argument_list; 107, 108; 108, attribute; 108, 109; 108, 110; 109, identifier:EChoiceField; 110, identifier:__name__; 111, identifier:RuntimeWarning; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:klass_name; 115, conditional_expression:if; 115, 116; 115, 119; 115, 130; 115, 131; 116, attribute; 116, 117; 116, 118; 117, identifier:EChoiceField; 118, identifier:__name__; 119, comparison_operator:<; 119, 120; 119, 126; 120, call; 120, 121; 120, 122; 121, identifier:StrictVersion; 122, argument_list; 122, 123; 123, call; 123, 124; 123, 125; 124, identifier:django_version; 125, argument_list; 126, call; 126, 127; 126, 128; 127, identifier:StrictVersion; 128, argument_list; 128, 129; 129, string:'1.9.0'; 130, line_continuation:\; 131, conditional_expression:if; 131, 132; 131, 133; 131, 134; 132, identifier:klass_name; 133, identifier:klass_name; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, string:"{}Field"; 137, identifier:format; 138, argument_list; 138, 139; 139, attribute; 139, 140; 139, 141; 140, identifier:echoices; 141, identifier:__name__; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:d; 145, call; 145, 146; 145, 147; 146, identifier:dict; 147, argument_list; 147, 148; 148, attribute; 148, 149; 148, 150; 149, identifier:cls_; 150, identifier:__dict__; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:d; 155, identifier:update; 156, argument_list; 156, 157; 157, call; 157, 158; 157, 159; 158, identifier:dict; 159, argument_list; 159, 160; 160, attribute; 160, 161; 160, 162; 161, identifier:EChoiceField; 162, identifier:__dict__; 163, return_statement; 163, 164; 164, call; 164, 165; 164, 172; 165, call; 165, 166; 165, 167; 166, identifier:type; 167, argument_list; 167, 168; 167, 169; 167, 171; 168, identifier:klass_name; 169, tuple; 169, 170; 170, identifier:cls_; 171, identifier:d; 172, argument_list; 172, 173; 172, 174; 172, 176; 173, identifier:echoices; 174, list_splat; 174, 175; 175, identifier:args; 176, dictionary_splat; 176, 177; 177, identifier:kwargs
def make_echoicefield(echoices, *args, klass_name=None, **kwargs): assert issubclass(echoices, EChoice) value_type = echoices.__getvaluetype__() if value_type is str: cls_ = models.CharField elif value_type is int: cls_ = models.IntegerField elif value_type is float: cls_ = models.FloatField elif value_type is bool: cls_ = models.BooleanField else: raise NotImplementedError("Please open an issue if you wish your value type to be supported: " "https://github.com/mbourqui/django-echoices/issues/new") if klass_name and StrictVersion(django_version()) < StrictVersion('1.9.0'): warnings.warn("Django < 1.9 throws an 'ImportError' if the class name is not defined in the module. " "The provided klass_name will be replaced by {}".format(EChoiceField.__name__), RuntimeWarning) klass_name = EChoiceField.__name__ if StrictVersion(django_version()) < StrictVersion('1.9.0') else \ klass_name if klass_name else "{}Field".format(echoices.__name__) d = dict(cls_.__dict__) d.update(dict(EChoiceField.__dict__)) return type(klass_name, (cls_,), d)(echoices, *args, **kwargs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:make_dummy; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 17; 3, 20; 3, 23; 3, 26; 3, 28; 4, identifier:instance; 5, default_parameter; 5, 6; 5, 7; 6, identifier:relations; 7, dictionary; 8, default_parameter; 8, 9; 8, 10; 9, identifier:datetime_default; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:dt; 13, identifier:strptime; 14, argument_list; 14, 15; 14, 16; 15, string:'1901-01-01'; 16, string:'%Y-%m-%d'; 17, default_parameter; 17, 18; 17, 19; 18, identifier:varchar_default; 19, string:""; 20, default_parameter; 20, 21; 20, 22; 21, identifier:integer_default; 22, integer:0; 23, default_parameter; 23, 24; 23, 25; 24, identifier:numeric_default; 25, float:0.0; 26, list_splat_pattern; 26, 27; 27, identifier:args; 28, dictionary_splat_pattern; 28, 29; 29, identifier:kwargs; 30, block; 30, 31; 30, 50; 30, 57; 30, 99; 30, 118; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:init_data; 34, dictionary; 34, 35; 34, 38; 34, 41; 34, 44; 34, 47; 35, pair; 35, 36; 35, 37; 36, string:'DATETIME'; 37, identifier:datetime_default; 38, pair; 38, 39; 38, 40; 39, string:'VARCHAR'; 40, identifier:varchar_default; 41, pair; 41, 42; 41, 43; 42, string:'INTEGER'; 43, identifier:integer_default; 44, pair; 44, 45; 44, 46; 45, string:'NUMERIC(50, 10)'; 46, identifier:numeric_default; 47, pair; 47, 48; 47, 49; 48, string:'TEXT'; 49, identifier:varchar_default; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:table; 53, call; 53, 54; 53, 55; 54, identifier:type; 55, argument_list; 55, 56; 56, identifier:instance; 57, for_statement; 57, 58; 57, 59; 57, 64; 58, identifier:col; 59, attribute; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:table; 62, identifier:__table__; 63, identifier:columns; 64, block; 64, 65; 65, try_statement; 65, 66; 65, 80; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, call; 68, 69; 68, 70; 69, identifier:setattr; 70, argument_list; 70, 71; 70, 72; 70, 75; 71, identifier:instance; 72, attribute; 72, 73; 72, 74; 73, identifier:col; 74, identifier:name; 75, subscript; 75, 76; 75, 77; 76, identifier:kwargs; 77, attribute; 77, 78; 77, 79; 78, identifier:col; 79, identifier:name; 80, except_clause; 80, 81; 80, 82; 81, identifier:KeyError; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:setattr; 86, argument_list; 86, 87; 86, 88; 86, 91; 87, identifier:instance; 88, attribute; 88, 89; 88, 90; 89, identifier:col; 90, identifier:name; 91, subscript; 91, 92; 91, 93; 92, identifier:init_data; 93, call; 93, 94; 93, 95; 94, identifier:str; 95, argument_list; 95, 96; 96, attribute; 96, 97; 96, 98; 97, identifier:col; 98, identifier:type; 99, for_statement; 99, 100; 99, 103; 99, 108; 100, pattern_list; 100, 101; 100, 102; 101, identifier:k; 102, identifier:v; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:relations; 106, identifier:iteritems; 107, argument_list; 108, block; 108, 109; 109, expression_statement; 109, 110; 110, call; 110, 111; 110, 112; 111, identifier:setattr; 112, argument_list; 112, 113; 112, 114; 112, 115; 113, identifier:instance; 114, identifier:k; 115, subscript; 115, 116; 115, 117; 116, identifier:v; 117, integer:0; 118, return_statement; 118, 119; 119, identifier:instance
def make_dummy(instance, relations = {}, datetime_default = dt.strptime('1901-01-01','%Y-%m-%d'), varchar_default = "", integer_default = 0, numeric_default = 0.0, *args, **kwargs ): init_data = { 'DATETIME' : datetime_default, 'VARCHAR' : varchar_default, 'INTEGER' : integer_default, 'NUMERIC(50, 10)' : numeric_default, 'TEXT' : varchar_default, } table = type(instance) for col in table.__table__.columns: try: setattr(instance, col.name, kwargs[col.name]) except KeyError: setattr(instance, col.name, init_data[str(col.type)]) for k,v in relations.iteritems(): setattr(instance, k, v[0]) return instance
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:read_headers; 3, parameters; 3, 4; 3, 5; 4, identifier:rfile; 5, default_parameter; 5, 6; 5, 7; 6, identifier:hdict; 7, None; 8, block; 8, 9; 8, 18; 8, 155; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifier:hdict; 12, None; 13, block; 13, 14; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:hdict; 17, dictionary; 18, while_statement; 18, 19; 18, 20; 19, True; 20, block; 20, 21; 20, 29; 20, 38; 20, 44; 20, 58; 20, 121; 20, 149; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:line; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:rfile; 27, identifier:readline; 28, argument_list; 29, if_statement; 29, 30; 29, 32; 30, not_operator; 30, 31; 31, identifier:line; 32, block; 32, 33; 33, raise_statement; 33, 34; 34, call; 34, 35; 34, 36; 35, identifier:ValueError; 36, argument_list; 36, 37; 37, string:"Illegal end of headers."; 38, if_statement; 38, 39; 38, 42; 39, comparison_operator:==; 39, 40; 39, 41; 40, identifier:line; 41, identifier:CRLF; 42, block; 42, 43; 43, break_statement; 44, if_statement; 44, 45; 44, 52; 45, not_operator; 45, 46; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:line; 49, identifier:endswith; 50, argument_list; 50, 51; 51, identifier:CRLF; 52, block; 52, 53; 53, raise_statement; 53, 54; 54, call; 54, 55; 54, 56; 55, identifier:ValueError; 56, argument_list; 56, 57; 57, string:"HTTP requires CRLF terminators"; 58, if_statement; 58, 59; 58, 64; 58, 73; 59, comparison_operator:in; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:line; 62, integer:0; 63, string:' \t'; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:v; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:line; 71, identifier:strip; 72, argument_list; 73, else_clause; 73, 74; 74, block; 74, 75; 74, 97; 74, 109; 74, 117; 75, try_statement; 75, 76; 75, 89; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 82; 79, pattern_list; 79, 80; 79, 81; 80, identifier:k; 81, identifier:v; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:line; 85, identifier:split; 86, argument_list; 86, 87; 86, 88; 87, string:":"; 88, integer:1; 89, except_clause; 89, 90; 89, 91; 90, identifier:ValueError; 91, block; 91, 92; 92, raise_statement; 92, 93; 93, call; 93, 94; 93, 95; 94, identifier:ValueError; 95, argument_list; 95, 96; 96, string:"Illegal header line."; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:k; 100, call; 100, 101; 100, 108; 101, attribute; 101, 102; 101, 107; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:k; 105, identifier:strip; 106, argument_list; 107, identifier:title; 108, argument_list; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:v; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:v; 115, identifier:strip; 116, argument_list; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:hname; 120, identifier:k; 121, if_statement; 121, 122; 121, 125; 122, comparison_operator:in; 122, 123; 122, 124; 123, identifier:k; 124, identifier:comma_separated_headers; 125, block; 125, 126; 125, 135; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:existing; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:hdict; 132, identifier:get; 133, argument_list; 133, 134; 134, identifier:hname; 135, if_statement; 135, 136; 135, 137; 136, identifier:existing; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:v; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, string:", "; 144, identifier:join; 145, argument_list; 145, 146; 146, tuple; 146, 147; 146, 148; 147, identifier:existing; 148, identifier:v; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 154; 151, subscript; 151, 152; 151, 153; 152, identifier:hdict; 153, identifier:hname; 154, identifier:v; 155, return_statement; 155, 156; 156, identifier:hdict
def read_headers(rfile, hdict=None): if hdict is None: hdict = {} while True: line = rfile.readline() if not line: raise ValueError("Illegal end of headers.") if line == CRLF: break if not line.endswith(CRLF): raise ValueError("HTTP requires CRLF terminators") if line[0] in ' \t': v = line.strip() else: try: k, v = line.split(":", 1) except ValueError: raise ValueError("Illegal header line.") k = k.strip().title() v = v.strip() hname = k if k in comma_separated_headers: existing = hdict.get(hname) if existing: v = ", ".join((existing, v)) hdict[hname] = v return hdict
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:send_headers; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 22; 5, 35; 5, 105; 5, 152; 5, 190; 5, 210; 5, 230; 5, 247; 5, 268; 5, 275; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:hkeys; 9, list_comprehension; 9, 10; 9, 15; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:key; 13, identifier:lower; 14, argument_list; 15, for_in_clause; 15, 16; 15, 19; 16, pattern_list; 16, 17; 16, 18; 17, identifier:key; 18, identifier:value; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:outheaders; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:status; 25, call; 25, 26; 25, 27; 26, identifier:int; 27, argument_list; 27, 28; 28, subscript; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:status; 32, slice; 32, 33; 32, 34; 33, colon; 34, integer:3; 35, if_statement; 35, 36; 35, 39; 35, 46; 36, comparison_operator:==; 36, 37; 36, 38; 37, identifier:status; 38, integer:413; 39, block; 39, 40; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:close_connection; 45, True; 46, elif_clause; 46, 47; 46, 50; 47, comparison_operator:not; 47, 48; 47, 49; 48, string:"content-length"; 49, identifier:hkeys; 50, block; 50, 51; 51, if_statement; 51, 52; 51, 62; 51, 64; 52, boolean_operator:or; 52, 53; 52, 56; 53, comparison_operator:<; 53, 54; 53, 55; 54, identifier:status; 55, integer:200; 56, comparison_operator:in; 56, 57; 56, 58; 57, identifier:status; 58, tuple; 58, 59; 58, 60; 58, 61; 59, integer:204; 60, integer:205; 61, integer:304; 62, block; 62, 63; 63, pass_statement; 64, else_clause; 64, 65; 65, block; 65, 66; 66, if_statement; 66, 67; 66, 79; 66, 97; 67, parenthesized_expression; 67, 68; 68, boolean_operator:and; 68, 69; 68, 74; 69, comparison_operator:==; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:response_protocol; 73, string:'HTTP/1.1'; 74, comparison_operator:!=; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:method; 78, string:'HEAD'; 79, block; 79, 80; 79, 86; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:chunked_write; 85, True; 86, expression_statement; 86, 87; 87, call; 87, 88; 87, 93; 88, attribute; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:outheaders; 92, identifier:append; 93, argument_list; 93, 94; 94, tuple; 94, 95; 94, 96; 95, string:"Transfer-Encoding"; 96, string:"chunked"; 97, else_clause; 97, 98; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:self; 103, identifier:close_connection; 104, True; 105, if_statement; 105, 106; 105, 109; 106, comparison_operator:not; 106, 107; 106, 108; 107, string:"connection"; 108, identifier:hkeys; 109, block; 109, 110; 110, if_statement; 110, 111; 110, 116; 110, 133; 111, comparison_operator:==; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:self; 114, identifier:response_protocol; 115, string:'HTTP/1.1'; 116, block; 116, 117; 117, if_statement; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:self; 120, identifier:close_connection; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 129; 124, attribute; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:self; 127, identifier:outheaders; 128, identifier:append; 129, argument_list; 129, 130; 130, tuple; 130, 131; 130, 132; 131, string:"Connection"; 132, string:"close"; 133, else_clause; 133, 134; 134, block; 134, 135; 135, if_statement; 135, 136; 135, 140; 136, not_operator; 136, 137; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:close_connection; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, call; 142, 143; 142, 148; 143, attribute; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:self; 146, identifier:outheaders; 147, identifier:append; 148, argument_list; 148, 149; 149, tuple; 149, 150; 149, 151; 150, string:"Connection"; 151, string:"Keep-Alive"; 152, if_statement; 152, 153; 152, 164; 153, boolean_operator:and; 153, 154; 153, 159; 154, parenthesized_expression; 154, 155; 155, not_operator; 155, 156; 156, attribute; 156, 157; 156, 158; 157, identifier:self; 158, identifier:close_connection; 159, parenthesized_expression; 159, 160; 160, not_operator; 160, 161; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:chunked_read; 164, block; 164, 165; 164, 176; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:remaining; 168, call; 168, 169; 168, 170; 169, identifier:getattr; 170, argument_list; 170, 171; 170, 174; 170, 175; 171, attribute; 171, 172; 171, 173; 172, identifier:self; 173, identifier:rfile; 174, string:'remaining'; 175, integer:0; 176, if_statement; 176, 177; 176, 180; 177, comparison_operator:>; 177, 178; 177, 179; 178, identifier:remaining; 179, integer:0; 180, block; 180, 181; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 188; 183, attribute; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:self; 186, identifier:rfile; 187, identifier:read; 188, argument_list; 188, 189; 189, identifier:remaining; 190, if_statement; 190, 191; 190, 194; 191, comparison_operator:not; 191, 192; 191, 193; 192, string:"date"; 193, identifier:hkeys; 194, block; 194, 195; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 202; 197, attribute; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:self; 200, identifier:outheaders; 201, identifier:append; 202, argument_list; 202, 203; 203, tuple; 203, 204; 203, 205; 204, string:"Date"; 205, call; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:rfc822; 208, identifier:formatdate; 209, argument_list; 210, if_statement; 210, 211; 210, 214; 211, comparison_operator:not; 211, 212; 211, 213; 212, string:"server"; 213, identifier:hkeys; 214, block; 214, 215; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 222; 217, attribute; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:self; 220, identifier:outheaders; 221, identifier:append; 222, argument_list; 222, 223; 223, tuple; 223, 224; 223, 225; 224, string:"Server"; 225, attribute; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:self; 228, identifier:server; 229, identifier:server_name; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:buf; 233, list:[self.server.protocol + " " + self.status + CRLF]; 233, 234; 234, binary_operator:+; 234, 235; 234, 246; 235, binary_operator:+; 235, 236; 235, 243; 236, binary_operator:+; 236, 237; 236, 242; 237, attribute; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:self; 240, identifier:server; 241, identifier:protocol; 242, string:" "; 243, attribute; 243, 244; 243, 245; 244, identifier:self; 245, identifier:status; 246, identifier:CRLF; 247, for_statement; 247, 248; 247, 251; 247, 254; 248, pattern_list; 248, 249; 248, 250; 249, identifier:k; 250, identifier:v; 251, attribute; 251, 252; 251, 253; 252, identifier:self; 253, identifier:outheaders; 254, block; 254, 255; 255, expression_statement; 255, 256; 256, call; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:buf; 259, identifier:append; 260, argument_list; 260, 261; 261, binary_operator:+; 261, 262; 261, 267; 262, binary_operator:+; 262, 263; 262, 266; 263, binary_operator:+; 263, 264; 263, 265; 264, identifier:k; 265, string:": "; 266, identifier:v; 267, identifier:CRLF; 268, expression_statement; 268, 269; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:buf; 272, identifier:append; 273, argument_list; 273, 274; 274, identifier:CRLF; 275, expression_statement; 275, 276; 276, call; 276, 277; 276, 284; 277, attribute; 277, 278; 277, 283; 278, attribute; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:self; 281, identifier:conn; 282, identifier:wfile; 283, identifier:sendall; 284, argument_list; 284, 285; 285, call; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, string:""; 288, identifier:join; 289, argument_list; 289, 290; 290, identifier:buf
def send_headers(self): hkeys = [key.lower() for key, value in self.outheaders] status = int(self.status[:3]) if status == 413: self.close_connection = True elif "content-length" not in hkeys: if status < 200 or status in (204, 205, 304): pass else: if (self.response_protocol == 'HTTP/1.1' and self.method != 'HEAD'): self.chunked_write = True self.outheaders.append(("Transfer-Encoding", "chunked")) else: self.close_connection = True if "connection" not in hkeys: if self.response_protocol == 'HTTP/1.1': if self.close_connection: self.outheaders.append(("Connection", "close")) else: if not self.close_connection: self.outheaders.append(("Connection", "Keep-Alive")) if (not self.close_connection) and (not self.chunked_read): remaining = getattr(self.rfile, 'remaining', 0) if remaining > 0: self.rfile.read(remaining) if "date" not in hkeys: self.outheaders.append(("Date", rfc822.formatdate())) if "server" not in hkeys: self.outheaders.append(("Server", self.server.server_name)) buf = [self.server.protocol + " " + self.status + CRLF] for k, v in self.outheaders: buf.append(k + ": " + v + CRLF) buf.append(CRLF) self.conn.wfile.sendall("".join(buf))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:setActivities; 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, 31; 9, 86; 9, 100; 9, 106; 10, function_definition; 10, 11; 10, 12; 10, 14; 11, function_name:activityDate; 12, parameters; 12, 13; 13, identifier:activity; 14, block; 14, 15; 15, try_statement; 15, 16; 15, 23; 16, block; 16, 17; 17, return_statement; 17, 18; 18, subscript; 18, 19; 18, 22; 19, subscript; 19, 20; 19, 21; 20, identifier:activity; 21, string:'activity'; 22, string:'timestamp'; 23, except_clause; 23, 24; 23, 28; 24, as_pattern; 24, 25; 24, 26; 25, identifier:KeyError; 26, as_pattern_target; 26, 27; 27, identifier:kerr; 28, block; 28, 29; 29, return_statement; 29, 30; 30, None; 31, try_statement; 31, 32; 31, 50; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:activities; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:mambuactivitiesclass; 40, argument_list; 40, 41; 40, 46; 40, 48; 41, keyword_argument; 41, 42; 41, 43; 42, identifier:groupId; 43, subscript; 43, 44; 43, 45; 44, identifier:self; 45, string:'encodedKey'; 46, list_splat; 46, 47; 47, identifier:args; 48, dictionary_splat; 48, 49; 49, identifier:kwargs; 50, except_clause; 50, 51; 50, 55; 51, as_pattern; 51, 52; 51, 53; 52, identifier:AttributeError; 53, as_pattern_target; 53, 54; 54, identifier:ae; 55, block; 55, 56; 55, 63; 55, 69; 56, import_from_statement; 56, 57; 56, 61; 57, relative_import; 57, 58; 57, 59; 58, import_prefix; 59, dotted_name; 59, 60; 60, identifier:mambuactivity; 61, dotted_name; 61, 62; 62, identifier:MambuActivities; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:mambuactivitiesclass; 68, identifier:MambuActivities; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:activities; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:mambuactivitiesclass; 76, argument_list; 76, 77; 76, 82; 76, 84; 77, keyword_argument; 77, 78; 77, 79; 78, identifier:groupId; 79, subscript; 79, 80; 79, 81; 80, identifier:self; 81, string:'encodedKey'; 82, list_splat; 82, 83; 83, identifier:args; 84, dictionary_splat; 84, 85; 85, identifier:kwargs; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:activities; 90, identifier:attrs; 91, call; 91, 92; 91, 93; 92, identifier:sorted; 93, argument_list; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:activities; 96, identifier:attrs; 97, keyword_argument; 97, 98; 97, 99; 98, identifier:key; 99, identifier:activityDate; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 105; 102, subscript; 102, 103; 102, 104; 103, identifier:self; 104, string:'activities'; 105, identifier:activities; 106, return_statement; 106, 107; 107, integer:1
def setActivities(self, *args, **kwargs): def activityDate(activity): try: return activity['activity']['timestamp'] except KeyError as kerr: return None try: activities = self.mambuactivitiesclass(groupId=self['encodedKey'], *args, **kwargs) except AttributeError as ae: from .mambuactivity import MambuActivities self.mambuactivitiesclass = MambuActivities activities = self.mambuactivitiesclass(groupId=self['encodedKey'], *args, **kwargs) activities.attrs = sorted(activities.attrs, key=activityDate) self['activities'] = activities return 1
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, 15; 9, 27; 9, 51; 9, 55; 9, 62; 9, 68; 9, 72; 9, 76; 9, 454; 9, 482; 10, import_from_statement; 10, 11; 10, 13; 11, dotted_name; 11, 12; 12, identifier:copy; 13, dotted_name; 13, 14; 14, identifier:deepcopy; 15, if_statement; 15, 16; 15, 17; 16, identifier:args; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:__args; 23, call; 23, 24; 23, 25; 24, identifier:deepcopy; 25, argument_list; 25, 26; 26, identifier:args; 27, if_statement; 27, 28; 27, 29; 28, identifier:kwargs; 29, block; 29, 30; 30, for_statement; 30, 31; 30, 34; 30, 39; 31, pattern_list; 31, 32; 31, 33; 32, identifier:k; 33, identifier:v; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:kwargs; 37, identifier:items; 38, argument_list; 39, block; 39, 40; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 47; 42, subscript; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:__kwargs; 46, identifier:k; 47, call; 47, 48; 47, 49; 48, identifier:deepcopy; 49, argument_list; 49, 50; 50, identifier:v; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:jsresp; 54, dictionary; 55, if_statement; 55, 56; 55, 60; 56, not_operator; 56, 57; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:__urlfunc; 60, block; 60, 61; 61, return_statement; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:offset; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:__offset; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:window; 71, True; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:jsresp; 75, dictionary; 76, while_statement; 76, 77; 76, 78; 77, identifier:window; 78, block; 78, 79; 78, 103; 78, 107; 78, 418; 78, 424; 79, if_statement; 79, 80; 79, 90; 79, 95; 80, boolean_operator:or; 80, 81; 80, 85; 81, not_operator; 81, 82; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:__limit; 85, comparison_operator:>; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:self; 88, identifier:__limit; 89, identifier:OUT_OF_BOUNDS_PAGINATION_LIMIT_VALUE; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:limit; 94, identifier:OUT_OF_BOUNDS_PAGINATION_LIMIT_VALUE; 95, else_clause; 95, 96; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:limit; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:__limit; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:retries; 106, integer:0; 107, while_statement; 107, 108; 107, 113; 107, 411; 108, comparison_operator:<; 108, 109; 108, 110; 109, identifier:retries; 110, attribute; 110, 111; 110, 112; 111, identifier:MambuStruct; 112, identifier:RETRIES; 113, block; 113, 114; 114, try_statement; 114, 115; 114, 384; 114, 392; 114, 403; 115, block; 115, 116; 115, 128; 115, 140; 115, 287; 115, 300; 115, 383; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:user; 119, call; 119, 120; 119, 125; 120, attribute; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:self; 123, identifier:__kwargs; 124, identifier:get; 125, argument_list; 125, 126; 125, 127; 126, string:'user'; 127, identifier:apiuser; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:pwd; 131, call; 131, 132; 131, 137; 132, attribute; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:__kwargs; 136, identifier:get; 137, argument_list; 137, 138; 137, 139; 138, string:'pwd'; 139, identifier:apipwd; 140, if_statement; 140, 141; 140, 144; 140, 243; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:__data; 144, block; 144, 145; 144, 152; 144, 166; 144, 194; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:headers; 148, dictionary; 148, 149; 149, pair; 149, 150; 149, 151; 150, string:'content-type'; 151, string:'application/json'; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:data; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:json; 158, identifier:dumps; 159, argument_list; 159, 160; 160, call; 160, 161; 160, 162; 161, identifier:encoded_dict; 162, argument_list; 162, 163; 163, attribute; 163, 164; 163, 165; 164, identifier:self; 165, identifier:__data; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 169; 168, identifier:url; 169, call; 169, 170; 169, 171; 170, identifier:iriToUri; 171, argument_list; 171, 172; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:self; 175, identifier:__urlfunc; 176, argument_list; 176, 177; 176, 180; 176, 183; 176, 186; 176, 190; 177, attribute; 177, 178; 177, 179; 178, identifier:self; 179, identifier:entid; 180, keyword_argument; 180, 181; 180, 182; 181, identifier:limit; 182, identifier:limit; 183, keyword_argument; 183, 184; 183, 185; 184, identifier:offset; 185, identifier:offset; 186, list_splat; 186, 187; 187, attribute; 187, 188; 187, 189; 188, identifier:self; 189, identifier:__args; 190, dictionary_splat; 190, 191; 191, attribute; 191, 192; 191, 193; 192, identifier:self; 193, identifier:__kwargs; 194, if_statement; 194, 195; 194, 200; 194, 221; 195, comparison_operator:==; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:self; 198, identifier:__method; 199, string:"PATCH"; 200, block; 200, 201; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:resp; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:requests; 207, identifier:patch; 208, argument_list; 208, 209; 208, 210; 208, 213; 208, 216; 209, identifier:url; 210, keyword_argument; 210, 211; 210, 212; 211, identifier:data; 212, identifier:data; 213, keyword_argument; 213, 214; 213, 215; 214, identifier:headers; 215, identifier:headers; 216, keyword_argument; 216, 217; 216, 218; 217, identifier:auth; 218, tuple; 218, 219; 218, 220; 219, identifier:user; 220, identifier:pwd; 221, else_clause; 221, 222; 222, block; 222, 223; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:resp; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:requests; 229, identifier:post; 230, argument_list; 230, 231; 230, 232; 230, 235; 230, 238; 231, identifier:url; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:data; 234, identifier:data; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:headers; 237, identifier:headers; 238, keyword_argument; 238, 239; 238, 240; 239, identifier:auth; 240, tuple; 240, 241; 240, 242; 241, identifier:user; 242, identifier:pwd; 243, else_clause; 243, 244; 244, block; 244, 245; 244, 273; 245, expression_statement; 245, 246; 246, assignment; 246, 247; 246, 248; 247, identifier:url; 248, call; 248, 249; 248, 250; 249, identifier:iriToUri; 250, argument_list; 250, 251; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:self; 254, identifier:__urlfunc; 255, argument_list; 255, 256; 255, 259; 255, 262; 255, 265; 255, 269; 256, attribute; 256, 257; 256, 258; 257, identifier:self; 258, identifier:entid; 259, keyword_argument; 259, 260; 259, 261; 260, identifier:limit; 261, identifier:limit; 262, keyword_argument; 262, 263; 262, 264; 263, identifier:offset; 264, identifier:offset; 265, list_splat; 265, 266; 266, attribute; 266, 267; 266, 268; 267, identifier:self; 268, identifier:__args; 269, dictionary_splat; 269, 270; 270, attribute; 270, 271; 270, 272; 271, identifier:self; 272, identifier:__kwargs; 273, expression_statement; 273, 274; 274, assignment; 274, 275; 274, 276; 275, identifier:resp; 276, call; 276, 277; 276, 280; 277, attribute; 277, 278; 277, 279; 278, identifier:requests; 279, identifier:get; 280, argument_list; 280, 281; 280, 282; 281, identifier:url; 282, keyword_argument; 282, 283; 282, 284; 283, identifier:auth; 284, tuple; 284, 285; 284, 286; 285, identifier:user; 286, identifier:pwd; 287, expression_statement; 287, 288; 288, call; 288, 289; 288, 294; 289, attribute; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:self; 292, identifier:rc; 293, identifier:add; 294, argument_list; 294, 295; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:datetime; 298, identifier:now; 299, argument_list; 300, try_statement; 300, 301; 300, 359; 300, 367; 301, block; 301, 302; 301, 313; 302, expression_statement; 302, 303; 303, assignment; 303, 304; 303, 305; 304, identifier:jsonresp; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:json; 308, identifier:loads; 309, argument_list; 309, 310; 310, attribute; 310, 311; 310, 312; 311, identifier:resp; 312, identifier:content; 313, if_statement; 313, 314; 313, 320; 313, 349; 314, comparison_operator:==; 314, 315; 314, 319; 315, call; 315, 316; 315, 317; 316, identifier:type; 317, argument_list; 317, 318; 318, identifier:jsonresp; 319, identifier:list; 320, block; 320, 321; 320, 337; 321, try_statement; 321, 322; 321, 330; 322, block; 322, 323; 323, expression_statement; 323, 324; 324, call; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:jsresp; 327, identifier:extend; 328, argument_list; 328, 329; 329, identifier:jsonresp; 330, except_clause; 330, 331; 330, 332; 331, identifier:AttributeError; 332, block; 332, 333; 333, expression_statement; 333, 334; 334, assignment; 334, 335; 334, 336; 335, identifier:jsresp; 336, identifier:jsonresp; 337, if_statement; 337, 338; 337, 344; 338, comparison_operator:<; 338, 339; 338, 343; 339, call; 339, 340; 339, 341; 340, identifier:len; 341, argument_list; 341, 342; 342, identifier:jsonresp; 343, identifier:limit; 344, block; 344, 345; 345, expression_statement; 345, 346; 346, assignment; 346, 347; 346, 348; 347, identifier:window; 348, False; 349, else_clause; 349, 350; 350, block; 350, 351; 350, 355; 351, expression_statement; 351, 352; 352, assignment; 352, 353; 352, 354; 353, identifier:jsresp; 354, identifier:jsonresp; 355, expression_statement; 355, 356; 356, assignment; 356, 357; 356, 358; 357, identifier:window; 358, False; 359, except_clause; 359, 360; 359, 364; 360, as_pattern; 360, 361; 360, 362; 361, identifier:ValueError; 362, as_pattern_target; 362, 363; 363, identifier:ex; 364, block; 364, 365; 365, raise_statement; 365, 366; 366, identifier:ex; 367, except_clause; 367, 368; 367, 372; 368, as_pattern; 368, 369; 368, 370; 369, identifier:Exception; 370, as_pattern_target; 370, 371; 371, identifier:ex; 372, block; 372, 373; 373, raise_statement; 373, 374; 374, call; 374, 375; 374, 376; 375, identifier:MambuError; 376, argument_list; 376, 377; 377, binary_operator:%; 377, 378; 377, 379; 378, string:"JSON Error: %s"; 379, call; 379, 380; 379, 381; 380, identifier:repr; 381, argument_list; 381, 382; 382, identifier:ex; 383, break_statement; 384, except_clause; 384, 385; 384, 389; 385, as_pattern; 385, 386; 385, 387; 386, identifier:MambuError; 387, as_pattern_target; 387, 388; 388, identifier:merr; 389, block; 389, 390; 390, raise_statement; 390, 391; 391, identifier:merr; 392, except_clause; 392, 393; 392, 398; 393, attribute; 393, 394; 393, 397; 394, attribute; 394, 395; 394, 396; 395, identifier:requests; 396, identifier:exceptions; 397, identifier:RequestException; 398, block; 398, 399; 399, expression_statement; 399, 400; 400, augmented_assignment:+=; 400, 401; 400, 402; 401, identifier:retries; 402, integer:1; 403, except_clause; 403, 404; 403, 408; 404, as_pattern; 404, 405; 404, 406; 405, identifier:Exception; 406, as_pattern_target; 406, 407; 407, identifier:ex; 408, block; 408, 409; 409, raise_statement; 409, 410; 410, identifier:ex; 411, else_clause; 411, 412; 412, block; 412, 413; 413, raise_statement; 413, 414; 414, call; 414, 415; 414, 416; 415, identifier:MambuCommError; 416, argument_list; 416, 417; 417, string:"ERROR I can't communicate with Mambu"; 418, expression_statement; 418, 419; 419, assignment; 419, 420; 419, 421; 420, identifier:offset; 421, binary_operator:+; 421, 422; 421, 423; 422, identifier:offset; 423, identifier:limit; 424, if_statement; 424, 425; 424, 428; 425, attribute; 425, 426; 425, 427; 426, identifier:self; 427, identifier:__limit; 428, block; 428, 429; 428, 435; 429, expression_statement; 429, 430; 430, augmented_assignment:-=; 430, 431; 430, 434; 431, attribute; 431, 432; 431, 433; 432, identifier:self; 433, identifier:__limit; 434, identifier:limit; 435, if_statement; 435, 436; 435, 441; 436, comparison_operator:<=; 436, 437; 436, 440; 437, attribute; 437, 438; 437, 439; 438, identifier:self; 439, identifier:__limit; 440, integer:0; 441, block; 441, 442; 441, 446; 442, expression_statement; 442, 443; 443, assignment; 443, 444; 443, 445; 444, identifier:window; 445, False; 446, expression_statement; 446, 447; 447, assignment; 447, 448; 447, 451; 448, attribute; 448, 449; 448, 450; 449, identifier:self; 450, identifier:__limit; 451, attribute; 451, 452; 451, 453; 452, identifier:self; 453, identifier:__inilimit; 454, try_statement; 454, 455; 454, 478; 455, block; 455, 456; 456, if_statement; 456, 457; 456, 470; 457, boolean_operator:and; 457, 458; 457, 465; 458, boolean_operator:and; 458, 459; 458, 462; 459, comparison_operator:in; 459, 460; 459, 461; 460, string:u'returnCode'; 461, identifier:jsresp; 462, comparison_operator:in; 462, 463; 462, 464; 463, string:u'returnStatus'; 464, identifier:jsresp; 465, comparison_operator:!=; 465, 466; 465, 469; 466, subscript; 466, 467; 466, 468; 467, identifier:jsresp; 468, string:u'returnCode'; 469, integer:0; 470, block; 470, 471; 471, raise_statement; 471, 472; 472, call; 472, 473; 472, 474; 473, identifier:MambuError; 474, argument_list; 474, 475; 475, subscript; 475, 476; 475, 477; 476, identifier:jsresp; 477, string:u'returnStatus'; 478, except_clause; 478, 479; 478, 480; 479, identifier:AttributeError; 480, block; 480, 481; 481, pass_statement; 482, if_statement; 482, 483; 482, 488; 483, comparison_operator:!=; 483, 484; 483, 487; 484, attribute; 484, 485; 484, 486; 485, identifier:self; 486, identifier:__method; 487, string:"PATCH"; 488, block; 488, 489; 489, expression_statement; 489, 490; 490, call; 490, 491; 490, 494; 491, attribute; 491, 492; 491, 493; 492, identifier:self; 493, identifier:init; 494, argument_list; 494, 495; 494, 498; 494, 502; 495, keyword_argument; 495, 496; 495, 497; 496, identifier:attrs; 497, identifier:jsresp; 498, list_splat; 498, 499; 499, attribute; 499, 500; 499, 501; 500, identifier:self; 501, identifier:__args; 502, dictionary_splat; 502, 503; 503, attribute; 503, 504; 503, 505; 504, identifier:self; 505, identifier:__kwargs
def connect(self, *args, **kwargs): from copy import deepcopy if args: self.__args = deepcopy(args) if kwargs: for k,v in kwargs.items(): self.__kwargs[k] = deepcopy(v) jsresp = {} if not self.__urlfunc: return offset = self.__offset window = True jsresp = {} while window: if not self.__limit or self.__limit > OUT_OF_BOUNDS_PAGINATION_LIMIT_VALUE: limit = OUT_OF_BOUNDS_PAGINATION_LIMIT_VALUE else: limit = self.__limit retries = 0 while retries < MambuStruct.RETRIES: try: user = self.__kwargs.get('user', apiuser) pwd = self.__kwargs.get('pwd', apipwd) if self.__data: headers = {'content-type': 'application/json'} data = json.dumps(encoded_dict(self.__data)) url = iriToUri(self.__urlfunc(self.entid, limit=limit, offset=offset, *self.__args, **self.__kwargs)) if self.__method=="PATCH": resp = requests.patch(url, data=data, headers=headers, auth=(user, pwd)) else: resp = requests.post(url, data=data, headers=headers, auth=(user, pwd)) else: url = iriToUri(self.__urlfunc(self.entid, limit=limit, offset=offset, *self.__args, **self.__kwargs)) resp = requests.get(url, auth=(user, pwd)) self.rc.add(datetime.now()) try: jsonresp = json.loads(resp.content) if type(jsonresp) == list: try: jsresp.extend(jsonresp) except AttributeError: jsresp=jsonresp if len(jsonresp) < limit: window = False else: jsresp = jsonresp window = False except ValueError as ex: raise ex except Exception as ex: raise MambuError("JSON Error: %s" % repr(ex)) break except MambuError as merr: raise merr except requests.exceptions.RequestException: retries += 1 except Exception as ex: raise ex else: raise MambuCommError("ERROR I can't communicate with Mambu") offset = offset + limit if self.__limit: self.__limit -= limit if self.__limit <= 0: window = False self.__limit = self.__inilimit try: if u'returnCode' in jsresp and u'returnStatus' in jsresp and jsresp[u'returnCode'] != 0: raise MambuError(jsresp[u'returnStatus']) except AttributeError: pass if self.__method != "PATCH": self.init(attrs=jsresp, *self.__args, **self.__kwargs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 37; 2, function_name:GetDirections; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 4, identifier:self; 5, identifier:origin; 6, identifier:destination; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sensor; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:mode; 12, None; 13, default_parameter; 13, 14; 13, 15; 14, identifier:waypoints; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:alternatives; 18, None; 19, default_parameter; 19, 20; 19, 21; 20, identifier:avoid; 21, None; 22, default_parameter; 22, 23; 22, 24; 23, identifier:language; 24, None; 25, default_parameter; 25, 26; 25, 27; 26, identifier:units; 27, None; 28, default_parameter; 28, 29; 28, 30; 29, identifier:region; 30, None; 31, default_parameter; 31, 32; 31, 33; 32, identifier:departure_time; 33, None; 34, default_parameter; 34, 35; 34, 36; 35, identifier:arrival_time; 36, None; 37, block; 37, 38; 37, 40; 37, 60; 37, 69; 37, 78; 37, 87; 37, 96; 37, 105; 37, 114; 37, 123; 37, 132; 37, 141; 37, 167; 38, expression_statement; 38, 39; 39, string:'''Get Directions Service Pls refer to the Google Maps Web API for the details of the remained parameters '''; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:params; 43, dictionary; 43, 44; 43, 47; 43, 50; 44, pair; 44, 45; 44, 46; 45, string:'origin'; 46, identifier:origin; 47, pair; 47, 48; 47, 49; 48, string:'destination'; 49, identifier:destination; 50, pair; 50, 51; 50, 52; 51, string:'sensor'; 52, call; 52, 53; 52, 59; 53, attribute; 53, 54; 53, 58; 54, call; 54, 55; 54, 56; 55, identifier:str; 56, argument_list; 56, 57; 57, identifier:sensor; 58, identifier:lower; 59, argument_list; 60, if_statement; 60, 61; 60, 62; 61, identifier:mode; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 68; 65, subscript; 65, 66; 65, 67; 66, identifier:params; 67, string:'mode'; 68, identifier:mode; 69, if_statement; 69, 70; 69, 71; 70, identifier:waypoints; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 77; 74, subscript; 74, 75; 74, 76; 75, identifier:params; 76, string:'waypoints'; 77, identifier:waypoints; 78, if_statement; 78, 79; 78, 80; 79, identifier:alternatives; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 86; 83, subscript; 83, 84; 83, 85; 84, identifier:params; 85, string:'alternatives'; 86, identifier:alternatives; 87, if_statement; 87, 88; 87, 89; 88, identifier:avoid; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 95; 92, subscript; 92, 93; 92, 94; 93, identifier:params; 94, string:'avoid'; 95, identifier:avoid; 96, if_statement; 96, 97; 96, 98; 97, identifier:language; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 104; 101, subscript; 101, 102; 101, 103; 102, identifier:params; 103, string:'language'; 104, identifier:language; 105, if_statement; 105, 106; 105, 107; 106, identifier:units; 107, block; 107, 108; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 113; 110, subscript; 110, 111; 110, 112; 111, identifier:params; 112, string:'units'; 113, identifier:units; 114, if_statement; 114, 115; 114, 116; 115, identifier:region; 116, block; 116, 117; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 122; 119, subscript; 119, 120; 119, 121; 120, identifier:params; 121, string:'region'; 122, identifier:region; 123, if_statement; 123, 124; 123, 125; 124, identifier:departure_time; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 131; 128, subscript; 128, 129; 128, 130; 129, identifier:params; 130, string:'departure_time'; 131, identifier:departure_time; 132, if_statement; 132, 133; 132, 134; 133, identifier:arrival_time; 134, block; 134, 135; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 140; 137, subscript; 137, 138; 137, 139; 138, identifier:params; 139, string:'arrival_time'; 140, identifier:arrival_time; 141, if_statement; 141, 142; 141, 146; 141, 156; 142, not_operator; 142, 143; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:premier; 146, block; 146, 147; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:url; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:self; 153, identifier:get_url; 154, argument_list; 154, 155; 155, identifier:params; 156, else_clause; 156, 157; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:url; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:self; 164, identifier:get_signed_url; 165, argument_list; 165, 166; 166, identifier:params; 167, return_statement; 167, 168; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:self; 171, identifier:GetService_url; 172, argument_list; 172, 173; 173, identifier:url
def GetDirections(self, origin, destination, sensor = False, mode = None, waypoints = None, alternatives = None, avoid = None, language = None, units = None, region = None, departure_time = None, arrival_time = None): '''Get Directions Service Pls refer to the Google Maps Web API for the details of the remained parameters ''' params = { 'origin': origin, 'destination': destination, 'sensor': str(sensor).lower() } if mode: params['mode'] = mode if waypoints: params['waypoints'] = waypoints if alternatives: params['alternatives'] = alternatives if avoid: params['avoid'] = avoid if language: params['language'] = language if units: params['units'] = units if region: params['region'] = region if departure_time: params['departure_time'] = departure_time if arrival_time: params['arrival_time'] = arrival_time if not self.premier: url = self.get_url(params) else: url = self.get_signed_url(params) return self.GetService_url(url)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:compactor; 3, parameters; 3, 4; 4, identifier:conf; 5, block; 5, 6; 5, 15; 5, 23; 5, 29; 5, 49; 5, 59; 5, 66; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:db; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:conf; 12, identifier:get_database; 13, argument_list; 13, 14; 14, string:'compactor'; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:limit_map; 18, call; 18, 19; 18, 20; 19, identifier:LimitContainer; 20, argument_list; 20, 21; 20, 22; 21, identifier:conf; 22, identifier:db; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:config; 26, subscript; 26, 27; 26, 28; 27, identifier:conf; 28, string:'compactor'; 29, if_statement; 29, 30; 29, 38; 30, comparison_operator:<=; 30, 31; 30, 37; 31, call; 31, 32; 31, 33; 32, identifier:get_int; 33, argument_list; 33, 34; 33, 35; 33, 36; 34, identifier:config; 35, string:'max_updates'; 36, integer:0; 37, integer:0; 38, block; 38, 39; 39, expression_statement; 39, 40; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:LOG; 43, identifier:warning; 44, argument_list; 44, 45; 45, concatenated_string; 45, 46; 45, 47; 45, 48; 46, string:"Compaction is not enabled. Enable it by "; 47, string:"setting a positive integer value for "; 48, string:"'compactor.max_updates' in the configuration."; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:key_getter; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:GetBucketKey; 55, identifier:factory; 56, argument_list; 56, 57; 56, 58; 57, identifier:config; 58, identifier:db; 59, expression_statement; 59, 60; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:LOG; 63, identifier:info; 64, argument_list; 64, 65; 65, string:"Compactor initialized"; 66, while_statement; 66, 67; 66, 68; 67, True; 68, block; 68, 69; 68, 100; 68, 108; 68, 133; 68, 142; 69, try_statement; 69, 70; 69, 84; 70, block; 70, 71; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:buck_key; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:limits; 78, identifier:BucketKey; 79, identifier:decode; 80, argument_list; 80, 81; 81, call; 81, 82; 81, 83; 82, identifier:key_getter; 83, argument_list; 84, except_clause; 84, 85; 84, 89; 85, as_pattern; 85, 86; 85, 87; 86, identifier:ValueError; 87, as_pattern_target; 87, 88; 88, identifier:exc; 89, block; 89, 90; 89, 99; 90, expression_statement; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:LOG; 94, identifier:warning; 95, argument_list; 95, 96; 96, binary_operator:%; 96, 97; 96, 98; 97, string:"Error interpreting bucket key: %s"; 98, identifier:exc; 99, continue_statement; 100, if_statement; 100, 101; 100, 106; 101, comparison_operator:<; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:buck_key; 104, identifier:version; 105, integer:2; 106, block; 106, 107; 107, continue_statement; 108, try_statement; 108, 109; 108, 118; 109, block; 109, 110; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:limit; 113, subscript; 113, 114; 113, 115; 114, identifier:limit_map; 115, attribute; 115, 116; 115, 117; 116, identifier:buck_key; 117, identifier:uuid; 118, except_clause; 118, 119; 118, 120; 119, identifier:KeyError; 120, block; 120, 121; 120, 132; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:LOG; 125, identifier:warning; 126, argument_list; 126, 127; 127, binary_operator:%; 127, 128; 127, 129; 128, string:"Unable to compact bucket for limit %s"; 129, attribute; 129, 130; 129, 131; 130, identifier:buck_key; 131, identifier:uuid; 132, continue_statement; 133, expression_statement; 133, 134; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:LOG; 137, identifier:debug; 138, argument_list; 138, 139; 139, binary_operator:%; 139, 140; 139, 141; 140, string:"Compacting bucket %s"; 141, identifier:buck_key; 142, try_statement; 142, 143; 142, 151; 142, 163; 143, block; 143, 144; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 147; 146, identifier:compact_bucket; 147, argument_list; 147, 148; 147, 149; 147, 150; 148, identifier:db; 149, identifier:buck_key; 150, identifier:limit; 151, except_clause; 151, 152; 151, 153; 152, identifier:Exception; 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:exception; 159, argument_list; 159, 160; 160, binary_operator:%; 160, 161; 160, 162; 161, string:"Failed to compact bucket %s"; 162, identifier:buck_key; 163, else_clause; 163, 164; 164, block; 164, 165; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:LOG; 169, identifier:debug; 170, argument_list; 170, 171; 171, binary_operator:%; 171, 172; 171, 173; 172, string:"Finished compacting bucket %s"; 173, identifier:buck_key
def compactor(conf): db = conf.get_database('compactor') limit_map = LimitContainer(conf, db) config = conf['compactor'] if get_int(config, 'max_updates', 0) <= 0: LOG.warning("Compaction is not enabled. Enable it by " "setting a positive integer value for " "'compactor.max_updates' in the configuration.") key_getter = GetBucketKey.factory(config, db) LOG.info("Compactor initialized") while True: try: buck_key = limits.BucketKey.decode(key_getter()) except ValueError as exc: LOG.warning("Error interpreting bucket key: %s" % exc) continue if buck_key.version < 2: continue try: limit = limit_map[buck_key.uuid] except KeyError: LOG.warning("Unable to compact bucket for limit %s" % buck_key.uuid) continue LOG.debug("Compacting bucket %s" % buck_key) try: compact_bucket(db, buck_key, limit) except Exception: LOG.exception("Failed to compact bucket %s" % buck_key) else: LOG.debug("Finished compacting bucket %s" % buck_key)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:now; 6, block; 6, 7; 7, with_statement; 7, 8; 7, 13; 8, with_clause; 8, 9; 9, with_item; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:lock; 13, block; 13, 14; 13, 39; 13, 45; 13, 51; 13, 60; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:items; 17, call; 17, 18; 17, 23; 18, attribute; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:db; 22, identifier:zrangebyscore; 23, argument_list; 23, 24; 23, 27; 23, 28; 23, 33; 23, 36; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:key; 27, integer:0; 28, binary_operator:-; 28, 29; 28, 30; 29, identifier:now; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:min_age; 33, keyword_argument; 33, 34; 33, 35; 34, identifier:start; 35, integer:0; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:num; 38, integer:1; 39, if_statement; 39, 40; 39, 42; 40, not_operator; 40, 41; 41, identifier:items; 42, block; 42, 43; 43, return_statement; 43, 44; 44, None; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:item; 48, subscript; 48, 49; 48, 50; 49, identifier:items; 50, integer:0; 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:db; 57, identifier:zrem; 58, argument_list; 58, 59; 59, identifier:item; 60, return_statement; 60, 61; 61, identifier:item
def get(self, now): with self.lock: items = self.db.zrangebyscore(self.key, 0, now - self.min_age, start=0, num=1) if not items: return None item = items[0] self.db.zrem(item) return item
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:now; 6, block; 6, 7; 6, 29; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:items; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:script; 14, argument_list; 14, 15; 14, 21; 15, keyword_argument; 15, 16; 15, 17; 16, identifier:keys; 17, list:[self.key]; 17, 18; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:key; 21, keyword_argument; 21, 22; 21, 23; 22, identifier:args; 23, list:[now - self.min_age]; 23, 24; 24, binary_operator:-; 24, 25; 24, 26; 25, identifier:now; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:min_age; 29, return_statement; 29, 30; 30, conditional_expression:if; 30, 31; 30, 34; 30, 35; 31, subscript; 31, 32; 31, 33; 32, identifier:items; 33, integer:0; 34, identifier:items; 35, None
def get(self, now): items = self.script(keys=[self.key], args=[now - self.min_age]) return items[0] if items else None
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main_cli; 3, parameters; 4, block; 4, 5; 4, 11; 4, 17; 4, 23; 4, 29; 4, 35; 4, 41; 4, 45; 4, 100; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:args; 8, call; 8, 9; 8, 10; 9, identifier:_cli_argument_parser; 10, argument_list; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:delta_secs; 14, attribute; 14, 15; 14, 16; 15, identifier:args; 16, identifier:delay; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:i2cbus; 20, attribute; 20, 21; 20, 22; 21, identifier:args; 22, identifier:bus; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:i2c_address; 26, attribute; 26, 27; 26, 28; 27, identifier:args; 28, identifier:address; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:sensor_key; 32, attribute; 32, 33; 32, 34; 33, identifier:args; 34, identifier:sensor; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:sensor_params; 38, attribute; 38, 39; 38, 40; 39, identifier:args; 40, identifier:params; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:params; 44, dictionary; 45, if_statement; 45, 46; 45, 47; 46, identifier:sensor_params; 47, block; 47, 48; 47, 86; 48, function_definition; 48, 49; 48, 50; 48, 52; 49, function_name:_parse_param; 50, parameters; 50, 51; 51, identifier:str_param; 52, block; 52, 53; 52, 64; 52, 77; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 58; 55, pattern_list; 55, 56; 55, 57; 56, identifier:key; 57, identifier:value; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:str_param; 61, identifier:split; 62, argument_list; 62, 63; 63, string:'='; 64, try_statement; 64, 65; 64, 73; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:value; 69, call; 69, 70; 69, 71; 70, identifier:int; 71, argument_list; 71, 72; 72, identifier:value; 73, except_clause; 73, 74; 73, 75; 74, identifier:ValueError; 75, block; 75, 76; 76, pass_statement; 77, return_statement; 77, 78; 78, dictionary; 78, 79; 79, pair; 79, 80; 79, 85; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:key; 83, identifier:strip; 84, argument_list; 85, identifier:value; 86, expression_statement; 86, 87; 87, list_comprehension; 87, 88; 87, 97; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:params; 91, identifier:update; 92, argument_list; 92, 93; 93, call; 93, 94; 93, 95; 94, identifier:_parse_param; 95, argument_list; 95, 96; 96, identifier:sp; 97, for_in_clause; 97, 98; 97, 99; 98, identifier:sp; 99, identifier:sensor_params; 100, if_statement; 100, 101; 100, 102; 100, 244; 101, identifier:sensor_key; 102, block; 102, 103; 102, 108; 102, 143; 102, 171; 102, 191; 102, 201; 103, import_from_statement; 103, 104; 103, 106; 104, dotted_name; 104, 105; 105, identifier:time; 106, dotted_name; 106, 107; 107, identifier:sleep; 108, try_statement; 108, 109; 108, 122; 109, block; 109, 110; 109, 113; 110, import_statement; 110, 111; 111, dotted_name; 111, 112; 112, identifier:smbus; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:bus_handler; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:smbus; 119, identifier:SMBus; 120, argument_list; 120, 121; 121, identifier:i2cbus; 122, except_clause; 122, 123; 122, 127; 123, as_pattern; 123, 124; 123, 125; 124, identifier:ImportError; 125, as_pattern_target; 125, 126; 126, identifier:exc; 127, block; 127, 128; 127, 135; 128, expression_statement; 128, 129; 129, call; 129, 130; 129, 131; 130, identifier:print; 131, argument_list; 131, 132; 131, 133; 131, 134; 132, identifier:exc; 133, string:"\n"; 134, string:"Please install smbus-cffi before."; 135, expression_statement; 135, 136; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:sys; 139, identifier:exit; 140, argument_list; 140, 141; 141, unary_operator:-; 141, 142; 142, integer:1; 143, try_statement; 143, 144; 143, 153; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 150; 147, pattern_list; 147, 148; 147, 149; 148, identifier:sensor_handler; 149, identifier:i2c_default_address; 150, subscript; 150, 151; 150, 152; 151, identifier:SENSORS; 152, identifier:sensor_key; 153, except_clause; 153, 154; 153, 155; 154, identifier:KeyError; 155, block; 155, 156; 155, 163; 156, expression_statement; 156, 157; 157, call; 157, 158; 157, 159; 158, identifier:print; 159, argument_list; 159, 160; 160, binary_operator:%; 160, 161; 160, 162; 161, string:"'%s' is not recognized as an implemented i2c sensor."; 162, identifier:sensor_key; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:sys; 167, identifier:exit; 168, argument_list; 168, 169; 169, unary_operator:-; 169, 170; 170, integer:1; 171, if_statement; 171, 172; 171, 173; 171, 185; 172, identifier:i2c_address; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:i2c_address; 177, call; 177, 178; 177, 179; 178, identifier:hex; 179, argument_list; 179, 180; 180, call; 180, 181; 180, 182; 181, identifier:int; 182, argument_list; 182, 183; 182, 184; 183, identifier:i2c_address; 184, integer:0; 185, else_clause; 185, 186; 186, block; 186, 187; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 190; 189, identifier:i2c_address; 190, identifier:i2c_default_address; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:sensor; 194, call; 194, 195; 194, 196; 195, identifier:sensor_handler; 196, argument_list; 196, 197; 196, 198; 196, 199; 197, identifier:bus_handler; 198, identifier:i2c_address; 199, dictionary_splat; 199, 200; 200, identifier:params; 201, try_statement; 201, 202; 201, 236; 202, block; 202, 203; 203, while_statement; 203, 204; 203, 205; 204, True; 205, block; 205, 206; 205, 212; 205, 224; 205, 231; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:sensor; 210, identifier:update; 211, argument_list; 212, if_statement; 212, 213; 212, 217; 213, not_operator; 213, 214; 214, attribute; 214, 215; 214, 216; 215, identifier:sensor; 216, identifier:sample_ok; 217, block; 217, 218; 217, 223; 218, expression_statement; 218, 219; 219, call; 219, 220; 219, 221; 220, identifier:print; 221, argument_list; 221, 222; 222, string:"An error has occured."; 223, break_statement; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 227; 226, identifier:print; 227, argument_list; 227, 228; 228, attribute; 228, 229; 228, 230; 229, identifier:sensor; 230, identifier:current_state_str; 231, expression_statement; 231, 232; 232, call; 232, 233; 232, 234; 233, identifier:sleep; 234, argument_list; 234, 235; 235, identifier:delta_secs; 236, except_clause; 236, 237; 236, 238; 237, identifier:KeyboardInterrupt; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 242; 241, identifier:print; 242, argument_list; 242, 243; 243, string:"Bye!"; 244, else_clause; 244, 245; 245, block; 245, 246; 245, 251; 245, 260; 245, 307; 245, 344; 246, import_from_statement; 246, 247; 246, 249; 247, dotted_name; 247, 248; 248, identifier:subprocess; 249, dotted_name; 249, 250; 250, identifier:check_output; 251, expression_statement; 251, 252; 252, assignment; 252, 253; 252, 254; 253, identifier:cmd; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, string:'/usr/sbin/i2cdetect -y {}'; 257, identifier:format; 258, argument_list; 258, 259; 259, identifier:i2cbus; 260, try_statement; 260, 261; 260, 291; 261, block; 261, 262; 261, 273; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 265; 264, identifier:output; 265, call; 265, 266; 265, 267; 266, identifier:check_output; 267, argument_list; 267, 268; 268, call; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:cmd; 271, identifier:split; 272, argument_list; 273, expression_statement; 273, 274; 274, call; 274, 275; 274, 276; 275, identifier:print; 276, argument_list; 276, 277; 277, call; 277, 278; 277, 283; 278, attribute; 278, 279; 278, 282; 279, concatenated_string; 279, 280; 279, 281; 280, string:"Running i2cdetect utility in i2c bus {}:\n"; 281, string:"The command '{}' has returned:\n{}"; 282, identifier:format; 283, argument_list; 283, 284; 283, 285; 283, 286; 284, identifier:i2cbus; 285, identifier:cmd; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:output; 289, identifier:decode; 290, argument_list; 291, except_clause; 291, 292; 291, 293; 292, identifier:FileNotFoundError; 293, block; 293, 294; 293, 299; 294, expression_statement; 294, 295; 295, call; 295, 296; 295, 297; 296, identifier:print; 297, argument_list; 297, 298; 298, string:"Please install i2cdetect before."; 299, expression_statement; 299, 300; 300, call; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:sys; 303, identifier:exit; 304, argument_list; 304, 305; 305, unary_operator:-; 305, 306; 306, integer:1; 307, expression_statement; 307, 308; 308, assignment; 308, 309; 308, 310; 309, identifier:addresses; 310, list_comprehension; 310, 311; 310, 314; 310, 329; 310, 340; 311, binary_operator:+; 311, 312; 311, 313; 312, string:'0x'; 313, identifier:l; 314, for_in_clause; 314, 315; 314, 316; 315, identifier:line; 316, subscript; 316, 317; 316, 326; 317, call; 317, 318; 317, 325; 318, attribute; 318, 319; 318, 324; 319, call; 319, 320; 319, 323; 320, attribute; 320, 321; 320, 322; 321, identifier:output; 322, identifier:decode; 323, argument_list; 324, identifier:splitlines; 325, argument_list; 326, slice; 326, 327; 326, 328; 327, integer:1; 328, colon; 329, for_in_clause; 329, 330; 329, 331; 330, identifier:l; 331, subscript; 331, 332; 331, 337; 332, call; 332, 333; 332, 336; 333, attribute; 333, 334; 333, 335; 334, identifier:line; 335, identifier:split; 336, argument_list; 337, slice; 337, 338; 337, 339; 338, integer:1; 339, colon; 340, if_clause; 340, 341; 341, comparison_operator:!=; 341, 342; 341, 343; 342, identifier:l; 343, string:'--'; 344, if_statement; 344, 345; 344, 346; 344, 366; 345, identifier:addresses; 346, block; 346, 347; 347, expression_statement; 347, 348; 348, call; 348, 349; 348, 350; 349, identifier:print; 350, argument_list; 350, 351; 351, call; 351, 352; 351, 355; 352, attribute; 352, 353; 352, 354; 353, string:"{} sensors detected in {}"; 354, identifier:format; 355, argument_list; 355, 356; 355, 360; 356, call; 356, 357; 356, 358; 357, identifier:len; 358, argument_list; 358, 359; 359, identifier:addresses; 360, call; 360, 361; 360, 364; 361, attribute; 361, 362; 361, 363; 362, string:', '; 363, identifier:join; 364, argument_list; 364, 365; 365, identifier:addresses; 366, else_clause; 366, 367; 367, block; 367, 368; 368, expression_statement; 368, 369; 369, call; 369, 370; 369, 371; 370, identifier:print; 371, argument_list; 371, 372; 372, string:"No i2c sensors detected."
def main_cli(): args = _cli_argument_parser() delta_secs = args.delay i2cbus = args.bus i2c_address = args.address sensor_key = args.sensor sensor_params = args.params params = {} if sensor_params: def _parse_param(str_param): key, value = str_param.split('=') try: value = int(value) except ValueError: pass return {key.strip(): value} [params.update(_parse_param(sp)) for sp in sensor_params] if sensor_key: from time import sleep try: import smbus bus_handler = smbus.SMBus(i2cbus) except ImportError as exc: print(exc, "\n", "Please install smbus-cffi before.") sys.exit(-1) try: sensor_handler, i2c_default_address = SENSORS[sensor_key] except KeyError: print("'%s' is not recognized as an implemented i2c sensor." % sensor_key) sys.exit(-1) if i2c_address: i2c_address = hex(int(i2c_address, 0)) else: i2c_address = i2c_default_address sensor = sensor_handler(bus_handler, i2c_address, **params) try: while True: sensor.update() if not sensor.sample_ok: print("An error has occured.") break print(sensor.current_state_str) sleep(delta_secs) except KeyboardInterrupt: print("Bye!") else: from subprocess import check_output cmd = '/usr/sbin/i2cdetect -y {}'.format(i2cbus) try: output = check_output(cmd.split()) print("Running i2cdetect utility in i2c bus {}:\n" "The command '{}' has returned:\n{}" .format(i2cbus, cmd, output.decode())) except FileNotFoundError: print("Please install i2cdetect before.") sys.exit(-1) addresses = ['0x' + l for line in output.decode().splitlines()[1:] for l in line.split()[1:] if l != '--'] if addresses: print("{} sensors detected in {}" .format(len(addresses), ', '.join(addresses))) else: print("No i2c sensors detected.")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:variant_support; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:variants; 5, identifier:allele_support_df; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_missing; 8, False; 9, block; 9, 10; 9, 12; 9, 26; 9, 41; 9, 59; 9, 72; 9, 81; 9, 119; 9, 126; 9, 141; 9, 338; 9, 364; 10, expression_statement; 10, 11; 11, string:''' Collect the read evidence support for the given variants. Parameters ---------- variants : iterable of varcode.Variant allele_support_df : dataframe Allele support dataframe, as output by the varlens-allele-support tool. It should have columns: source, contig, interbase_start, interbase_end, allele. The remaining columns are interpreted as read counts of various subsets of reads (e.g. all reads, non-duplicate reads, etc.) ignore_missing : boolean If True, then varaints with no allele counts will be interpreted as having 0 depth. If False, then an exception will be raised if any variants have no allele counts. Returns ---------- A pandas.Panel4D frame with these axes: labels (axis=0) : the type of read being counted, i.e. the read count fields in allele_support_df. items (axis=1) : the type of measurement (num_alt, num_ref, num_other, total_depth, alt_fraction, any_alt_fraction) major axis (axis=2) : the variants minor axis (axis=3) : the sources '''; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:missing; 15, list_comprehension; 15, 16; 15, 17; 15, 20; 16, identifier:c; 17, for_in_clause; 17, 18; 17, 19; 18, identifier:c; 19, identifier:EXPECTED_COLUMNS; 20, if_clause; 20, 21; 21, comparison_operator:not; 21, 22; 21, 23; 22, identifier:c; 23, attribute; 23, 24; 23, 25; 24, identifier:allele_support_df; 25, identifier:columns; 26, if_statement; 26, 27; 26, 28; 27, identifier:missing; 28, block; 28, 29; 29, raise_statement; 29, 30; 30, call; 30, 31; 30, 32; 31, identifier:ValueError; 32, argument_list; 32, 33; 33, binary_operator:%; 33, 34; 33, 35; 34, string:"Missing columns: %s"; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, string:" "; 38, identifier:join; 39, argument_list; 39, 40; 40, identifier:missing; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 48; 43, subscript; 43, 44; 43, 45; 44, identifier:allele_support_df; 45, list:["interbase_start", "interbase_end"]; 45, 46; 45, 47; 46, string:"interbase_start"; 47, string:"interbase_end"; 48, parenthesized_expression; 48, 49; 49, call; 49, 50; 49, 57; 50, attribute; 50, 51; 50, 56; 51, subscript; 51, 52; 51, 53; 52, identifier:allele_support_df; 53, list:["interbase_start", "interbase_end"]; 53, 54; 53, 55; 54, string:"interbase_start"; 55, string:"interbase_end"; 56, identifier:astype; 57, argument_list; 57, 58; 58, identifier:int; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:sources; 62, call; 62, 63; 62, 64; 63, identifier:sorted; 64, argument_list; 64, 65; 65, call; 65, 66; 65, 71; 66, attribute; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:allele_support_df; 69, string:"source"; 70, identifier:unique; 71, argument_list; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:allele_support_dict; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:collections; 78, identifier:defaultdict; 79, argument_list; 79, 80; 80, identifier:dict; 81, for_statement; 81, 82; 81, 85; 81, 90; 82, tuple_pattern; 82, 83; 82, 84; 83, identifier:i; 84, identifier:row; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:allele_support_df; 88, identifier:iterrows; 89, argument_list; 90, block; 90, 91; 90, 107; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:key; 94, tuple; 94, 95; 94, 98; 94, 101; 94, 104; 95, subscript; 95, 96; 95, 97; 96, identifier:row; 97, string:'source'; 98, attribute; 98, 99; 98, 100; 99, identifier:row; 100, identifier:contig; 101, attribute; 101, 102; 101, 103; 102, identifier:row; 103, identifier:interbase_start; 104, attribute; 104, 105; 104, 106; 105, identifier:row; 106, identifier:interbase_end; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 116; 109, subscript; 109, 110; 109, 113; 110, subscript; 110, 111; 110, 112; 111, identifier:allele_support_dict; 112, identifier:key; 113, attribute; 113, 114; 113, 115; 114, identifier:row; 115, identifier:allele; 116, subscript; 116, 117; 116, 118; 117, identifier:row; 118, string:"count"; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:allele_support_dict; 122, call; 122, 123; 122, 124; 123, identifier:dict; 124, argument_list; 124, 125; 125, identifier:allele_support_dict; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:dataframe_dicts; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:collections; 132, identifier:defaultdict; 133, argument_list; 133, 134; 134, lambda; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:collections; 138, identifier:defaultdict; 139, argument_list; 139, 140; 140, identifier:list; 141, for_statement; 141, 142; 141, 143; 141, 144; 142, identifier:variant; 143, identifier:variants; 144, block; 144, 145; 145, for_statement; 145, 146; 145, 147; 145, 148; 146, identifier:source; 147, identifier:sources; 148, block; 148, 149; 148, 165; 148, 209; 148, 221; 148, 233; 148, 244; 148, 252; 148, 263; 148, 274; 148, 285; 148, 296; 148, 316; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:key; 152, tuple; 152, 153; 152, 154; 152, 157; 152, 162; 153, identifier:source; 154, attribute; 154, 155; 154, 156; 155, identifier:variant; 156, identifier:contig; 157, binary_operator:-; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:variant; 160, identifier:start; 161, integer:1; 162, attribute; 162, 163; 162, 164; 163, identifier:variant; 164, identifier:end; 165, try_statement; 165, 166; 165, 173; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:alleles; 170, subscript; 170, 171; 170, 172; 171, identifier:allele_support_dict; 172, identifier:key; 173, except_clause; 173, 174; 173, 175; 174, identifier:KeyError; 175, block; 175, 176; 175, 188; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:message; 179, parenthesized_expression; 179, 180; 180, binary_operator:%; 180, 181; 180, 182; 181, string:"No allele counts in source %s for variant %s"; 182, tuple; 182, 183; 182, 184; 183, identifier:source; 184, call; 184, 185; 184, 186; 185, identifier:str; 186, argument_list; 186, 187; 187, identifier:variant; 188, if_statement; 188, 189; 188, 190; 188, 202; 189, identifier:ignore_missing; 190, block; 190, 191; 190, 198; 191, expression_statement; 191, 192; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:logging; 195, identifier:warning; 196, argument_list; 196, 197; 197, identifier:message; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:alleles; 201, dictionary; 202, else_clause; 202, 203; 203, block; 203, 204; 204, raise_statement; 204, 205; 205, call; 205, 206; 205, 207; 206, identifier:ValueError; 207, argument_list; 207, 208; 208, identifier:message; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:alt; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:alleles; 215, identifier:get; 216, argument_list; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:variant; 219, identifier:alt; 220, integer:0; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:ref; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:alleles; 227, identifier:get; 228, argument_list; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:variant; 231, identifier:ref; 232, integer:0; 233, expression_statement; 233, 234; 234, assignment; 234, 235; 234, 236; 235, identifier:total; 236, call; 236, 237; 236, 238; 237, identifier:sum; 238, argument_list; 238, 239; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:alleles; 242, identifier:values; 243, argument_list; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 247; 246, identifier:other; 247, binary_operator:-; 247, 248; 247, 251; 248, binary_operator:-; 248, 249; 248, 250; 249, identifier:total; 250, identifier:alt; 251, identifier:ref; 252, expression_statement; 252, 253; 253, call; 253, 254; 253, 261; 254, attribute; 254, 255; 254, 260; 255, subscript; 255, 256; 255, 259; 256, subscript; 256, 257; 256, 258; 257, identifier:dataframe_dicts; 258, string:"num_alt"; 259, identifier:source; 260, identifier:append; 261, argument_list; 261, 262; 262, identifier:alt; 263, expression_statement; 263, 264; 264, call; 264, 265; 264, 272; 265, attribute; 265, 266; 265, 271; 266, subscript; 266, 267; 266, 270; 267, subscript; 267, 268; 267, 269; 268, identifier:dataframe_dicts; 269, string:"num_ref"; 270, identifier:source; 271, identifier:append; 272, argument_list; 272, 273; 273, identifier:ref; 274, expression_statement; 274, 275; 275, call; 275, 276; 275, 283; 276, attribute; 276, 277; 276, 282; 277, subscript; 277, 278; 277, 281; 278, subscript; 278, 279; 278, 280; 279, identifier:dataframe_dicts; 280, string:"num_other"; 281, identifier:source; 282, identifier:append; 283, argument_list; 283, 284; 284, identifier:other; 285, expression_statement; 285, 286; 286, call; 286, 287; 286, 294; 287, attribute; 287, 288; 287, 293; 288, subscript; 288, 289; 288, 292; 289, subscript; 289, 290; 289, 291; 290, identifier:dataframe_dicts; 291, string:"total_depth"; 292, identifier:source; 293, identifier:append; 294, argument_list; 294, 295; 295, identifier:total; 296, expression_statement; 296, 297; 297, call; 297, 298; 297, 305; 298, attribute; 298, 299; 298, 304; 299, subscript; 299, 300; 299, 303; 300, subscript; 300, 301; 300, 302; 301, identifier:dataframe_dicts; 302, string:"alt_fraction"; 303, identifier:source; 304, identifier:append; 305, argument_list; 305, 306; 306, binary_operator:/; 306, 307; 306, 311; 307, call; 307, 308; 307, 309; 308, identifier:float; 309, argument_list; 309, 310; 310, identifier:alt; 311, call; 311, 312; 311, 313; 312, identifier:max; 313, argument_list; 313, 314; 313, 315; 314, integer:1; 315, identifier:total; 316, expression_statement; 316, 317; 317, call; 317, 318; 317, 325; 318, attribute; 318, 319; 318, 324; 319, subscript; 319, 320; 319, 323; 320, subscript; 320, 321; 320, 322; 321, identifier:dataframe_dicts; 322, string:"any_alt_fraction"; 323, identifier:source; 324, identifier:append; 325, argument_list; 325, 326; 326, binary_operator:/; 326, 327; 326, 333; 327, call; 327, 328; 327, 329; 328, identifier:float; 329, argument_list; 329, 330; 330, binary_operator:+; 330, 331; 330, 332; 331, identifier:alt; 332, identifier:other; 333, call; 333, 334; 333, 335; 334, identifier:max; 335, argument_list; 335, 336; 335, 337; 336, integer:1; 337, identifier:total; 338, expression_statement; 338, 339; 339, assignment; 339, 340; 339, 341; 340, identifier:dataframes; 341, call; 341, 342; 341, 343; 342, identifier:dict; 343, generator_expression; 343, 344; 343, 355; 344, tuple; 344, 345; 344, 346; 345, identifier:label; 346, call; 346, 347; 346, 350; 347, attribute; 347, 348; 347, 349; 348, identifier:pandas; 349, identifier:DataFrame; 350, argument_list; 350, 351; 350, 352; 351, identifier:value; 352, keyword_argument; 352, 353; 352, 354; 353, identifier:index; 354, identifier:variants; 355, for_in_clause; 355, 356; 355, 359; 356, tuple_pattern; 356, 357; 356, 358; 357, identifier:label; 358, identifier:value; 359, call; 359, 360; 359, 363; 360, attribute; 360, 361; 360, 362; 361, identifier:dataframe_dicts; 362, identifier:items; 363, argument_list; 364, return_statement; 364, 365; 365, call; 365, 366; 365, 369; 366, attribute; 366, 367; 366, 368; 367, identifier:pandas; 368, identifier:Panel; 369, argument_list; 369, 370; 370, identifier:dataframes
def variant_support(variants, allele_support_df, ignore_missing=False): ''' Collect the read evidence support for the given variants. Parameters ---------- variants : iterable of varcode.Variant allele_support_df : dataframe Allele support dataframe, as output by the varlens-allele-support tool. It should have columns: source, contig, interbase_start, interbase_end, allele. The remaining columns are interpreted as read counts of various subsets of reads (e.g. all reads, non-duplicate reads, etc.) ignore_missing : boolean If True, then varaints with no allele counts will be interpreted as having 0 depth. If False, then an exception will be raised if any variants have no allele counts. Returns ---------- A pandas.Panel4D frame with these axes: labels (axis=0) : the type of read being counted, i.e. the read count fields in allele_support_df. items (axis=1) : the type of measurement (num_alt, num_ref, num_other, total_depth, alt_fraction, any_alt_fraction) major axis (axis=2) : the variants minor axis (axis=3) : the sources ''' missing = [ c for c in EXPECTED_COLUMNS if c not in allele_support_df.columns ] if missing: raise ValueError("Missing columns: %s" % " ".join(missing)) allele_support_df[["interbase_start", "interbase_end"]] = ( allele_support_df[["interbase_start", "interbase_end"]].astype(int)) sources = sorted(allele_support_df["source"].unique()) allele_support_dict = collections.defaultdict(dict) for (i, row) in allele_support_df.iterrows(): key = ( row['source'], row.contig, row.interbase_start, row.interbase_end) allele_support_dict[key][row.allele] = row["count"] allele_support_dict = dict(allele_support_dict) dataframe_dicts = collections.defaultdict( lambda: collections.defaultdict(list)) for variant in variants: for source in sources: key = (source, variant.contig, variant.start - 1, variant.end) try: alleles = allele_support_dict[key] except KeyError: message = ( "No allele counts in source %s for variant %s" % ( source, str(variant))) if ignore_missing: logging.warning(message) alleles = {} else: raise ValueError(message) alt = alleles.get(variant.alt, 0) ref = alleles.get(variant.ref, 0) total = sum(alleles.values()) other = total - alt - ref dataframe_dicts["num_alt"][source].append(alt) dataframe_dicts["num_ref"][source].append(ref) dataframe_dicts["num_other"][source].append(other) dataframe_dicts["total_depth"][source].append(total) dataframe_dicts["alt_fraction"][source].append( float(alt) / max(1, total)) dataframe_dicts["any_alt_fraction"][source].append( float(alt + other) / max(1, total)) dataframes = dict( (label, pandas.DataFrame(value, index=variants)) for (label, value) in dataframe_dicts.items()) return pandas.Panel(dataframes)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 1, 25; 2, function_name:_wavReadData; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 13; 3, 17; 4, identifier:fid; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:size; 7, type; 7, 8; 8, identifier:int; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:channels; 11, type; 11, 12; 12, identifier:int; 13, typed_parameter; 13, 14; 13, 15; 14, identifier:encoding; 15, type; 15, 16; 16, identifier:str; 17, typed_parameter; 17, 18; 17, 19; 18, identifier:bigendian; 19, type; 19, 20; 20, identifier:bool; 21, type; 21, 22; 22, attribute; 22, 23; 22, 24; 23, identifier:np; 24, identifier:ndarray; 25, block; 25, 26; 25, 37; 25, 254; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:bits; 29, call; 29, 30; 29, 31; 30, identifier:int; 31, argument_list; 31, 32; 32, subscript; 32, 33; 32, 34; 33, identifier:encoding; 34, slice; 34, 35; 34, 36; 35, integer:3; 36, colon; 37, if_statement; 37, 38; 37, 41; 37, 75; 38, comparison_operator:==; 38, 39; 38, 40; 39, identifier:bits; 40, integer:8; 41, block; 41, 42; 41, 59; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:data; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:np; 48, identifier:fromfile; 49, argument_list; 49, 50; 49, 51; 49, 56; 50, identifier:fid; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:dtype; 53, attribute; 53, 54; 53, 55; 54, identifier:np; 55, identifier:ubyte; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:count; 58, identifier:size; 59, if_statement; 59, 60; 59, 63; 60, comparison_operator:>; 60, 61; 60, 62; 61, identifier:channels; 62, integer:1; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:data; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:data; 70, identifier:reshape; 71, argument_list; 71, 72; 71, 74; 72, unary_operator:-; 72, 73; 73, integer:1; 74, identifier:channels; 75, else_clause; 75, 76; 76, block; 76, 77; 76, 83; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:bytes; 80, binary_operator://; 80, 81; 80, 82; 81, identifier:bits; 82, integer:8; 83, if_statement; 83, 84; 83, 90; 83, 141; 83, 210; 84, comparison_operator:in; 84, 85; 84, 86; 85, identifier:encoding; 86, tuple; 86, 87; 86, 88; 86, 89; 87, string:'pcm16'; 88, string:'pcm32'; 89, string:'pcm64'; 90, block; 90, 91; 90, 108; 90, 125; 91, if_statement; 91, 92; 91, 93; 91, 100; 92, identifier:bigendian; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:dtype; 97, binary_operator:%; 97, 98; 97, 99; 98, string:'>i%d'; 99, identifier:bytes; 100, else_clause; 100, 101; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:dtype; 105, binary_operator:%; 105, 106; 105, 107; 106, string:'<i%d'; 107, identifier:bytes; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:data; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:np; 114, identifier:fromfile; 115, argument_list; 115, 116; 115, 117; 115, 120; 116, identifier:fid; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:dtype; 119, identifier:dtype; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:count; 122, binary_operator://; 122, 123; 122, 124; 123, identifier:size; 124, identifier:bytes; 125, if_statement; 125, 126; 125, 129; 126, comparison_operator:>; 126, 127; 126, 128; 127, identifier:channels; 128, integer:1; 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:reshape; 137, argument_list; 137, 138; 137, 140; 138, unary_operator:-; 138, 139; 139, integer:1; 140, identifier:channels; 141, elif_clause; 141, 142; 141, 149; 142, comparison_operator:==; 142, 143; 142, 148; 143, subscript; 143, 144; 143, 145; 144, identifier:encoding; 145, slice; 145, 146; 145, 147; 146, colon; 147, integer:3; 148, string:'flt'; 149, block; 149, 150; 149, 155; 149, 177; 149, 194; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 153; 152, identifier:print; 153, argument_list; 153, 154; 154, string:"flt32!"; 155, if_statement; 155, 156; 155, 159; 155, 173; 156, comparison_operator:==; 156, 157; 156, 158; 157, identifier:bits; 158, integer:32; 159, block; 159, 160; 160, if_statement; 160, 161; 160, 162; 160, 167; 161, identifier:bigendian; 162, block; 162, 163; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:dtype; 166, string:'>f4'; 167, else_clause; 167, 168; 168, block; 168, 169; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:dtype; 172, string:'<f4'; 173, else_clause; 173, 174; 174, block; 174, 175; 175, raise_statement; 175, 176; 176, identifier:NotImplementedError; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:data; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:np; 183, identifier:fromfile; 184, argument_list; 184, 185; 184, 186; 184, 189; 185, identifier:fid; 186, keyword_argument; 186, 187; 186, 188; 187, identifier:dtype; 188, identifier:dtype; 189, keyword_argument; 189, 190; 189, 191; 190, identifier:count; 191, binary_operator://; 191, 192; 191, 193; 192, identifier:size; 193, identifier:bytes; 194, if_statement; 194, 195; 194, 198; 195, comparison_operator:>; 195, 196; 195, 197; 196, identifier:channels; 197, integer:1; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 202; 201, identifier:data; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:data; 205, identifier:reshape; 206, argument_list; 206, 207; 206, 209; 207, unary_operator:-; 207, 208; 208, integer:1; 209, identifier:channels; 210, elif_clause; 210, 211; 210, 214; 211, comparison_operator:==; 211, 212; 211, 213; 212, identifier:encoding; 213, string:'pcm24'; 214, block; 214, 215; 214, 238; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:data; 218, call; 218, 219; 218, 220; 219, identifier:_numpy24to32bit; 220, argument_list; 220, 221; 220, 235; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:np; 224, identifier:fromfile; 225, argument_list; 225, 226; 225, 227; 225, 232; 226, identifier:fid; 227, keyword_argument; 227, 228; 227, 229; 228, identifier:dtype; 229, attribute; 229, 230; 229, 231; 230, identifier:np; 231, identifier:ubyte; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:count; 234, identifier:size; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:bigendian; 237, False; 238, if_statement; 238, 239; 238, 242; 239, comparison_operator:>; 239, 240; 239, 241; 240, identifier:channels; 241, integer:1; 242, block; 242, 243; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:data; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:data; 249, identifier:reshape; 250, argument_list; 250, 251; 250, 253; 251, unary_operator:-; 251, 252; 252, integer:1; 253, identifier:channels; 254, return_statement; 254, 255; 255, identifier:data
def _wavReadData(fid, size:int, channels:int, encoding:str, bigendian:bool) -> np.ndarray: bits = int(encoding[3:]) if bits == 8: data = np.fromfile(fid, dtype=np.ubyte, count=size) if channels > 1: data = data.reshape(-1, channels) else: bytes = bits // 8 if encoding in ('pcm16', 'pcm32', 'pcm64'): if bigendian: dtype = '>i%d' % bytes else: dtype = '<i%d' % bytes data = np.fromfile(fid, dtype=dtype, count=size // bytes) if channels > 1: data = data.reshape(-1, channels) elif encoding[:3] == 'flt': print("flt32!") if bits == 32: if bigendian: dtype = '>f4' else: dtype = '<f4' else: raise NotImplementedError data = np.fromfile(fid, dtype=dtype, count=size // bytes) if channels > 1: data = data.reshape(-1, channels) elif encoding == 'pcm24': data = _numpy24to32bit(np.fromfile(fid, dtype=np.ubyte, count=size), bigendian=False) if channels > 1: data = data.reshape(-1, channels) return data
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:refreshButton; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 20; 5, 25; 5, 33; 5, 60; 5, 64; 5, 195; 5, 262; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:collapsed; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:isCollapsed; 13, argument_list; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:btn; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:_collapseButton; 20, if_statement; 20, 21; 20, 23; 21, not_operator; 21, 22; 22, identifier:btn; 23, block; 23, 24; 24, return_statement; 25, expression_statement; 25, 26; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:btn; 29, identifier:setMaximumSize; 30, argument_list; 30, 31; 30, 32; 31, identifier:MAX_SIZE; 32, identifier:MAX_SIZE; 33, if_statement; 33, 34; 33, 43; 33, 51; 34, comparison_operator:==; 34, 35; 34, 40; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:orientation; 39, argument_list; 40, attribute; 40, 41; 40, 42; 41, identifier:Qt; 42, identifier:Vertical; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:btn; 48, identifier:setMaximumHeight; 49, argument_list; 49, 50; 50, integer:12; 51, else_clause; 51, 52; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:btn; 57, identifier:setMaximumWidth; 58, argument_list; 58, 59; 59, integer:12; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:icon; 63, string:''; 64, if_statement; 64, 65; 64, 74; 64, 134; 65, comparison_operator:==; 65, 66; 65, 71; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:orientation; 70, argument_list; 71, attribute; 71, 72; 71, 73; 72, identifier:Qt; 73, identifier:Vertical; 74, block; 74, 75; 75, if_statement; 75, 76; 75, 77; 75, 103; 76, identifier:collapsed; 77, block; 77, 78; 77, 87; 77, 94; 78, expression_statement; 78, 79; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:setFixedWidth; 83, argument_list; 83, 84; 84, attribute; 84, 85; 84, 86; 85, identifier:self; 86, identifier:_collapsedSize; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:btn; 91, identifier:setMaximumHeight; 92, argument_list; 92, 93; 93, identifier:MAX_SIZE; 94, expression_statement; 94, 95; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:btn; 98, identifier:setArrowType; 99, argument_list; 99, 100; 100, attribute; 100, 101; 100, 102; 101, identifier:Qt; 102, identifier:RightArrow; 103, else_clause; 103, 104; 104, block; 104, 105; 104, 112; 104, 118; 104, 125; 105, expression_statement; 105, 106; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:setMaximumWidth; 110, argument_list; 110, 111; 111, identifier:MAX_SIZE; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:_precollapseSize; 117, None; 118, expression_statement; 118, 119; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:btn; 122, identifier:setMaximumHeight; 123, argument_list; 123, 124; 124, integer:12; 125, expression_statement; 125, 126; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:btn; 129, identifier:setArrowType; 130, argument_list; 130, 131; 131, attribute; 131, 132; 131, 133; 132, identifier:Qt; 133, identifier:LeftArrow; 134, else_clause; 134, 135; 135, block; 135, 136; 136, if_statement; 136, 137; 136, 138; 136, 164; 137, identifier:collapsed; 138, block; 138, 139; 138, 148; 138, 155; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:setFixedHeight; 144, argument_list; 144, 145; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:_collapsedSize; 148, expression_statement; 148, 149; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:btn; 152, identifier:setMaximumWidth; 153, argument_list; 153, 154; 154, identifier:MAX_SIZE; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:btn; 159, identifier:setArrowType; 160, argument_list; 160, 161; 161, attribute; 161, 162; 161, 163; 162, identifier:Qt; 163, identifier:DownArrow; 164, else_clause; 164, 165; 165, block; 165, 166; 165, 173; 165, 179; 165, 186; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:setMaximumHeight; 171, argument_list; 171, 172; 172, integer:1000; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:self; 177, identifier:_precollapseSize; 178, None; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:btn; 183, identifier:setMaximumWidth; 184, argument_list; 184, 185; 185, integer:12; 186, expression_statement; 186, 187; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:btn; 190, identifier:setArrowType; 191, argument_list; 191, 192; 192, attribute; 192, 193; 192, 194; 193, identifier:Qt; 194, identifier:UpArrow; 195, for_statement; 195, 196; 195, 197; 195, 210; 196, identifier:index; 197, call; 197, 198; 197, 199; 198, identifier:range; 199, argument_list; 199, 200; 199, 201; 200, integer:1; 201, call; 201, 202; 201, 209; 202, attribute; 202, 203; 202, 208; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:self; 206, identifier:layout; 207, argument_list; 208, identifier:count; 209, argument_list; 210, block; 210, 211; 210, 224; 210, 233; 211, expression_statement; 211, 212; 212, assignment; 212, 213; 212, 214; 213, identifier:item; 214, call; 214, 215; 214, 222; 215, attribute; 215, 216; 215, 221; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:self; 219, identifier:layout; 220, argument_list; 221, identifier:itemAt; 222, argument_list; 222, 223; 223, identifier:index; 224, if_statement; 224, 225; 224, 231; 225, not_operator; 225, 226; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:item; 229, identifier:widget; 230, argument_list; 231, block; 231, 232; 232, continue_statement; 233, if_statement; 233, 234; 233, 235; 233, 248; 234, identifier:collapsed; 235, block; 235, 236; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 245; 238, attribute; 238, 239; 238, 244; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:item; 242, identifier:widget; 243, argument_list; 244, identifier:setMaximumSize; 245, argument_list; 245, 246; 245, 247; 246, integer:0; 247, integer:0; 248, else_clause; 248, 249; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 259; 252, attribute; 252, 253; 252, 258; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:item; 256, identifier:widget; 257, argument_list; 258, identifier:setMaximumSize; 259, argument_list; 259, 260; 259, 261; 260, identifier:MAX_SIZE; 261, identifier:MAX_SIZE; 262, if_statement; 262, 263; 262, 269; 262, 276; 263, not_operator; 263, 264; 264, call; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:self; 267, identifier:isCollapsable; 268, argument_list; 269, block; 269, 270; 270, expression_statement; 270, 271; 271, call; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:btn; 274, identifier:hide; 275, argument_list; 276, else_clause; 276, 277; 277, block; 277, 278; 278, expression_statement; 278, 279; 279, call; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:btn; 282, identifier:show; 283, argument_list
def refreshButton(self): collapsed = self.isCollapsed() btn = self._collapseButton if not btn: return btn.setMaximumSize(MAX_SIZE, MAX_SIZE) if self.orientation() == Qt.Vertical: btn.setMaximumHeight(12) else: btn.setMaximumWidth(12) icon = '' if self.orientation() == Qt.Vertical: if collapsed: self.setFixedWidth(self._collapsedSize) btn.setMaximumHeight(MAX_SIZE) btn.setArrowType(Qt.RightArrow) else: self.setMaximumWidth(MAX_SIZE) self._precollapseSize = None btn.setMaximumHeight(12) btn.setArrowType(Qt.LeftArrow) else: if collapsed: self.setFixedHeight(self._collapsedSize) btn.setMaximumWidth(MAX_SIZE) btn.setArrowType(Qt.DownArrow) else: self.setMaximumHeight(1000) self._precollapseSize = None btn.setMaximumWidth(12) btn.setArrowType(Qt.UpArrow) for index in range(1, self.layout().count()): item = self.layout().itemAt(index) if not item.widget(): continue if collapsed: item.widget().setMaximumSize(0, 0) else: item.widget().setMaximumSize(MAX_SIZE, MAX_SIZE) if not self.isCollapsable(): btn.hide() else: btn.show()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:applyCommand; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 23; 5, 42; 5, 50; 5, 62; 5, 72; 5, 447; 5, 454; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:cursor; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:textCursor; 13, argument_list; 14, expression_statement; 14, 15; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:cursor; 18, identifier:movePosition; 19, argument_list; 19, 20; 20, attribute; 20, 21; 20, 22; 21, identifier:cursor; 22, identifier:EndOfLine; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:line; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:projex; 30, identifier:text; 31, identifier:nativestring; 32, argument_list; 32, 33; 33, call; 33, 34; 33, 41; 34, attribute; 34, 35; 34, 40; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:cursor; 38, identifier:block; 39, argument_list; 40, identifier:text; 41, argument_list; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:at_end; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:cursor; 48, identifier:atEnd; 49, argument_list; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:modifiers; 53, call; 53, 54; 53, 61; 54, attribute; 54, 55; 54, 60; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:QApplication; 58, identifier:instance; 59, argument_list; 60, identifier:keyboardModifiers; 61, argument_list; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:mod_mode; 65, boolean_operator:or; 65, 66; 65, 67; 66, identifier:at_end; 67, comparison_operator:==; 67, 68; 67, 69; 68, identifier:modifiers; 69, attribute; 69, 70; 69, 71; 70, identifier:Qt; 71, identifier:ShiftModifier; 72, if_statement; 72, 73; 72, 81; 72, 144; 72, 216; 72, 437; 73, boolean_operator:and; 73, 74; 73, 75; 74, identifier:mod_mode; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:line; 78, identifier:endswith; 79, argument_list; 79, 80; 80, string:':'; 81, block; 81, 82; 81, 91; 81, 102; 81, 113; 81, 131; 81, 142; 82, expression_statement; 82, 83; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:cursor; 86, identifier:movePosition; 87, argument_list; 87, 88; 88, attribute; 88, 89; 88, 90; 89, identifier:cursor; 90, identifier:EndOfLine; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:line; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:re; 97, identifier:sub; 98, argument_list; 98, 99; 98, 100; 98, 101; 99, string:'^>>> '; 100, string:''; 101, identifier:line; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:line; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:re; 108, identifier:sub; 109, argument_list; 109, 110; 109, 111; 109, 112; 110, string:'^\.\.\. '; 111, string:''; 112, identifier:line; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:count; 116, binary_operator:+; 116, 117; 116, 130; 117, binary_operator:-; 117, 118; 117, 122; 118, call; 118, 119; 118, 120; 119, identifier:len; 120, argument_list; 120, 121; 121, identifier:line; 122, call; 122, 123; 122, 124; 123, identifier:len; 124, argument_list; 124, 125; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:line; 128, identifier:lstrip; 129, argument_list; 130, integer:4; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:insertPlainText; 136, argument_list; 136, 137; 137, binary_operator:+; 137, 138; 137, 139; 138, string:'\n... '; 139, binary_operator:*; 139, 140; 139, 141; 140, identifier:count; 141, string:' '; 142, return_statement; 142, 143; 143, False; 144, elif_clause; 144, 145; 144, 166; 145, boolean_operator:and; 145, 146; 145, 154; 145, 155; 146, boolean_operator:and; 146, 147; 146, 148; 147, identifier:mod_mode; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:line; 151, identifier:startswith; 152, argument_list; 152, 153; 153, string:'...'; 154, line_continuation:\; 155, parenthesized_expression; 155, 156; 156, boolean_operator:or; 156, 157; 156, 164; 157, comparison_operator:!=; 157, 158; 157, 163; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:line; 161, identifier:strip; 162, argument_list; 163, string:'...'; 164, not_operator; 164, 165; 165, identifier:at_end; 166, block; 166, 167; 166, 176; 166, 187; 166, 203; 166, 214; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:cursor; 171, identifier:movePosition; 172, argument_list; 172, 173; 173, attribute; 173, 174; 173, 175; 174, identifier:cursor; 175, identifier:EndOfLine; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:line; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:re; 182, identifier:sub; 183, argument_list; 183, 184; 183, 185; 183, 186; 184, string:'^\.\.\. '; 185, string:''; 186, identifier:line; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 190; 189, identifier:count; 190, binary_operator:-; 190, 191; 190, 195; 191, call; 191, 192; 191, 193; 192, identifier:len; 193, argument_list; 193, 194; 194, identifier:line; 195, call; 195, 196; 195, 197; 196, identifier:len; 197, argument_list; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:line; 201, identifier:lstrip; 202, argument_list; 203, expression_statement; 203, 204; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:self; 207, identifier:insertPlainText; 208, argument_list; 208, 209; 209, binary_operator:+; 209, 210; 209, 211; 210, string:'\n... '; 211, binary_operator:*; 211, 212; 211, 213; 212, identifier:count; 213, string:' '; 214, return_statement; 214, 215; 215, False; 216, elif_clause; 216, 217; 216, 230; 217, boolean_operator:or; 217, 218; 217, 224; 218, call; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:line; 221, identifier:startswith; 222, argument_list; 222, 223; 223, string:'>>>'; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:line; 227, identifier:startswith; 228, argument_list; 228, 229; 229, string:'...'; 230, block; 230, 231; 230, 250; 230, 286; 230, 295; 230, 314; 230, 318; 230, 322; 230, 391; 230, 400; 231, expression_statement; 231, 232; 232, assignment; 232, 233; 232, 234; 233, identifier:line; 234, call; 234, 235; 234, 240; 235, attribute; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:projex; 238, identifier:text; 239, identifier:nativestring; 240, argument_list; 240, 241; 241, call; 241, 242; 241, 249; 242, attribute; 242, 243; 242, 248; 243, call; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:cursor; 246, identifier:block; 247, argument_list; 248, identifier:text; 249, argument_list; 250, while_statement; 250, 251; 250, 257; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:line; 254, identifier:startswith; 255, argument_list; 255, 256; 256, string:'...'; 257, block; 257, 258; 257, 267; 258, expression_statement; 258, 259; 259, call; 259, 260; 259, 263; 260, attribute; 260, 261; 260, 262; 261, identifier:cursor; 262, identifier:movePosition; 263, argument_list; 263, 264; 264, attribute; 264, 265; 264, 266; 265, identifier:cursor; 266, identifier:PreviousBlock; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:line; 270, call; 270, 271; 270, 276; 271, attribute; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:projex; 274, identifier:text; 275, identifier:nativestring; 276, argument_list; 276, 277; 277, call; 277, 278; 277, 285; 278, attribute; 278, 279; 278, 284; 279, call; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:cursor; 282, identifier:block; 283, argument_list; 284, identifier:text; 285, argument_list; 286, expression_statement; 286, 287; 287, call; 287, 288; 287, 291; 288, attribute; 288, 289; 288, 290; 289, identifier:cursor; 290, identifier:movePosition; 291, argument_list; 291, 292; 292, attribute; 292, 293; 292, 294; 293, identifier:cursor; 294, identifier:EndOfLine; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:line; 298, call; 298, 299; 298, 304; 299, attribute; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:projex; 302, identifier:text; 303, identifier:nativestring; 304, argument_list; 304, 305; 305, call; 305, 306; 305, 313; 306, attribute; 306, 307; 306, 312; 307, call; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:cursor; 310, identifier:block; 311, argument_list; 312, identifier:text; 313, argument_list; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 317; 316, identifier:ended; 317, False; 318, expression_statement; 318, 319; 319, assignment; 319, 320; 319, 321; 320, identifier:lines; 321, list:[]; 322, while_statement; 322, 323; 322, 324; 323, True; 324, block; 324, 325; 324, 332; 324, 344; 324, 353; 324, 362; 324, 381; 325, expression_statement; 325, 326; 326, call; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:lines; 329, identifier:append; 330, argument_list; 330, 331; 331, identifier:line; 332, if_statement; 332, 333; 332, 338; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:cursor; 336, identifier:atEnd; 337, argument_list; 338, block; 338, 339; 338, 343; 339, expression_statement; 339, 340; 340, assignment; 340, 341; 340, 342; 341, identifier:ended; 342, True; 343, break_statement; 344, expression_statement; 344, 345; 345, call; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:cursor; 348, identifier:movePosition; 349, argument_list; 349, 350; 350, attribute; 350, 351; 350, 352; 351, identifier:cursor; 352, identifier:NextBlock; 353, expression_statement; 353, 354; 354, call; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:cursor; 357, identifier:movePosition; 358, argument_list; 358, 359; 359, attribute; 359, 360; 359, 361; 360, identifier:cursor; 361, identifier:EndOfLine; 362, expression_statement; 362, 363; 363, assignment; 363, 364; 363, 365; 364, identifier:line; 365, call; 365, 366; 365, 371; 366, attribute; 366, 367; 366, 370; 367, attribute; 367, 368; 367, 369; 368, identifier:projex; 369, identifier:text; 370, identifier:nativestring; 371, argument_list; 371, 372; 372, call; 372, 373; 372, 380; 373, attribute; 373, 374; 373, 379; 374, call; 374, 375; 374, 378; 375, attribute; 375, 376; 375, 377; 376, identifier:cursor; 377, identifier:block; 378, argument_list; 379, identifier:text; 380, argument_list; 381, if_statement; 381, 382; 381, 389; 382, not_operator; 382, 383; 383, call; 383, 384; 383, 387; 384, attribute; 384, 385; 384, 386; 385, identifier:line; 386, identifier:startswith; 387, argument_list; 387, 388; 388, string:'...'; 389, block; 389, 390; 390, break_statement; 391, expression_statement; 391, 392; 392, assignment; 392, 393; 392, 394; 393, identifier:command; 394, call; 394, 395; 394, 398; 395, attribute; 395, 396; 395, 397; 396, string:'\n'; 397, identifier:join; 398, argument_list; 398, 399; 399, identifier:lines; 400, if_statement; 400, 401; 400, 406; 401, not_operator; 401, 402; 402, parenthesized_expression; 402, 403; 403, boolean_operator:and; 403, 404; 403, 405; 404, identifier:ended; 405, identifier:command; 406, block; 406, 407; 406, 413; 406, 426; 406, 435; 407, expression_statement; 407, 408; 408, call; 408, 409; 408, 412; 409, attribute; 409, 410; 409, 411; 410, identifier:self; 411, identifier:waitForInput; 412, argument_list; 413, expression_statement; 413, 414; 414, call; 414, 415; 414, 418; 415, attribute; 415, 416; 415, 417; 416, identifier:self; 417, identifier:insertPlainText; 418, argument_list; 418, 419; 419, call; 419, 420; 419, 423; 420, attribute; 420, 421; 420, 422; 421, identifier:command; 422, identifier:replace; 423, argument_list; 423, 424; 423, 425; 424, string:'>>> '; 425, string:''; 426, expression_statement; 426, 427; 427, call; 427, 428; 427, 431; 428, attribute; 428, 429; 428, 430; 429, identifier:cursor; 430, identifier:movePosition; 431, argument_list; 431, 432; 432, attribute; 432, 433; 432, 434; 433, identifier:cursor; 434, identifier:End; 435, return_statement; 435, 436; 436, False; 437, else_clause; 437, 438; 438, block; 438, 439; 438, 445; 439, expression_statement; 439, 440; 440, call; 440, 441; 440, 444; 441, attribute; 441, 442; 441, 443; 442, identifier:self; 443, identifier:waitForInput; 444, argument_list; 445, return_statement; 445, 446; 446, False; 447, expression_statement; 447, 448; 448, call; 448, 449; 448, 452; 449, attribute; 449, 450; 449, 451; 450, identifier:self; 451, identifier:executeCommand; 452, argument_list; 452, 453; 453, identifier:command; 454, return_statement; 454, 455; 455, True
def applyCommand(self): cursor = self.textCursor() cursor.movePosition(cursor.EndOfLine) line = projex.text.nativestring(cursor.block().text()) at_end = cursor.atEnd() modifiers = QApplication.instance().keyboardModifiers() mod_mode = at_end or modifiers == Qt.ShiftModifier if mod_mode and line.endswith(':'): cursor.movePosition(cursor.EndOfLine) line = re.sub('^>>> ', '', line) line = re.sub('^\.\.\. ', '', line) count = len(line) - len(line.lstrip()) + 4 self.insertPlainText('\n... ' + count * ' ') return False elif mod_mode and line.startswith('...') and \ (line.strip() != '...' or not at_end): cursor.movePosition(cursor.EndOfLine) line = re.sub('^\.\.\. ', '', line) count = len(line) - len(line.lstrip()) self.insertPlainText('\n... ' + count * ' ') return False elif line.startswith('>>>') or line.startswith('...'): line = projex.text.nativestring(cursor.block().text()) while line.startswith('...'): cursor.movePosition(cursor.PreviousBlock) line = projex.text.nativestring(cursor.block().text()) cursor.movePosition(cursor.EndOfLine) line = projex.text.nativestring(cursor.block().text()) ended = False lines = [] while True: lines.append(line) if cursor.atEnd(): ended = True break cursor.movePosition(cursor.NextBlock) cursor.movePosition(cursor.EndOfLine) line = projex.text.nativestring(cursor.block().text()) if not line.startswith('...'): break command = '\n'.join(lines) if not (ended and command): self.waitForInput() self.insertPlainText(command.replace('>>> ', '')) cursor.movePosition(cursor.End) return False else: self.waitForInput() return False self.executeCommand(command) return True
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:pager; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:lines; 6, block; 6, 7; 7, try_statement; 7, 8; 7, 244; 8, block; 8, 9; 8, 13; 8, 35; 8, 50; 8, 54; 8, 231; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:line_count; 12, integer:0; 13, if_statement; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:_output_filename; 17, block; 17, 18; 17, 23; 18, expression_statement; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:print; 21, argument_list; 21, 22; 22, string:f"Output is also going to '{self.output_file}'"; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:_output_file; 28, call; 28, 29; 28, 30; 29, identifier:open; 30, argument_list; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:_output_filename; 34, string:"a+"; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 40; 37, pattern_list; 37, 38; 37, 39; 38, identifier:terminal_columns; 39, identifier:terminal_lines; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:shutil; 43, identifier:get_terminal_size; 44, argument_list; 44, 45; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:fallback; 47, tuple; 47, 48; 47, 49; 48, integer:80; 49, integer:24; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:lines_left; 53, identifier:terminal_lines; 54, for_statement; 54, 55; 54, 58; 54, 63; 55, pattern_list; 55, 56; 55, 57; 56, identifier:i; 57, identifier:l; 58, call; 58, 59; 58, 60; 59, identifier:enumerate; 60, argument_list; 60, 61; 60, 62; 61, identifier:lines; 62, integer:1; 63, block; 63, 64; 63, 68; 63, 83; 63, 95; 63, 107; 63, 126; 63, 137; 63, 142; 63, 164; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:line_residue; 67, integer:0; 68, if_statement; 68, 69; 68, 72; 68, 77; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:line_numbers; 72, block; 72, 73; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:output_line; 76, string:f"{i:<4} {l}"; 77, else_clause; 77, 78; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:output_line; 82, identifier:l; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:line_overflow; 86, call; 86, 87; 86, 88; 87, identifier:int; 88, argument_list; 88, 89; 89, binary_operator:/; 89, 90; 89, 94; 90, call; 90, 91; 90, 92; 91, identifier:len; 92, argument_list; 92, 93; 93, identifier:output_line; 94, identifier:terminal_columns; 95, if_statement; 95, 96; 95, 97; 96, identifier:line_overflow; 97, block; 97, 98; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:line_residue; 101, binary_operator:%; 101, 102; 101, 106; 102, call; 102, 103; 102, 104; 103, identifier:len; 104, argument_list; 104, 105; 105, identifier:output_line; 106, identifier:terminal_columns; 107, if_statement; 107, 108; 107, 111; 107, 118; 108, comparison_operator:>=; 108, 109; 108, 110; 109, identifier:line_overflow; 110, integer:1; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:lines_left; 115, binary_operator:-; 115, 116; 115, 117; 116, identifier:lines_left; 117, identifier:line_overflow; 118, else_clause; 118, 119; 119, block; 119, 120; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:lines_left; 123, binary_operator:-; 123, 124; 123, 125; 124, identifier:lines_left; 125, integer:1; 126, if_statement; 126, 127; 126, 130; 127, comparison_operator:>; 127, 128; 127, 129; 128, identifier:line_residue; 129, integer:1; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:lines_left; 134, binary_operator:-; 134, 135; 134, 136; 135, identifier:lines_left; 136, integer:1; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 140; 139, identifier:print; 140, argument_list; 140, 141; 141, identifier:output_line; 142, if_statement; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:_output_file; 146, block; 146, 147; 146, 156; 147, expression_statement; 147, 148; 148, call; 148, 149; 148, 154; 149, attribute; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:self; 152, identifier:_output_file; 153, identifier:write; 154, argument_list; 154, 155; 155, string:f"{l}\n"; 156, expression_statement; 156, 157; 157, call; 157, 158; 157, 163; 158, attribute; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:_output_file; 162, identifier:flush; 163, argument_list; 164, if_statement; 164, 165; 164, 175; 165, comparison_operator:<=; 165, 166; 165, 174; 166, parenthesized_expression; 166, 167; 167, binary_operator:-; 167, 168; 167, 173; 168, binary_operator:-; 168, 169; 168, 170; 169, identifier:lines_left; 170, attribute; 170, 171; 170, 172; 171, identifier:self; 172, identifier:overlap; 173, integer:1; 174, integer:0; 175, block; 175, 176; 176, if_statement; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:self; 179, identifier:paginate; 180, block; 180, 181; 180, 189; 180, 195; 180, 212; 180, 227; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 184; 183, identifier:print; 184, argument_list; 184, 185; 184, 186; 185, string:"Hit Return to continue (q or quit to exit)"; 186, keyword_argument; 186, 187; 186, 188; 187, identifier:end; 188, string:""; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:user_input; 192, call; 192, 193; 192, 194; 193, identifier:input; 194, argument_list; 195, if_statement; 195, 196; 195, 210; 196, comparison_operator:in; 196, 197; 196, 206; 197, call; 197, 198; 197, 205; 198, attribute; 198, 199; 198, 204; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:user_input; 202, identifier:lower; 203, argument_list; 204, identifier:strip; 205, argument_list; 206, list:["q", "quit", "exit"]; 206, 207; 206, 208; 206, 209; 207, string:"q"; 208, string:"quit"; 209, string:"exit"; 210, block; 210, 211; 211, break_statement; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 217; 214, pattern_list; 214, 215; 214, 216; 215, identifier:terminal_columns; 216, identifier:terminal_lines; 217, call; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:shutil; 220, identifier:get_terminal_size; 221, argument_list; 221, 222; 222, keyword_argument; 222, 223; 222, 224; 223, identifier:fallback; 224, tuple; 224, 225; 224, 226; 225, integer:80; 226, integer:24; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:lines_left; 230, identifier:terminal_lines; 231, if_statement; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:self; 234, identifier:_output_file; 235, block; 235, 236; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 243; 238, attribute; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:self; 241, identifier:_output_file; 242, identifier:close; 243, argument_list; 244, except_clause; 244, 245; 244, 246; 245, identifier:KeyboardInterrupt; 246, block; 246, 247; 246, 252; 247, expression_statement; 247, 248; 248, call; 248, 249; 248, 250; 249, identifier:print; 250, argument_list; 250, 251; 251, string:"ctrl-C..."; 252, if_statement; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:self; 255, identifier:_output_file; 256, block; 256, 257; 257, expression_statement; 257, 258; 258, call; 258, 259; 258, 264; 259, attribute; 259, 260; 259, 263; 260, attribute; 260, 261; 260, 262; 261, identifier:self; 262, identifier:_output_file; 263, identifier:close; 264, argument_list
def pager(self, lines): try: line_count = 0 if self._output_filename: print(f"Output is also going to '{self.output_file}'") self._output_file = open(self._output_filename, "a+") terminal_columns, terminal_lines = shutil.get_terminal_size(fallback=(80, 24)) lines_left = terminal_lines for i, l in enumerate(lines, 1): line_residue = 0 if self.line_numbers: output_line = f"{i:<4} {l}" else: output_line = l line_overflow = int(len(output_line) / terminal_columns) if line_overflow: line_residue = len(output_line) % terminal_columns if line_overflow >= 1: lines_left = lines_left - line_overflow else: lines_left = lines_left - 1 if line_residue > 1: lines_left = lines_left - 1 print(output_line) if self._output_file: self._output_file.write(f"{l}\n") self._output_file.flush() if (lines_left - self.overlap - 1) <= 0: if self.paginate: print("Hit Return to continue (q or quit to exit)", end="") user_input = input() if user_input.lower().strip() in ["q", "quit", "exit"]: break terminal_columns, terminal_lines = shutil.get_terminal_size(fallback=(80, 24)) lines_left = terminal_lines if self._output_file: self._output_file.close() except KeyboardInterrupt: print("ctrl-C...") if self._output_file: self._output_file.close()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge; 3, parameters; 3, 4; 4, identifier:constraints; 5, block; 5, 6; 5, 13; 5, 30; 5, 53; 5, 76; 5, 98; 5, 120; 5, 124; 5, 201; 5, 205; 5, 282; 5, 365; 5, 379; 5, 393; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:operators; 9, call; 9, 10; 9, 11; 10, identifier:defaultdict; 11, argument_list; 11, 12; 12, identifier:set; 13, for_statement; 13, 14; 13, 15; 13, 16; 14, identifier:constraint; 15, identifier:constraints; 16, block; 16, 17; 17, expression_statement; 17, 18; 18, call; 18, 19; 18, 26; 19, attribute; 19, 20; 19, 25; 20, subscript; 20, 21; 20, 22; 21, identifier:operators; 22, attribute; 22, 23; 22, 24; 23, identifier:constraint; 24, identifier:operator; 25, identifier:add; 26, argument_list; 26, 27; 27, attribute; 27, 28; 27, 29; 28, identifier:constraint; 29, identifier:version; 30, if_statement; 30, 31; 30, 34; 30, 47; 31, comparison_operator:in; 31, 32; 31, 33; 32, identifier:gt; 33, identifier:operators; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:gt_ver; 38, subscript; 38, 39; 38, 45; 39, call; 39, 40; 39, 41; 40, identifier:sorted; 41, argument_list; 41, 42; 42, subscript; 42, 43; 42, 44; 43, identifier:operators; 44, identifier:gt; 45, unary_operator:-; 45, 46; 46, integer:1; 47, else_clause; 47, 48; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:gt_ver; 52, None; 53, if_statement; 53, 54; 53, 57; 53, 70; 54, comparison_operator:in; 54, 55; 54, 56; 55, identifier:ge; 56, identifier:operators; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:ge_ver; 61, subscript; 61, 62; 61, 68; 62, call; 62, 63; 62, 64; 63, identifier:sorted; 64, argument_list; 64, 65; 65, subscript; 65, 66; 65, 67; 66, identifier:operators; 67, identifier:ge; 68, unary_operator:-; 68, 69; 69, integer:1; 70, else_clause; 70, 71; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:ge_ver; 75, None; 76, if_statement; 76, 77; 76, 80; 76, 92; 77, comparison_operator:in; 77, 78; 77, 79; 78, identifier:lt; 79, identifier:operators; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:lt_ver; 84, subscript; 84, 85; 84, 91; 85, call; 85, 86; 85, 87; 86, identifier:sorted; 87, argument_list; 87, 88; 88, subscript; 88, 89; 88, 90; 89, identifier:operators; 90, identifier:lt; 91, integer:0; 92, else_clause; 92, 93; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:lt_ver; 97, None; 98, if_statement; 98, 99; 98, 102; 98, 114; 99, comparison_operator:in; 99, 100; 99, 101; 100, identifier:le; 101, identifier:operators; 102, block; 102, 103; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:le_ver; 106, subscript; 106, 107; 106, 113; 107, call; 107, 108; 107, 109; 108, identifier:sorted; 109, argument_list; 109, 110; 110, subscript; 110, 111; 110, 112; 111, identifier:operators; 112, identifier:le; 113, integer:0; 114, else_clause; 114, 115; 115, block; 115, 116; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:le_ver; 119, None; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:l_constraint; 123, None; 124, if_statement; 124, 125; 124, 126; 124, 190; 125, identifier:le_ver; 126, block; 126, 127; 127, if_statement; 127, 128; 127, 129; 127, 180; 128, identifier:lt_ver; 129, block; 129, 130; 129, 138; 129, 146; 129, 169; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:le_constraint; 133, call; 133, 134; 133, 135; 134, identifier:Constraint; 135, argument_list; 135, 136; 135, 137; 136, identifier:le; 137, identifier:le_ver; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:lt_constraint; 141, call; 141, 142; 141, 143; 142, identifier:Constraint; 143, argument_list; 143, 144; 143, 145; 144, identifier:lt; 145, identifier:lt_ver; 146, if_statement; 146, 147; 146, 150; 146, 159; 147, comparison_operator:<; 147, 148; 147, 149; 148, identifier:le_ver; 149, identifier:lt_ver; 150, block; 150, 151; 150, 155; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:l_constraint; 154, identifier:le_constraint; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:l_less_restrictive_c; 158, identifier:lt_constraint; 159, else_clause; 159, 160; 160, block; 160, 161; 160, 165; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:l_constraint; 164, identifier:lt_constraint; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:l_less_restrictive_c; 168, identifier:le_constraint; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:LOGGER; 173, identifier:debug; 174, argument_list; 174, 175; 174, 178; 174, 179; 175, concatenated_string; 175, 176; 175, 177; 176, string:'Removed constraint %s because it is less '; 177, string:'restrictive than %s'; 178, identifier:l_less_restrictive_c; 179, identifier:l_constraint; 180, else_clause; 180, 181; 181, block; 181, 182; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:l_constraint; 185, call; 185, 186; 185, 187; 186, identifier:Constraint; 187, argument_list; 187, 188; 187, 189; 188, identifier:le; 189, identifier:le_ver; 190, elif_clause; 190, 191; 190, 192; 191, identifier:lt_ver; 192, block; 192, 193; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 196; 195, identifier:l_constraint; 196, call; 196, 197; 196, 198; 197, identifier:Constraint; 198, argument_list; 198, 199; 198, 200; 199, identifier:lt; 200, identifier:lt_ver; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:g_constraint; 204, None; 205, if_statement; 205, 206; 205, 207; 205, 271; 206, identifier:ge_ver; 207, block; 207, 208; 208, if_statement; 208, 209; 208, 210; 208, 261; 209, identifier:gt_ver; 210, block; 210, 211; 210, 219; 210, 227; 210, 250; 211, expression_statement; 211, 212; 212, assignment; 212, 213; 212, 214; 213, identifier:gt_constraint; 214, call; 214, 215; 214, 216; 215, identifier:Constraint; 216, argument_list; 216, 217; 216, 218; 217, identifier:gt; 218, identifier:gt_ver; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 222; 221, identifier:ge_constraint; 222, call; 222, 223; 222, 224; 223, identifier:Constraint; 224, argument_list; 224, 225; 224, 226; 225, identifier:ge; 226, identifier:ge_ver; 227, if_statement; 227, 228; 227, 231; 227, 240; 228, comparison_operator:<=; 228, 229; 228, 230; 229, identifier:ge_ver; 230, identifier:gt_ver; 231, block; 231, 232; 231, 236; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:g_constraint; 235, identifier:gt_constraint; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:g_less_restrictive_c; 239, identifier:ge_constraint; 240, else_clause; 240, 241; 241, block; 241, 242; 241, 246; 242, expression_statement; 242, 243; 243, assignment; 243, 244; 243, 245; 244, identifier:g_constraint; 245, identifier:ge_constraint; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 249; 248, identifier:g_less_restrictive_c; 249, identifier:gt_constraint; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:LOGGER; 254, identifier:debug; 255, argument_list; 255, 256; 255, 259; 255, 260; 256, concatenated_string; 256, 257; 256, 258; 257, string:'Removed constraint %s because it is less '; 258, string:'restrictive than %s'; 259, identifier:g_less_restrictive_c; 260, identifier:g_constraint; 261, else_clause; 261, 262; 262, block; 262, 263; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:g_constraint; 266, call; 266, 267; 266, 268; 267, identifier:Constraint; 268, argument_list; 268, 269; 268, 270; 269, identifier:ge; 270, identifier:ge_ver; 271, elif_clause; 271, 272; 271, 273; 272, identifier:gt_ver; 273, block; 273, 274; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:g_constraint; 277, call; 277, 278; 277, 279; 278, identifier:Constraint; 279, argument_list; 279, 280; 279, 281; 280, identifier:gt; 281, identifier:gt_ver; 282, if_statement; 282, 283; 282, 286; 283, boolean_operator:and; 283, 284; 283, 285; 284, identifier:g_constraint; 285, identifier:l_constraint; 286, block; 286, 287; 287, if_statement; 287, 288; 287, 295; 287, 349; 288, comparison_operator:==; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:g_constraint; 291, identifier:version; 292, attribute; 292, 293; 292, 294; 293, identifier:l_constraint; 294, identifier:version; 295, block; 295, 296; 296, if_statement; 296, 297; 296, 308; 296, 340; 297, boolean_operator:and; 297, 298; 297, 303; 298, comparison_operator:==; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:g_constraint; 301, identifier:operator; 302, identifier:ge; 303, comparison_operator:==; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, identifier:l_constraint; 306, identifier:operator; 307, identifier:le; 308, block; 308, 309; 308, 320; 308, 332; 309, expression_statement; 309, 310; 310, call; 310, 311; 310, 316; 311, attribute; 311, 312; 311, 315; 312, subscript; 312, 313; 312, 314; 313, identifier:operators; 314, identifier:eq; 315, identifier:add; 316, argument_list; 316, 317; 317, attribute; 317, 318; 317, 319; 318, identifier:g_constraint; 319, identifier:version; 320, expression_statement; 320, 321; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:LOGGER; 324, identifier:debug; 325, argument_list; 325, 326; 325, 327; 325, 328; 325, 329; 326, string:'Merged constraints: %s and %s into ==%s'; 327, identifier:l_constraint; 328, identifier:g_constraint; 329, attribute; 329, 330; 329, 331; 330, identifier:g_constraint; 331, identifier:version; 332, expression_statement; 332, 333; 333, assignment; 333, 334; 333, 337; 334, pattern_list; 334, 335; 334, 336; 335, identifier:l_constraint; 336, identifier:g_constraint; 337, expression_list; 337, 338; 337, 339; 338, None; 339, None; 340, else_clause; 340, 341; 341, block; 341, 342; 342, raise_statement; 342, 343; 343, call; 343, 344; 343, 345; 344, identifier:ExclusiveConstraints; 345, argument_list; 345, 346; 345, 347; 346, identifier:g_constraint; 347, list:[l_constraint]; 347, 348; 348, identifier:l_constraint; 349, elif_clause; 349, 350; 349, 357; 350, comparison_operator:>; 350, 351; 350, 354; 351, attribute; 351, 352; 351, 353; 352, identifier:g_constraint; 353, identifier:version; 354, attribute; 354, 355; 354, 356; 355, identifier:l_constraint; 356, identifier:version; 357, block; 357, 358; 358, raise_statement; 358, 359; 359, call; 359, 360; 359, 361; 360, identifier:ExclusiveConstraints; 361, argument_list; 361, 362; 361, 363; 362, identifier:g_constraint; 363, list:[l_constraint]; 363, 364; 364, identifier:l_constraint; 365, expression_statement; 365, 366; 366, assignment; 366, 367; 366, 368; 367, identifier:ne_constraints; 368, list_comprehension; 368, 369; 368, 374; 369, call; 369, 370; 369, 371; 370, identifier:Constraint; 371, argument_list; 371, 372; 371, 373; 372, identifier:ne; 373, identifier:v; 374, for_in_clause; 374, 375; 374, 376; 375, identifier:v; 376, subscript; 376, 377; 376, 378; 377, identifier:operators; 378, identifier:ne; 379, expression_statement; 379, 380; 380, assignment; 380, 381; 380, 382; 381, identifier:eq_constraints; 382, list_comprehension; 382, 383; 382, 388; 383, call; 383, 384; 383, 385; 384, identifier:Constraint; 385, argument_list; 385, 386; 385, 387; 386, identifier:eq; 387, identifier:v; 388, for_in_clause; 388, 389; 388, 390; 389, identifier:v; 390, subscript; 390, 391; 390, 392; 391, identifier:operators; 392, identifier:eq; 393, if_statement; 393, 394; 393, 395; 393, 448; 394, identifier:eq_constraints; 395, block; 395, 396; 395, 404; 395, 445; 396, expression_statement; 396, 397; 397, assignment; 397, 398; 397, 399; 398, identifier:eq_constraint; 399, call; 399, 400; 399, 403; 400, attribute; 400, 401; 400, 402; 401, identifier:eq_constraints; 402, identifier:pop; 403, argument_list; 404, if_statement; 404, 405; 404, 412; 405, boolean_operator:or; 405, 406; 405, 411; 406, boolean_operator:or; 406, 407; 406, 410; 407, boolean_operator:or; 407, 408; 407, 409; 408, identifier:g_constraint; 409, identifier:l_constraint; 410, identifier:ne_constraints; 411, identifier:eq_constraints; 412, block; 412, 413; 412, 425; 412, 432; 412, 439; 413, expression_statement; 413, 414; 414, assignment; 414, 415; 414, 416; 415, identifier:conflict_list; 416, list_comprehension; 416, 417; 416, 418; 416, 423; 417, identifier:c; 418, for_in_clause; 418, 419; 418, 420; 419, identifier:c; 420, tuple; 420, 421; 420, 422; 421, identifier:g_constraint; 422, identifier:l_constraint; 423, if_clause; 423, 424; 424, identifier:c; 425, expression_statement; 425, 426; 426, call; 426, 427; 426, 430; 427, attribute; 427, 428; 427, 429; 428, identifier:conflict_list; 429, identifier:extend; 430, argument_list; 430, 431; 431, identifier:ne_constraints; 432, expression_statement; 432, 433; 433, call; 433, 434; 433, 437; 434, attribute; 434, 435; 434, 436; 435, identifier:conflict_list; 436, identifier:extend; 437, argument_list; 437, 438; 438, identifier:eq_constraints; 439, raise_statement; 439, 440; 440, call; 440, 441; 440, 442; 441, identifier:ExclusiveConstraints; 442, argument_list; 442, 443; 442, 444; 443, identifier:eq_constraint; 444, identifier:conflict_list; 445, return_statement; 445, 446; 446, list:[eq_constraint]; 446, 447; 447, identifier:eq_constraint; 448, else_clause; 448, 449; 449, block; 449, 450; 449, 458; 450, expression_statement; 450, 451; 451, assignment; 451, 452; 451, 453; 452, identifier:constraints; 453, binary_operator:+; 453, 454; 453, 455; 454, identifier:ne_constraints; 455, list:[g_constraint, l_constraint]; 455, 456; 455, 457; 456, identifier:g_constraint; 457, identifier:l_constraint; 458, return_statement; 458, 459; 459, list_comprehension; 459, 460; 459, 461; 459, 464; 460, identifier:c; 461, for_in_clause; 461, 462; 461, 463; 462, identifier:c; 463, identifier:constraints; 464, if_clause; 464, 465; 465, identifier:c
def merge(constraints): operators = defaultdict(set) for constraint in constraints: operators[constraint.operator].add(constraint.version) if gt in operators: gt_ver = sorted(operators[gt])[-1] else: gt_ver = None if ge in operators: ge_ver = sorted(operators[ge])[-1] else: ge_ver = None if lt in operators: lt_ver = sorted(operators[lt])[0] else: lt_ver = None if le in operators: le_ver = sorted(operators[le])[0] else: le_ver = None l_constraint = None if le_ver: if lt_ver: le_constraint = Constraint(le, le_ver) lt_constraint = Constraint(lt, lt_ver) if le_ver < lt_ver: l_constraint = le_constraint l_less_restrictive_c = lt_constraint else: l_constraint = lt_constraint l_less_restrictive_c = le_constraint LOGGER.debug('Removed constraint %s because it is less ' 'restrictive than %s', l_less_restrictive_c, l_constraint) else: l_constraint = Constraint(le, le_ver) elif lt_ver: l_constraint = Constraint(lt, lt_ver) g_constraint = None if ge_ver: if gt_ver: gt_constraint = Constraint(gt, gt_ver) ge_constraint = Constraint(ge, ge_ver) if ge_ver <= gt_ver: g_constraint = gt_constraint g_less_restrictive_c = ge_constraint else: g_constraint = ge_constraint g_less_restrictive_c = gt_constraint LOGGER.debug('Removed constraint %s because it is less ' 'restrictive than %s', g_less_restrictive_c, g_constraint) else: g_constraint = Constraint(ge, ge_ver) elif gt_ver: g_constraint = Constraint(gt, gt_ver) if g_constraint and l_constraint: if g_constraint.version == l_constraint.version: if g_constraint.operator == ge and l_constraint.operator == le: operators[eq].add(g_constraint.version) LOGGER.debug('Merged constraints: %s and %s into ==%s', l_constraint, g_constraint, g_constraint.version) l_constraint, g_constraint = None, None else: raise ExclusiveConstraints(g_constraint, [l_constraint]) elif g_constraint.version > l_constraint.version: raise ExclusiveConstraints(g_constraint, [l_constraint]) ne_constraints = [Constraint(ne, v) for v in operators[ne]] eq_constraints = [Constraint(eq, v) for v in operators[eq]] if eq_constraints: eq_constraint = eq_constraints.pop() if g_constraint or l_constraint or ne_constraints or eq_constraints: conflict_list = [c for c in (g_constraint, l_constraint) if c] conflict_list.extend(ne_constraints) conflict_list.extend(eq_constraints) raise ExclusiveConstraints(eq_constraint, conflict_list) return [eq_constraint] else: constraints = ne_constraints + [g_constraint, l_constraint] return [c for c in constraints if c]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_baxter; 3, parameters; 3, 4; 4, identifier:reading; 5, block; 5, 6; 5, 10; 5, 14; 5, 18; 5, 22; 5, 26; 5, 30; 5, 34; 5, 38; 5, 42; 5, 49; 5, 139; 5, 162; 5, 175; 5, 192; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:initial; 9, string:''; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:medial; 13, string:''; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:final; 17, string:''; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:tone; 21, string:''; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:inienv; 25, True; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:medienv; 29, False; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:finenv; 33, False; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:tonenv; 37, False; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:inichars; 41, string:"pbmrtdnkgnsyhzl'x"; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:chars; 45, call; 45, 46; 45, 47; 46, identifier:list; 47, argument_list; 47, 48; 48, identifier:reading; 49, for_statement; 49, 50; 49, 51; 49, 52; 50, identifier:char; 51, identifier:chars; 52, block; 52, 53; 52, 111; 52, 118; 52, 125; 52, 132; 53, if_statement; 53, 54; 53, 60; 53, 73; 54, boolean_operator:and; 54, 55; 54, 58; 55, comparison_operator:in; 55, 56; 55, 57; 56, identifier:char; 57, string:'jw'; 58, not_operator; 58, 59; 59, identifier:finenv; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 68; 63, pattern_list; 63, 64; 63, 65; 63, 66; 63, 67; 64, identifier:inienv; 65, identifier:medienv; 66, identifier:finenv; 67, identifier:tonenv; 68, expression_list; 68, 69; 68, 70; 68, 71; 68, 72; 69, False; 70, True; 71, False; 72, False; 73, elif_clause; 73, 74; 73, 79; 74, boolean_operator:or; 74, 75; 74, 78; 75, comparison_operator:not; 75, 76; 75, 77; 76, identifier:char; 77, identifier:inichars; 78, identifier:finenv; 79, block; 79, 80; 80, if_statement; 80, 81; 80, 84; 80, 97; 81, comparison_operator:in; 81, 82; 81, 83; 82, identifier:char; 83, string:'XH'; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 92; 87, pattern_list; 87, 88; 87, 89; 87, 90; 87, 91; 88, identifier:inienv; 89, identifier:medienv; 90, identifier:finenv; 91, identifier:tonenv; 92, expression_list; 92, 93; 92, 94; 92, 95; 92, 96; 93, False; 94, False; 95, False; 96, True; 97, else_clause; 97, 98; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 106; 101, pattern_list; 101, 102; 101, 103; 101, 104; 101, 105; 102, identifier:inienv; 103, identifier:medienv; 104, identifier:finenv; 105, identifier:tonenv; 106, expression_list; 106, 107; 106, 108; 106, 109; 106, 110; 107, False; 108, False; 109, True; 110, False; 111, if_statement; 111, 112; 111, 113; 112, identifier:inienv; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, augmented_assignment:+=; 115, 116; 115, 117; 116, identifier:initial; 117, identifier:char; 118, if_statement; 118, 119; 118, 120; 119, identifier:medienv; 120, block; 120, 121; 121, expression_statement; 121, 122; 122, augmented_assignment:+=; 122, 123; 122, 124; 123, identifier:medial; 124, identifier:char; 125, if_statement; 125, 126; 125, 127; 126, identifier:finenv; 127, block; 127, 128; 128, expression_statement; 128, 129; 129, augmented_assignment:+=; 129, 130; 129, 131; 130, identifier:final; 131, identifier:char; 132, if_statement; 132, 133; 132, 134; 133, identifier:tonenv; 134, block; 134, 135; 135, expression_statement; 135, 136; 136, augmented_assignment:+=; 136, 137; 136, 138; 137, identifier:tone; 138, identifier:char; 139, if_statement; 139, 140; 139, 149; 139, 154; 140, boolean_operator:and; 140, 141; 140, 143; 141, not_operator; 141, 142; 142, identifier:tone; 143, comparison_operator:in; 143, 144; 143, 148; 144, subscript; 144, 145; 144, 146; 145, identifier:final; 146, unary_operator:-; 146, 147; 147, integer:1; 148, string:'ptk'; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:tone; 153, string:'R'; 154, elif_clause; 154, 155; 154, 157; 155, not_operator; 155, 156; 156, identifier:tone; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:tone; 161, string:'P'; 162, if_statement; 162, 163; 162, 170; 163, boolean_operator:and; 163, 164; 163, 167; 164, comparison_operator:not; 164, 165; 164, 166; 165, string:'j'; 166, identifier:medial; 167, comparison_operator:in; 167, 168; 167, 169; 168, string:'y'; 169, identifier:initial; 170, block; 170, 171; 171, expression_statement; 171, 172; 172, augmented_assignment:+=; 172, 173; 172, 174; 173, identifier:medial; 174, string:'j'; 175, if_statement; 175, 176; 175, 185; 176, boolean_operator:and; 176, 177; 176, 182; 177, comparison_operator:in; 177, 178; 177, 181; 178, subscript; 178, 179; 178, 180; 179, identifier:final; 180, integer:0; 181, string:'u'; 182, comparison_operator:not; 182, 183; 182, 184; 183, string:'w'; 184, identifier:medial; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:medial; 189, binary_operator:+; 189, 190; 189, 191; 190, string:'w'; 191, identifier:medial; 192, return_statement; 192, 193; 193, expression_list; 193, 194; 193, 195; 193, 196; 193, 197; 194, identifier:initial; 195, identifier:medial; 196, identifier:final; 197, identifier:tone
def parse_baxter(reading): initial = '' medial = '' final = '' tone = '' inienv = True medienv = False finenv = False tonenv = False inichars = "pbmrtdnkgnsyhzl'x" chars = list(reading) for char in chars: if char in 'jw' and not finenv: inienv,medienv,finenv,tonenv = False,True,False,False elif char not in inichars or finenv: if char in 'XH': inienv,medienv,finenv,tonenv = False,False,False,True else: inienv,medienv,finenv,tonenv = False,False,True,False if inienv: initial += char if medienv: medial += char if finenv: final += char if tonenv: tone += char if not tone and final[-1] in 'ptk': tone = 'R' elif not tone: tone = 'P' if 'j' not in medial and 'y' in initial: medial += 'j' if final[0] in 'u' and 'w' not in medial: medial = 'w' + medial return initial,medial,final,tone
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:query; 6, keyword_separator; 7, default_parameter; 7, 8; 7, 9; 8, identifier:dc; 9, None; 10, block; 10, 11; 10, 31; 10, 52; 11, if_statement; 11, 12; 11, 15; 12, comparison_operator:in; 12, 13; 12, 14; 13, string:"Token"; 14, identifier:query; 15, block; 15, 16; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 21; 18, subscript; 18, 19; 18, 20; 19, identifier:query; 20, string:"Token"; 21, call; 21, 22; 21, 23; 22, identifier:extract_attr; 23, argument_list; 23, 24; 23, 27; 24, subscript; 24, 25; 24, 26; 25, identifier:query; 26, string:"Token"; 27, keyword_argument; 27, 28; 27, 29; 28, identifier:keys; 29, list:["ID"]; 29, 30; 30, string:"ID"; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:response; 34, await; 34, 35; 35, call; 35, 36; 35, 41; 36, attribute; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:_api; 40, identifier:post; 41, argument_list; 41, 42; 41, 43; 41, 49; 42, string:"/v1/query"; 43, keyword_argument; 43, 44; 43, 45; 44, identifier:params; 45, dictionary; 45, 46; 46, pair; 46, 47; 46, 48; 47, string:"dc"; 48, identifier:dc; 49, keyword_argument; 49, 50; 49, 51; 50, identifier:data; 51, identifier:query; 52, return_statement; 52, 53; 53, attribute; 53, 54; 53, 55; 54, identifier:response; 55, identifier:body
async def create(self, query, *, dc=None): if "Token" in query: query["Token"] = extract_attr(query["Token"], keys=["ID"]) response = await self._api.post("/v1/query", params={"dc": dc}, data=query) return response.body
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:execute; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:query; 6, keyword_separator; 7, default_parameter; 7, 8; 7, 9; 8, identifier:dc; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:near; 12, None; 13, default_parameter; 13, 14; 13, 15; 14, identifier:limit; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:consistency; 18, None; 19, block; 19, 20; 19, 31; 19, 60; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:query_id; 23, call; 23, 24; 23, 25; 24, identifier:extract_attr; 25, argument_list; 25, 26; 25, 27; 26, identifier:query; 27, keyword_argument; 27, 28; 27, 29; 28, identifier:keys; 29, list:["ID"]; 29, 30; 30, string:"ID"; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:response; 34, await; 34, 35; 35, call; 35, 36; 35, 41; 36, attribute; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:_api; 40, identifier:get; 41, argument_list; 41, 42; 41, 45; 41, 57; 42, binary_operator:%; 42, 43; 42, 44; 43, string:"/v1/query/%s/execute"; 44, identifier:query_id; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:params; 47, dictionary; 47, 48; 47, 51; 47, 54; 48, pair; 48, 49; 48, 50; 49, string:"dc"; 50, identifier:dc; 51, pair; 51, 52; 51, 53; 52, string:"near"; 53, identifier:near; 54, pair; 54, 55; 54, 56; 55, string:"limit"; 56, identifier:limit; 57, keyword_argument; 57, 58; 57, 59; 58, identifier:consistency; 59, identifier:consistency; 60, return_statement; 60, 61; 61, attribute; 61, 62; 61, 63; 62, identifier:response; 63, identifier:body
async def execute(self, query, *, dc=None, near=None, limit=None, consistency=None): query_id = extract_attr(query, keys=["ID"]) response = await self._api.get( "/v1/query/%s/execute" % query_id, params={"dc": dc, "near": near, "limit": limit}, consistency=consistency) return response.body
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:zip_process; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:kwargs; 6, block; 6, 7; 6, 11; 6, 15; 6, 19; 6, 23; 6, 69; 6, 94; 6, 253; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:str_localPath; 10, string:""; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:str_zipFileName; 14, string:""; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:str_action; 18, string:"zip"; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:str_arcroot; 22, string:""; 23, for_statement; 23, 24; 23, 27; 23, 32; 24, pattern_list; 24, 25; 24, 26; 25, identifier:k; 26, identifier:v; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:kwargs; 30, identifier:items; 31, argument_list; 32, block; 32, 33; 32, 42; 32, 51; 32, 60; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:==; 34, 35; 34, 36; 35, identifier:k; 36, string:'path'; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:str_localPath; 41, identifier:v; 42, if_statement; 42, 43; 42, 46; 43, comparison_operator:==; 43, 44; 43, 45; 44, identifier:k; 45, string:'action'; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:str_action; 50, identifier:v; 51, if_statement; 51, 52; 51, 55; 52, comparison_operator:==; 52, 53; 52, 54; 53, identifier:k; 54, string:'payloadFile'; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:str_zipFileName; 59, identifier:v; 60, if_statement; 60, 61; 60, 64; 61, comparison_operator:==; 61, 62; 61, 63; 62, identifier:k; 63, string:'arcroot'; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:str_arcroot; 68, identifier:v; 69, if_statement; 69, 70; 69, 73; 69, 88; 70, comparison_operator:==; 70, 71; 70, 72; 71, identifier:str_action; 72, string:'zip'; 73, block; 73, 74; 73, 78; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:str_mode; 77, string:'w'; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:str_zipFileName; 81, binary_operator:%; 81, 82; 81, 83; 82, string:'%s.zip'; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:uuid; 86, identifier:uuid4; 87, argument_list; 88, else_clause; 88, 89; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:str_mode; 93, string:'r'; 94, try_statement; 94, 95; 94, 241; 95, block; 95, 96; 95, 109; 95, 213; 95, 225; 95, 231; 95, 237; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:ziphandler; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:zipfile; 102, identifier:ZipFile; 103, argument_list; 103, 104; 103, 105; 103, 106; 104, identifier:str_zipFileName; 105, identifier:str_mode; 106, attribute; 106, 107; 106, 108; 107, identifier:zipfile; 108, identifier:ZIP_DEFLATED; 109, if_statement; 109, 110; 109, 113; 110, comparison_operator:==; 110, 111; 110, 112; 111, identifier:str_mode; 112, string:'w'; 113, block; 113, 114; 114, if_statement; 114, 115; 114, 123; 114, 133; 115, call; 115, 116; 115, 121; 116, attribute; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:os; 119, identifier:path; 120, identifier:isdir; 121, argument_list; 121, 122; 122, identifier:str_localPath; 123, block; 123, 124; 124, expression_statement; 124, 125; 125, call; 125, 126; 125, 127; 126, identifier:zipdir; 127, argument_list; 127, 128; 127, 129; 127, 130; 128, identifier:str_localPath; 129, identifier:ziphandler; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:arcroot; 132, identifier:str_arcroot; 133, else_clause; 133, 134; 134, block; 134, 135; 134, 168; 135, if_statement; 135, 136; 135, 140; 135, 162; 136, call; 136, 137; 136, 138; 137, identifier:len; 138, argument_list; 138, 139; 139, identifier:str_arcroot; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:str_arcname; 144, binary_operator:+; 144, 145; 144, 154; 145, subscript; 145, 146; 145, 152; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:str_arcroot; 149, identifier:split; 150, argument_list; 150, 151; 151, string:'/'; 152, unary_operator:-; 152, 153; 153, integer:1; 154, subscript; 154, 155; 154, 161; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:str_localPath; 158, identifier:split; 159, argument_list; 159, 160; 160, identifier:str_arcroot; 161, integer:1; 162, else_clause; 162, 163; 163, block; 163, 164; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:str_arcname; 167, identifier:str_localPath; 168, try_statement; 168, 169; 168, 180; 169, block; 169, 170; 170, expression_statement; 170, 171; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:ziphandler; 174, identifier:write; 175, argument_list; 175, 176; 175, 177; 176, identifier:str_localPath; 177, keyword_argument; 177, 178; 177, 179; 178, identifier:arcname; 179, identifier:str_arcname; 180, except_clause; 180, 181; 181, block; 181, 182; 181, 188; 181, 195; 182, expression_statement; 182, 183; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:ziphandler; 186, identifier:close; 187, argument_list; 188, expression_statement; 188, 189; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:os; 192, identifier:remove; 193, argument_list; 193, 194; 194, identifier:str_zipFileName; 195, return_statement; 195, 196; 196, dictionary; 196, 197; 196, 210; 197, pair; 197, 198; 197, 199; 198, string:'msg'; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:json; 202, identifier:dumps; 203, argument_list; 203, 204; 204, dictionary; 204, 205; 205, pair; 205, 206; 205, 207; 206, string:"msg"; 207, binary_operator:%; 207, 208; 207, 209; 208, string:"No file or directory found for '%s'"; 209, identifier:str_localPath; 210, pair; 210, 211; 210, 212; 211, string:'status'; 212, False; 213, if_statement; 213, 214; 213, 217; 214, comparison_operator:==; 214, 215; 214, 216; 215, identifier:str_mode; 216, string:'r'; 217, block; 217, 218; 218, expression_statement; 218, 219; 219, call; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:ziphandler; 222, identifier:extractall; 223, argument_list; 223, 224; 224, identifier:str_localPath; 225, expression_statement; 225, 226; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:ziphandler; 229, identifier:close; 230, argument_list; 231, expression_statement; 231, 232; 232, assignment; 232, 233; 232, 234; 233, identifier:str_msg; 234, binary_operator:%; 234, 235; 234, 236; 235, string:'%s operation successful'; 236, identifier:str_action; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:b_status; 240, True; 241, except_clause; 241, 242; 242, block; 242, 243; 242, 249; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:str_msg; 246, binary_operator:%; 246, 247; 246, 248; 247, string:'%s operation failed'; 248, identifier:str_action; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 252; 251, identifier:b_status; 252, False; 253, return_statement; 253, 254; 254, dictionary; 254, 255; 254, 258; 254, 261; 254, 264; 254, 267; 254, 270; 254, 285; 255, pair; 255, 256; 255, 257; 256, string:'msg'; 257, identifier:str_msg; 258, pair; 258, 259; 258, 260; 259, string:'fileProcessed'; 260, identifier:str_zipFileName; 261, pair; 261, 262; 261, 263; 262, string:'status'; 263, identifier:b_status; 264, pair; 264, 265; 264, 266; 265, string:'path'; 266, identifier:str_localPath; 267, pair; 267, 268; 267, 269; 268, string:'zipmode'; 269, identifier:str_mode; 270, pair; 270, 271; 270, 272; 271, string:'filesize'; 272, call; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, string:"{:,}"; 275, identifier:format; 276, argument_list; 276, 277; 277, attribute; 277, 278; 277, 284; 278, call; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:os; 281, identifier:stat; 282, argument_list; 282, 283; 283, identifier:str_zipFileName; 284, identifier:st_size; 285, pair; 285, 286; 285, 287; 286, string:'timestamp'; 287, binary_operator:%; 287, 288; 287, 289; 288, string:'%s'; 289, call; 289, 290; 289, 295; 290, attribute; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:datetime; 293, identifier:datetime; 294, identifier:now; 295, argument_list
def zip_process(**kwargs): str_localPath = "" str_zipFileName = "" str_action = "zip" str_arcroot = "" for k,v in kwargs.items(): if k == 'path': str_localPath = v if k == 'action': str_action = v if k == 'payloadFile': str_zipFileName = v if k == 'arcroot': str_arcroot = v if str_action == 'zip': str_mode = 'w' str_zipFileName = '%s.zip' % uuid.uuid4() else: str_mode = 'r' try: ziphandler = zipfile.ZipFile(str_zipFileName, str_mode, zipfile.ZIP_DEFLATED) if str_mode == 'w': if os.path.isdir(str_localPath): zipdir(str_localPath, ziphandler, arcroot = str_arcroot) else: if len(str_arcroot): str_arcname = str_arcroot.split('/')[-1] + str_localPath.split(str_arcroot)[1] else: str_arcname = str_localPath try: ziphandler.write(str_localPath, arcname = str_arcname) except: ziphandler.close() os.remove(str_zipFileName) return { 'msg': json.dumps({"msg": "No file or directory found for '%s'" % str_localPath}), 'status': False } if str_mode == 'r': ziphandler.extractall(str_localPath) ziphandler.close() str_msg = '%s operation successful' % str_action b_status = True except: str_msg = '%s operation failed' % str_action b_status = False return { 'msg': str_msg, 'fileProcessed': str_zipFileName, 'status': b_status, 'path': str_localPath, 'zipmode': str_mode, 'filesize': "{:,}".format(os.stat(str_zipFileName).st_size), 'timestamp': '%s' % datetime.datetime.now() }
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:base64_process; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:kwargs; 6, block; 6, 7; 6, 11; 6, 15; 6, 19; 6, 23; 6, 69; 6, 151; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:str_fileToSave; 10, string:""; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:str_fileToRead; 14, string:""; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:str_action; 18, string:"encode"; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:data; 22, None; 23, for_statement; 23, 24; 23, 27; 23, 32; 24, pattern_list; 24, 25; 24, 26; 25, identifier:k; 26, identifier:v; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:kwargs; 30, identifier:items; 31, argument_list; 32, block; 32, 33; 32, 42; 32, 51; 32, 60; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:==; 34, 35; 34, 36; 35, identifier:k; 36, string:'action'; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:str_action; 41, identifier:v; 42, if_statement; 42, 43; 42, 46; 43, comparison_operator:==; 43, 44; 43, 45; 44, identifier:k; 45, string:'payloadBytes'; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:data; 50, identifier:v; 51, if_statement; 51, 52; 51, 55; 52, comparison_operator:==; 52, 53; 52, 54; 53, identifier:k; 54, string:'payloadFile'; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:str_fileToRead; 59, identifier:v; 60, if_statement; 60, 61; 60, 64; 61, comparison_operator:==; 61, 62; 61, 63; 62, identifier:k; 63, string:'saveToFile'; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:str_fileToSave; 68, identifier:v; 69, if_statement; 69, 70; 69, 73; 70, comparison_operator:==; 70, 71; 70, 72; 71, identifier:str_action; 72, string:"encode"; 73, block; 73, 74; 73, 106; 73, 115; 73, 140; 74, if_statement; 74, 75; 74, 79; 75, call; 75, 76; 75, 77; 76, identifier:len; 77, argument_list; 77, 78; 78, identifier:str_fileToRead; 79, block; 79, 80; 80, with_statement; 80, 81; 80, 91; 81, with_clause; 81, 82; 82, with_item; 82, 83; 83, as_pattern; 83, 84; 83, 89; 84, call; 84, 85; 84, 86; 85, identifier:open; 86, argument_list; 86, 87; 86, 88; 87, identifier:str_fileToRead; 88, string:'rb'; 89, as_pattern_target; 89, 90; 90, identifier:f; 91, block; 91, 92; 91, 100; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:data; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:f; 98, identifier:read; 99, argument_list; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:f; 104, identifier:close; 105, argument_list; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:data_b64; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:base64; 112, identifier:b64encode; 113, argument_list; 113, 114; 114, identifier:data; 115, with_statement; 115, 116; 115, 126; 116, with_clause; 116, 117; 117, with_item; 117, 118; 118, as_pattern; 118, 119; 118, 124; 119, call; 119, 120; 119, 121; 120, identifier:open; 121, argument_list; 121, 122; 121, 123; 122, identifier:str_fileToSave; 123, string:'wb'; 124, as_pattern_target; 124, 125; 125, identifier:f; 126, block; 126, 127; 126, 134; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:f; 131, identifier:write; 132, argument_list; 132, 133; 133, identifier:data_b64; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:f; 138, identifier:close; 139, argument_list; 140, return_statement; 140, 141; 141, dictionary; 141, 142; 141, 145; 141, 148; 142, pair; 142, 143; 142, 144; 143, string:'msg'; 144, string:'Encode successful'; 145, pair; 145, 146; 145, 147; 146, string:'fileProcessed'; 147, identifier:str_fileToSave; 148, pair; 148, 149; 148, 150; 149, string:'status'; 150, True; 151, if_statement; 151, 152; 151, 155; 152, comparison_operator:==; 152, 153; 152, 154; 153, identifier:str_action; 154, string:"decode"; 155, block; 155, 156; 155, 167; 155, 192; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:bytes_decoded; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:base64; 162, identifier:b64decode; 163, argument_list; 163, 164; 164, binary_operator:+; 164, 165; 164, 166; 165, identifier:data; 166, string:"==="; 167, with_statement; 167, 168; 167, 178; 168, with_clause; 168, 169; 169, with_item; 169, 170; 170, as_pattern; 170, 171; 170, 176; 171, call; 171, 172; 171, 173; 172, identifier:open; 173, argument_list; 173, 174; 173, 175; 174, identifier:str_fileToSave; 175, string:'wb'; 176, as_pattern_target; 176, 177; 177, identifier:f; 178, block; 178, 179; 178, 186; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:f; 183, identifier:write; 184, argument_list; 184, 185; 185, identifier:bytes_decoded; 186, expression_statement; 186, 187; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:f; 190, identifier:close; 191, argument_list; 192, return_statement; 192, 193; 193, dictionary; 193, 194; 193, 197; 193, 200; 194, pair; 194, 195; 194, 196; 195, string:'msg'; 196, string:'Decode successful'; 197, pair; 197, 198; 197, 199; 198, string:'fileProcessed'; 199, identifier:str_fileToSave; 200, pair; 200, 201; 200, 202; 201, string:'status'; 202, True
def base64_process(**kwargs): str_fileToSave = "" str_fileToRead = "" str_action = "encode" data = None for k,v in kwargs.items(): if k == 'action': str_action = v if k == 'payloadBytes': data = v if k == 'payloadFile': str_fileToRead = v if k == 'saveToFile': str_fileToSave = v if str_action == "encode": if len(str_fileToRead): with open(str_fileToRead, 'rb') as f: data = f.read() f.close() data_b64 = base64.b64encode(data) with open(str_fileToSave, 'wb') as f: f.write(data_b64) f.close() return { 'msg': 'Encode successful', 'fileProcessed': str_fileToSave, 'status': True } if str_action == "decode": bytes_decoded = base64.b64decode(data + "===") with open(str_fileToSave, 'wb') as f: f.write(bytes_decoded) f.close() return { 'msg': 'Decode successful', 'fileProcessed': str_fileToSave, 'status': True }
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:path_localLocationCheck; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:d_msg; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 13; 8, 19; 8, 35; 8, 46; 8, 57; 8, 63; 8, 76; 8, 80; 8, 84; 8, 95; 8, 106; 8, 117; 8, 272; 8, 296; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:b_pull; 12, False; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:d_meta; 16, subscript; 16, 17; 16, 18; 17, identifier:d_msg; 18, string:'meta'; 19, if_statement; 19, 20; 19, 23; 20, comparison_operator:in; 20, 21; 20, 22; 21, string:'do'; 22, identifier:d_meta; 23, block; 23, 24; 24, if_statement; 24, 25; 24, 30; 25, comparison_operator:==; 25, 26; 25, 29; 26, subscript; 26, 27; 26, 28; 27, identifier:d_meta; 28, string:'do'; 29, string:'pull'; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:b_pull; 34, True; 35, if_statement; 35, 36; 35, 39; 36, comparison_operator:in; 36, 37; 36, 38; 37, string:'local'; 38, identifier:d_meta; 39, block; 39, 40; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:d_local; 43, subscript; 43, 44; 43, 45; 44, identifier:d_meta; 45, string:'local'; 46, if_statement; 46, 47; 46, 50; 47, comparison_operator:in; 47, 48; 47, 49; 48, string:'to'; 49, identifier:d_meta; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:d_local; 54, subscript; 54, 55; 54, 56; 55, identifier:d_meta; 56, string:'to'; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:str_localPathFull; 60, subscript; 60, 61; 60, 62; 61, identifier:d_local; 62, string:'path'; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 68; 65, pattern_list; 65, 66; 65, 67; 66, identifier:str_localPath; 67, identifier:str_unpack; 68, call; 68, 69; 68, 74; 69, attribute; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:os; 72, identifier:path; 73, identifier:split; 74, argument_list; 74, 75; 75, identifier:str_localPathFull; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:str_msg; 79, string:''; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:str_checkedDir; 83, identifier:str_localPathFull; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:b_isFile; 87, call; 87, 88; 87, 93; 88, attribute; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:os; 91, identifier:path; 92, identifier:isfile; 93, argument_list; 93, 94; 94, identifier:str_localPathFull; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:b_isDir; 98, call; 98, 99; 98, 104; 99, attribute; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:os; 102, identifier:path; 103, identifier:isdir; 104, argument_list; 104, 105; 105, identifier:str_localPathFull; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:b_exists; 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:exists; 115, argument_list; 115, 116; 116, identifier:str_localPathFull; 117, if_statement; 117, 118; 117, 125; 118, boolean_operator:or; 118, 119; 118, 124; 119, comparison_operator:in; 119, 120; 119, 121; 120, string:'pull'; 121, subscript; 121, 122; 121, 123; 122, identifier:d_msg; 123, string:'action'; 124, identifier:b_pull; 125, block; 125, 126; 125, 130; 125, 141; 125, 152; 125, 163; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:str_checkedDir; 129, identifier:str_localPath; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:b_isFile; 133, call; 133, 134; 133, 139; 134, attribute; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:os; 137, identifier:path; 138, identifier:isfile; 139, argument_list; 139, 140; 140, identifier:str_localPath; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:b_isDir; 144, call; 144, 145; 144, 150; 145, attribute; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:os; 148, identifier:path; 149, identifier:isdir; 150, argument_list; 150, 151; 151, identifier:str_localPath; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:b_exists; 155, call; 155, 156; 155, 161; 156, attribute; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:os; 159, identifier:path; 160, identifier:exists; 161, argument_list; 161, 162; 162, identifier:str_localPath; 163, if_statement; 163, 164; 163, 171; 163, 235; 164, comparison_operator:in; 164, 165; 164, 166; 165, string:'createDir'; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:d_local; 169, identifier:keys; 170, argument_list; 171, block; 171, 172; 172, if_statement; 172, 173; 172, 176; 173, subscript; 173, 174; 173, 175; 174, identifier:d_local; 175, string:'createDir'; 176, block; 176, 177; 176, 209; 176, 220; 176, 227; 176, 231; 177, if_statement; 177, 178; 177, 186; 178, call; 178, 179; 178, 184; 179, attribute; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:os; 182, identifier:path; 183, identifier:isdir; 184, argument_list; 184, 185; 185, identifier:str_localPathFull; 186, block; 186, 187; 186, 198; 186, 205; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 194; 189, attribute; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:self; 192, identifier:dp; 193, identifier:qprint; 194, argument_list; 194, 195; 195, binary_operator:%; 195, 196; 195, 197; 196, string:'Removing local path %s...'; 197, identifier:str_localPathFull; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:shutil; 202, identifier:rmtree; 203, argument_list; 203, 204; 204, identifier:str_localPathFull; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:str_msg; 208, string:'Removed existing local path... '; 209, expression_statement; 209, 210; 210, call; 210, 211; 210, 216; 211, attribute; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:self; 214, identifier:dp; 215, identifier:qprint; 216, argument_list; 216, 217; 217, binary_operator:%; 217, 218; 217, 219; 218, string:'Creating empty local path %s...'; 219, identifier:str_localPathFull; 220, expression_statement; 220, 221; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:os; 224, identifier:makedirs; 225, argument_list; 225, 226; 226, identifier:str_localPathFull; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:b_exists; 230, True; 231, expression_statement; 231, 232; 232, augmented_assignment:+=; 232, 233; 232, 234; 233, identifier:str_msg; 234, string:'Created new local path'; 235, else_clause; 235, 236; 236, block; 236, 237; 236, 241; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:str_msg; 240, string:'local path already exists!'; 241, if_statement; 241, 242; 241, 249; 241, 263; 242, comparison_operator:in; 242, 243; 242, 244; 243, string:'writeInExisting'; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:d_local; 247, identifier:keys; 248, argument_list; 249, block; 249, 250; 250, if_statement; 250, 251; 250, 255; 251, not_operator; 251, 252; 252, subscript; 252, 253; 252, 254; 253, identifier:d_local; 254, string:'writeInExisting'; 255, block; 255, 256; 256, if_statement; 256, 257; 256, 258; 257, identifier:b_isDir; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 262; 261, identifier:b_exists; 262, False; 263, else_clause; 263, 264; 264, block; 264, 265; 265, if_statement; 265, 266; 265, 267; 266, identifier:b_isDir; 267, block; 267, 268; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 271; 270, identifier:b_exists; 271, False; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:d_ret; 275, dictionary; 275, 276; 275, 281; 275, 284; 275, 287; 275, 290; 275, 293; 276, pair; 276, 277; 276, 278; 277, string:'action'; 278, subscript; 278, 279; 278, 280; 279, identifier:d_msg; 280, string:'action'; 281, pair; 281, 282; 281, 283; 282, string:'dir'; 283, identifier:str_checkedDir; 284, pair; 284, 285; 284, 286; 285, string:'status'; 286, identifier:b_exists; 287, pair; 287, 288; 287, 289; 288, string:'isfile'; 289, identifier:b_isFile; 290, pair; 290, 291; 290, 292; 291, string:'isdir'; 292, identifier:b_isDir; 293, pair; 293, 294; 293, 295; 294, string:'msg'; 295, identifier:str_msg; 296, return_statement; 296, 297; 297, dictionary; 297, 298; 297, 301; 297, 306; 298, pair; 298, 299; 298, 300; 299, string:'check'; 300, identifier:d_ret; 301, pair; 301, 302; 301, 303; 302, string:'status'; 303, subscript; 303, 304; 303, 305; 304, identifier:d_ret; 305, string:'status'; 306, pair; 306, 307; 306, 308; 307, string:'timestamp'; 308, binary_operator:%; 308, 309; 308, 310; 309, string:'%s'; 310, call; 310, 311; 310, 316; 311, attribute; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:datetime; 314, identifier:datetime; 315, identifier:now; 316, argument_list
def path_localLocationCheck(self, d_msg, **kwargs): b_pull = False d_meta = d_msg['meta'] if 'do' in d_meta: if d_meta['do'] == 'pull': b_pull = True if 'local' in d_meta: d_local = d_meta['local'] if 'to' in d_meta: d_local = d_meta['to'] str_localPathFull = d_local['path'] str_localPath, str_unpack = os.path.split(str_localPathFull) str_msg = '' str_checkedDir = str_localPathFull b_isFile = os.path.isfile(str_localPathFull) b_isDir = os.path.isdir(str_localPathFull) b_exists = os.path.exists(str_localPathFull) if 'pull' in d_msg['action'] or b_pull: str_checkedDir = str_localPath b_isFile = os.path.isfile(str_localPath) b_isDir = os.path.isdir(str_localPath) b_exists = os.path.exists(str_localPath) if 'createDir' in d_local.keys(): if d_local['createDir']: if os.path.isdir(str_localPathFull): self.dp.qprint('Removing local path %s...' % str_localPathFull) shutil.rmtree(str_localPathFull) str_msg = 'Removed existing local path... ' self.dp.qprint('Creating empty local path %s...' % str_localPathFull) os.makedirs(str_localPathFull) b_exists = True str_msg += 'Created new local path' else: str_msg = 'local path already exists!' if 'writeInExisting' in d_local.keys(): if not d_local['writeInExisting']: if b_isDir: b_exists = False else: if b_isDir: b_exists = False d_ret = { 'action': d_msg['action'], 'dir': str_checkedDir, 'status': b_exists, 'isfile': b_isFile, 'isdir': b_isDir, 'msg': str_msg } return {'check': d_ret, 'status': d_ret['status'], 'timestamp': '%s' % datetime.datetime.now()}
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:rebuild; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 25; 5, 87; 5, 115; 5, 122; 5, 130; 5, 138; 5, 156; 5, 162; 5, 342; 5, 349; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:table; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:tableType; 13, argument_list; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:form; 17, call; 17, 18; 17, 19; 18, identifier:nativestring; 19, argument_list; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:filterFormat; 24, argument_list; 25, if_statement; 25, 26; 25, 30; 25, 82; 26, boolean_operator:and; 26, 27; 26, 29; 27, not_operator; 27, 28; 28, identifier:table; 29, identifier:form; 30, block; 30, 31; 30, 81; 31, if_statement; 31, 32; 31, 43; 31, 59; 32, comparison_operator:==; 32, 33; 32, 42; 33, call; 33, 34; 33, 41; 34, attribute; 34, 35; 34, 40; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:layout; 39, argument_list; 40, identifier:count; 41, argument_list; 42, integer:0; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 53; 46, attribute; 46, 47; 46, 52; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:layout; 51, argument_list; 52, identifier:addWidget; 53, argument_list; 53, 54; 54, call; 54, 55; 54, 56; 55, identifier:QLabel; 56, argument_list; 56, 57; 56, 58; 57, identifier:form; 58, identifier:self; 59, else_clause; 59, 60; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, call; 62, 63; 62, 79; 63, attribute; 63, 64; 63, 78; 64, call; 64, 65; 64, 77; 65, attribute; 65, 66; 65, 76; 66, call; 66, 67; 66, 74; 67, attribute; 67, 68; 67, 73; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:layout; 72, argument_list; 73, identifier:itemAt; 74, argument_list; 74, 75; 75, integer:0; 76, identifier:widget; 77, argument_list; 78, identifier:setText; 79, argument_list; 79, 80; 80, identifier:form; 81, return_statement; 82, elif_clause; 82, 83; 82, 85; 83, not_operator; 83, 84; 84, identifier:form; 85, block; 85, 86; 86, return_statement; 87, for_statement; 87, 88; 87, 89; 87, 95; 88, identifier:child; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:findChildren; 93, argument_list; 93, 94; 94, identifier:QWidget; 95, block; 95, 96; 95, 102; 95, 109; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:child; 100, identifier:close; 101, argument_list; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:child; 106, identifier:setParent; 107, argument_list; 107, 108; 108, None; 109, expression_statement; 109, 110; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:child; 113, identifier:deleteLater; 114, argument_list; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:setUpdatesEnabled; 120, argument_list; 120, 121; 121, False; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:schema; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:table; 128, identifier:schema; 129, argument_list; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:vlayout; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:self; 136, identifier:layout; 137, argument_list; 138, for_statement; 138, 139; 138, 140; 138, 148; 139, identifier:i; 140, call; 140, 141; 140, 142; 141, identifier:range; 142, argument_list; 142, 143; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:vlayout; 146, identifier:count; 147, argument_list; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:vlayout; 153, identifier:takeAt; 154, argument_list; 154, 155; 155, integer:0; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:_plugins; 161, list:[]; 162, for_statement; 162, 163; 162, 164; 162, 170; 163, identifier:line; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:form; 167, identifier:split; 168, argument_list; 168, 169; 169, string:'\n'; 170, block; 170, 171; 170, 177; 170, 187; 170, 194; 170, 328; 170, 335; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:row; 174, call; 174, 175; 174, 176; 175, identifier:QHBoxLayout; 176, argument_list; 177, expression_statement; 177, 178; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:row; 181, identifier:setContentsMargins; 182, argument_list; 182, 183; 182, 184; 182, 185; 182, 186; 183, integer:0; 184, integer:0; 185, integer:0; 186, integer:0; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:row; 191, identifier:setSpacing; 192, argument_list; 192, 193; 193, integer:0; 194, for_statement; 194, 195; 194, 198; 194, 204; 195, pattern_list; 195, 196; 195, 197; 196, identifier:label; 197, identifier:lookup; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:FORMAT_SPLITTER; 201, identifier:findall; 202, argument_list; 202, 203; 203, identifier:line; 204, block; 204, 205; 204, 213; 204, 220; 204, 229; 204, 244; 204, 255; 204, 260; 204, 273; 204, 278; 204, 292; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:lbl; 208, call; 208, 209; 208, 210; 209, identifier:QLabel; 210, argument_list; 210, 211; 210, 212; 211, identifier:label; 212, identifier:self; 213, expression_statement; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:row; 217, identifier:addWidget; 218, argument_list; 218, 219; 219, identifier:lbl; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 223; 222, identifier:opts; 223, call; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:lookup; 226, identifier:split; 227, argument_list; 227, 228; 228, string:':'; 229, if_statement; 229, 230; 229, 236; 230, comparison_operator:==; 230, 231; 230, 235; 231, call; 231, 232; 231, 233; 232, identifier:len; 233, argument_list; 233, 234; 234, identifier:opts; 235, integer:1; 236, block; 236, 237; 237, expression_statement; 237, 238; 238, call; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:opts; 241, identifier:append; 242, argument_list; 242, 243; 243, string:'is'; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 247; 246, identifier:column; 247, call; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:schema; 250, identifier:column; 251, argument_list; 251, 252; 252, subscript; 252, 253; 252, 254; 253, identifier:opts; 254, integer:0; 255, if_statement; 255, 256; 255, 258; 256, not_operator; 256, 257; 257, identifier:column; 258, block; 258, 259; 259, continue_statement; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 263; 262, identifier:plugin; 263, call; 263, 264; 263, 271; 264, attribute; 264, 265; 264, 270; 265, call; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:self; 268, identifier:pluginFactory; 269, argument_list; 270, identifier:plugin; 271, argument_list; 271, 272; 272, identifier:column; 273, if_statement; 273, 274; 273, 276; 274, not_operator; 274, 275; 275, identifier:plugin; 276, block; 276, 277; 277, continue_statement; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:editor; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:plugin; 284, identifier:createEditor; 285, argument_list; 285, 286; 285, 287; 285, 288; 285, 291; 286, identifier:self; 287, identifier:column; 288, subscript; 288, 289; 288, 290; 289, identifier:opts; 290, integer:1; 291, None; 292, if_statement; 292, 293; 292, 294; 293, identifier:editor; 294, block; 294, 295; 294, 304; 294, 311; 295, expression_statement; 295, 296; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:editor; 299, identifier:setObjectName; 300, argument_list; 300, 301; 301, subscript; 301, 302; 301, 303; 302, identifier:opts; 303, integer:0; 304, expression_statement; 304, 305; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:row; 308, identifier:addWidget; 309, argument_list; 309, 310; 310, identifier:editor; 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:self; 316, identifier:_plugins; 317, identifier:append; 318, argument_list; 318, 319; 319, tuple; 319, 320; 319, 323; 319, 326; 319, 327; 320, subscript; 320, 321; 320, 322; 321, identifier:opts; 322, integer:0; 323, subscript; 323, 324; 323, 325; 324, identifier:opts; 325, integer:1; 326, identifier:plugin; 327, identifier:editor; 328, expression_statement; 328, 329; 329, call; 329, 330; 329, 333; 330, attribute; 330, 331; 330, 332; 331, identifier:row; 332, identifier:addStretch; 333, argument_list; 333, 334; 334, integer:1; 335, expression_statement; 335, 336; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:vlayout; 339, identifier:addLayout; 340, argument_list; 340, 341; 341, identifier:row; 342, expression_statement; 342, 343; 343, call; 343, 344; 343, 347; 344, attribute; 344, 345; 344, 346; 345, identifier:self; 346, identifier:setUpdatesEnabled; 347, argument_list; 347, 348; 348, True; 349, expression_statement; 349, 350; 350, call; 350, 351; 350, 354; 351, attribute; 351, 352; 351, 353; 352, identifier:self; 353, identifier:adjustSize; 354, argument_list
def rebuild(self): table = self.tableType() form = nativestring(self.filterFormat()) if not table and form: if self.layout().count() == 0: self.layout().addWidget(QLabel(form, self)) else: self.layout().itemAt(0).widget().setText(form) return elif not form: return for child in self.findChildren(QWidget): child.close() child.setParent(None) child.deleteLater() self.setUpdatesEnabled(False) schema = table.schema() vlayout = self.layout() for i in range(vlayout.count()): vlayout.takeAt(0) self._plugins = [] for line in form.split('\n'): row = QHBoxLayout() row.setContentsMargins(0, 0, 0, 0) row.setSpacing(0) for label, lookup in FORMAT_SPLITTER.findall(line): lbl = QLabel(label, self) row.addWidget(lbl) opts = lookup.split(':') if len(opts) == 1: opts.append('is') column = schema.column(opts[0]) if not column: continue plugin = self.pluginFactory().plugin(column) if not plugin: continue editor = plugin.createEditor(self, column, opts[1], None) if editor: editor.setObjectName(opts[0]) row.addWidget(editor) self._plugins.append((opts[0], opts[1], plugin, editor)) row.addStretch(1) vlayout.addLayout(row) self.setUpdatesEnabled(True) self.adjustSize()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:filters; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:filter_directory; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:update; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:fmt; 12, string:'table'; 13, dictionary_splat_pattern; 13, 14; 14, identifier:kwargs; 15, block; 15, 16; 15, 29; 15, 41; 15, 45; 15, 68; 15, 272; 15, 276; 15, 307; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:is; 17, 18; 17, 19; 18, identifier:filter_directory; 19, None; 20, block; 20, 21; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:filter_directory; 24, call; 24, 25; 24, 26; 25, identifier:resource_filename; 26, argument_list; 26, 27; 26, 28; 27, string:'svo_filters'; 28, string:'data/filters/'; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:p_path; 32, call; 32, 33; 32, 38; 33, attribute; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:os; 36, identifier:path; 37, identifier:join; 38, argument_list; 38, 39; 38, 40; 39, identifier:filter_directory; 40, string:'filter_list.p'; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:updated; 44, False; 45, if_statement; 45, 46; 45, 55; 46, not_operator; 46, 47; 47, call; 47, 48; 47, 53; 48, attribute; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:os; 51, identifier:path; 52, identifier:isfile; 53, argument_list; 53, 54; 54, identifier:p_path; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:os; 60, identifier:system; 61, argument_list; 61, 62; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, string:'touch {}'; 65, identifier:format; 66, argument_list; 66, 67; 67, identifier:p_path; 68, if_statement; 68, 69; 68, 70; 69, identifier:update; 70, block; 70, 71; 70, 76; 70, 85; 70, 101; 70, 116; 70, 120; 70, 247; 71, expression_statement; 71, 72; 72, call; 72, 73; 72, 74; 73, identifier:print; 74, argument_list; 74, 75; 75, string:'Loading filters into table...'; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:files; 79, call; 79, 80; 79, 81; 80, identifier:glob; 81, argument_list; 81, 82; 82, binary_operator:+; 82, 83; 82, 84; 83, identifier:filter_directory; 84, string:'*'; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:files; 88, list_comprehension; 88, 89; 88, 90; 88, 93; 89, identifier:f; 90, for_in_clause; 90, 91; 90, 92; 91, identifier:f; 92, identifier:files; 93, if_clause; 93, 94; 94, not_operator; 94, 95; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:f; 98, identifier:endswith; 99, argument_list; 99, 100; 100, string:'.p'; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:bands; 104, list_comprehension; 104, 105; 104, 113; 105, call; 105, 106; 105, 111; 106, attribute; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:os; 109, identifier:path; 110, identifier:basename; 111, argument_list; 111, 112; 112, identifier:b; 113, for_in_clause; 113, 114; 113, 115; 114, identifier:b; 115, identifier:files; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:tables; 119, list:[]; 120, for_statement; 120, 121; 120, 122; 120, 123; 121, identifier:band; 122, identifier:bands; 123, block; 123, 124; 123, 134; 123, 143; 123, 149; 123, 158; 123, 196; 123, 212; 123, 235; 123, 242; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:band; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:band; 130, identifier:replace; 131, argument_list; 131, 132; 131, 133; 132, string:'.txt'; 133, string:''; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:filt; 137, call; 137, 138; 137, 139; 138, identifier:Filter; 139, argument_list; 139, 140; 139, 141; 140, identifier:band; 141, dictionary_splat; 141, 142; 142, identifier:kwargs; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:filt; 147, identifier:Band; 148, identifier:band; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:info; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:filt; 155, identifier:info; 156, argument_list; 156, 157; 157, True; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:vals; 161, list_comprehension; 161, 162; 161, 191; 162, conditional_expression:if; 162, 163; 162, 167; 162, 190; 163, call; 163, 164; 163, 165; 164, identifier:float; 165, argument_list; 165, 166; 166, identifier:i; 167, call; 167, 168; 167, 189; 168, attribute; 168, 169; 168, 188; 169, call; 169, 170; 169, 185; 170, attribute; 170, 171; 170, 184; 171, call; 171, 172; 171, 181; 172, attribute; 172, 173; 172, 180; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:i; 176, identifier:replace; 177, argument_list; 177, 178; 177, 179; 178, string:'.'; 179, string:''; 180, identifier:replace; 181, argument_list; 181, 182; 181, 183; 182, string:'-'; 183, string:''; 184, identifier:replace; 185, argument_list; 185, 186; 185, 187; 186, string:'+'; 187, string:''; 188, identifier:isnumeric; 189, argument_list; 190, identifier:i; 191, for_in_clause; 191, 192; 191, 193; 192, identifier:i; 193, subscript; 193, 194; 193, 195; 194, identifier:info; 195, string:'Values'; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 199; 198, identifier:dtypes; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:np; 202, identifier:array; 203, argument_list; 203, 204; 204, list_comprehension; 204, 205; 204, 209; 205, call; 205, 206; 205, 207; 206, identifier:type; 207, argument_list; 207, 208; 208, identifier:i; 209, for_in_clause; 209, 210; 209, 211; 210, identifier:i; 211, identifier:vals; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:table; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:at; 218, identifier:Table; 219, argument_list; 219, 220; 219, 227; 219, 232; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:np; 223, identifier:array; 224, argument_list; 224, 225; 225, list:[vals]; 225, 226; 226, identifier:vals; 227, keyword_argument; 227, 228; 227, 229; 228, identifier:names; 229, subscript; 229, 230; 229, 231; 230, identifier:info; 231, string:'Attributes'; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:dtype; 234, identifier:dtypes; 235, expression_statement; 235, 236; 236, call; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:tables; 239, identifier:append; 240, argument_list; 240, 241; 241, identifier:table; 242, delete_statement; 242, 243; 243, expression_list; 243, 244; 243, 245; 243, 246; 244, identifier:filt; 245, identifier:info; 246, identifier:table; 247, with_statement; 247, 248; 247, 258; 248, with_clause; 248, 249; 249, with_item; 249, 250; 250, as_pattern; 250, 251; 250, 256; 251, call; 251, 252; 251, 253; 252, identifier:open; 253, argument_list; 253, 254; 253, 255; 254, identifier:p_path; 255, string:'wb'; 256, as_pattern_target; 256, 257; 257, identifier:file; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:pickle; 263, identifier:dump; 264, argument_list; 264, 265; 264, 271; 265, call; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:at; 268, identifier:vstack; 269, argument_list; 269, 270; 270, identifier:tables; 271, identifier:file; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:data; 275, dictionary; 276, if_statement; 276, 277; 276, 285; 277, call; 277, 278; 277, 283; 278, attribute; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:os; 281, identifier:path; 282, identifier:isfile; 283, argument_list; 283, 284; 284, identifier:p_path; 285, block; 285, 286; 286, with_statement; 286, 287; 286, 297; 287, with_clause; 287, 288; 288, with_item; 288, 289; 289, as_pattern; 289, 290; 289, 295; 290, call; 290, 291; 290, 292; 291, identifier:open; 292, argument_list; 292, 293; 292, 294; 293, identifier:p_path; 294, string:'rb'; 295, as_pattern_target; 295, 296; 296, identifier:file; 297, block; 297, 298; 298, expression_statement; 298, 299; 299, assignment; 299, 300; 299, 301; 300, identifier:data; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:pickle; 304, identifier:load; 305, argument_list; 305, 306; 306, identifier:file; 307, if_statement; 307, 308; 307, 309; 307, 367; 308, identifier:data; 309, block; 309, 310; 309, 365; 310, if_statement; 310, 311; 310, 314; 310, 356; 311, comparison_operator:==; 311, 312; 311, 313; 312, identifier:fmt; 313, string:'dict'; 314, block; 314, 315; 315, expression_statement; 315, 316; 316, assignment; 316, 317; 316, 318; 317, identifier:data; 318, dictionary_comprehension; 318, 319; 318, 353; 319, pair; 319, 320; 319, 323; 320, subscript; 320, 321; 320, 322; 321, identifier:r; 322, integer:0; 323, dictionary_comprehension; 323, 324; 323, 342; 324, pair; 324, 325; 324, 326; 325, identifier:k; 326, conditional_expression:if; 326, 327; 326, 332; 326, 339; 327, attribute; 327, 328; 327, 331; 328, subscript; 328, 329; 328, 330; 329, identifier:r; 330, identifier:k; 331, identifier:value; 332, call; 332, 333; 332, 334; 333, identifier:hasattr; 334, argument_list; 334, 335; 334, 338; 335, subscript; 335, 336; 335, 337; 336, identifier:r; 337, identifier:k; 338, string:'unit'; 339, subscript; 339, 340; 339, 341; 340, identifier:r; 341, identifier:k; 342, for_in_clause; 342, 343; 342, 344; 343, identifier:k; 344, subscript; 344, 345; 344, 350; 345, call; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:data; 348, identifier:keys; 349, argument_list; 350, slice; 350, 351; 350, 352; 351, integer:1; 352, colon; 353, for_in_clause; 353, 354; 353, 355; 354, identifier:r; 355, identifier:data; 356, else_clause; 356, 357; 357, block; 357, 358; 358, expression_statement; 358, 359; 359, call; 359, 360; 359, 363; 360, attribute; 360, 361; 360, 362; 361, identifier:data; 362, identifier:add_index; 363, argument_list; 363, 364; 364, string:'Band'; 365, return_statement; 365, 366; 366, identifier:data; 367, else_clause; 367, 368; 368, block; 368, 369; 369, if_statement; 369, 370; 369, 372; 369, 384; 370, not_operator; 370, 371; 371, identifier:updated; 372, block; 372, 373; 372, 377; 373, expression_statement; 373, 374; 374, assignment; 374, 375; 374, 376; 375, identifier:updated; 376, True; 377, expression_statement; 377, 378; 378, call; 378, 379; 378, 380; 379, identifier:filters; 380, argument_list; 380, 381; 381, keyword_argument; 381, 382; 381, 383; 382, identifier:update; 383, True; 384, else_clause; 384, 385; 385, block; 385, 386; 386, expression_statement; 386, 387; 387, call; 387, 388; 387, 389; 388, identifier:print; 389, argument_list; 389, 390; 389, 391; 390, string:'No filters found in'; 391, identifier:filter_directory
def filters(filter_directory=None, update=False, fmt='table', **kwargs): if filter_directory is None: filter_directory = resource_filename('svo_filters', 'data/filters/') p_path = os.path.join(filter_directory, 'filter_list.p') updated = False if not os.path.isfile(p_path): os.system('touch {}'.format(p_path)) if update: print('Loading filters into table...') files = glob(filter_directory+'*') files = [f for f in files if not f.endswith('.p')] bands = [os.path.basename(b) for b in files] tables = [] for band in bands: band = band.replace('.txt', '') filt = Filter(band, **kwargs) filt.Band = band info = filt.info(True) vals = [float(i) if i.replace('.', '').replace('-', '') .replace('+', '').isnumeric() else i for i in info['Values']] dtypes = np.array([type(i) for i in vals]) table = at.Table(np.array([vals]), names=info['Attributes'], dtype=dtypes) tables.append(table) del filt, info, table with open(p_path, 'wb') as file: pickle.dump(at.vstack(tables), file) data = {} if os.path.isfile(p_path): with open(p_path, 'rb') as file: data = pickle.load(file) if data: if fmt == 'dict': data = {r[0]: {k: r[k].value if hasattr(r[k], 'unit') else r[k] for k in data.keys()[1:]} for r in data} else: data.add_index('Band') return data else: if not updated: updated = True filters(update=True) else: print('No filters found in', filter_directory)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:parse_unit; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:prop; 5, identifier:dictionary; 6, default_parameter; 6, 7; 6, 8; 7, identifier:dt; 8, None; 9, block; 9, 10; 9, 12; 9, 35; 9, 51; 9, 78; 9, 123; 9, 134; 10, expression_statement; 10, 11; 11, string:'''Do a fuzzy match for `prop` in the dictionary, taking into account unit suffix.'''; 12, try_statement; 12, 13; 12, 28; 13, block; 13, 14; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:dt; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:timezone; 20, identifier:parse_datetime; 21, argument_list; 21, 22; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:dictionary; 25, identifier:get; 26, argument_list; 26, 27; 27, string:'date_time'; 28, except_clause; 28, 29; 28, 30; 29, identifier:TypeError; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:dt; 34, None; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:matches; 38, list_comprehension; 38, 39; 38, 40; 38, 47; 39, identifier:k; 40, for_in_clause; 40, 41; 40, 42; 41, identifier:k; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:dictionary; 45, identifier:keys; 46, argument_list; 47, if_clause; 47, 48; 48, comparison_operator:in; 48, 49; 48, 50; 49, identifier:prop; 50, identifier:k; 51, try_statement; 51, 52; 51, 73; 52, block; 52, 53; 52, 61; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:value; 56, subscript; 56, 57; 56, 58; 57, identifier:dictionary; 58, subscript; 58, 59; 58, 60; 59, identifier:matches; 60, integer:0; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:unit; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:re; 67, identifier:search; 68, argument_list; 68, 69; 68, 70; 69, string:r' \(([^)]+)\)'; 70, subscript; 70, 71; 70, 72; 71, identifier:matches; 72, integer:0; 73, except_clause; 73, 74; 73, 75; 74, identifier:IndexError; 75, block; 75, 76; 76, return_statement; 76, 77; 77, None; 78, if_statement; 78, 79; 78, 82; 79, comparison_operator:in; 79, 80; 79, 81; 80, string:';'; 81, identifier:value; 82, block; 82, 83; 82, 100; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:values; 86, list_comprehension; 86, 87; 86, 88; 86, 96; 87, identifier:val; 88, for_in_clause; 88, 89; 88, 90; 89, identifier:val; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:value; 93, identifier:split; 94, argument_list; 94, 95; 95, string:';'; 96, if_clause; 96, 97; 97, comparison_operator:!=; 97, 98; 97, 99; 98, identifier:val; 99, string:''; 100, if_statement; 100, 101; 100, 102; 100, 119; 101, identifier:unit; 102, block; 102, 103; 103, return_statement; 103, 104; 104, list_comprehension; 104, 105; 104, 116; 105, call; 105, 106; 105, 107; 106, identifier:Observation; 107, argument_list; 107, 108; 107, 109; 107, 115; 108, identifier:v; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:unit; 112, identifier:group; 113, argument_list; 113, 114; 114, integer:1; 115, identifier:dt; 116, for_in_clause; 116, 117; 116, 118; 117, identifier:v; 118, identifier:values; 119, else_clause; 119, 120; 120, block; 120, 121; 121, return_statement; 121, 122; 122, identifier:values; 123, if_statement; 123, 124; 123, 129; 124, boolean_operator:or; 124, 125; 124, 127; 125, not_operator; 125, 126; 126, identifier:value; 127, not_operator; 127, 128; 128, identifier:unit; 129, block; 129, 130; 130, return_statement; 130, 131; 131, boolean_operator:or; 131, 132; 131, 133; 132, identifier:value; 133, None; 134, return_statement; 134, 135; 135, call; 135, 136; 135, 137; 136, identifier:Observation; 137, argument_list; 137, 138; 137, 139; 137, 145; 138, identifier:value; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:unit; 142, identifier:group; 143, argument_list; 143, 144; 144, integer:1; 145, identifier:dt
def parse_unit(prop, dictionary, dt=None): '''Do a fuzzy match for `prop` in the dictionary, taking into account unit suffix.''' try: dt = timezone.parse_datetime(dictionary.get('date_time')) except TypeError: dt = None matches = [k for k in dictionary.keys() if prop in k] try: value = dictionary[matches[0]] unit = re.search(r' \(([^)]+)\)', matches[0]) except IndexError: return None if ';' in value: values = [val for val in value.split(';') if val != ''] if unit: return [Observation(v, unit.group(1), dt) for v in values] else: return values if not value or not unit: return value or None return Observation(value, unit.group(1), dt)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:rebuild; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 20; 5, 42; 5, 50; 5, 313; 5, 320; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:setUpdatesEnabled; 11, argument_list; 11, 12; 12, False; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:blockSignals; 18, argument_list; 18, 19; 19, True; 20, for_statement; 20, 21; 20, 22; 20, 28; 21, identifier:child; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:findChildren; 26, argument_list; 26, 27; 27, identifier:QObject; 28, block; 28, 29; 28, 36; 29, expression_statement; 29, 30; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:child; 33, identifier:setParent; 34, argument_list; 34, 35; 35, None; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:child; 40, identifier:deleteLater; 41, argument_list; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:schema; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:schema; 49, argument_list; 50, if_statement; 50, 51; 50, 53; 50, 304; 51, parenthesized_expression; 51, 52; 52, identifier:schema; 53, block; 53, 54; 53, 61; 53, 69; 54, expression_statement; 54, 55; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:setEnabled; 59, argument_list; 59, 60; 60, True; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:uifile; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:uiFile; 68, argument_list; 69, if_statement; 69, 70; 69, 72; 69, 137; 70, parenthesized_expression; 70, 71; 71, identifier:uifile; 72, block; 72, 73; 72, 82; 73, expression_statement; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:projexui; 77, identifier:loadUi; 78, argument_list; 78, 79; 78, 80; 78, 81; 79, string:''; 80, identifier:self; 81, identifier:uifile; 82, for_statement; 82, 83; 82, 84; 82, 90; 83, identifier:widget; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:findChildren; 88, argument_list; 88, 89; 89, identifier:XOrbColumnEdit; 90, block; 90, 91; 90, 99; 90, 108; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:columnName; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:widget; 97, identifier:columnName; 98, argument_list; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:column; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:schema; 105, identifier:column; 106, argument_list; 106, 107; 107, identifier:columnName; 108, if_statement; 108, 109; 108, 111; 108, 119; 109, parenthesized_expression; 109, 110; 110, identifier:column; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:widget; 116, identifier:setColumn; 117, argument_list; 117, 118; 118, identifier:column; 119, else_clause; 119, 120; 120, block; 120, 121; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:logger; 125, identifier:debug; 126, argument_list; 126, 127; 127, binary_operator:%; 127, 128; 127, 129; 127, 130; 128, string:'%s is not a valid column of %s'; 129, line_continuation:\; 130, tuple; 130, 131; 130, 132; 131, identifier:columnName; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:schema; 135, identifier:name; 136, argument_list; 137, else_clause; 137, 138; 138, block; 138, 139; 138, 145; 138, 155; 138, 163; 138, 179; 138, 187; 138, 278; 138, 285; 138, 291; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:layout; 142, call; 142, 143; 142, 144; 143, identifier:QFormLayout; 144, argument_list; 145, expression_statement; 145, 146; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:layout; 149, identifier:setContentsMargins; 150, argument_list; 150, 151; 150, 152; 150, 153; 150, 154; 151, integer:0; 152, integer:0; 153, integer:0; 154, integer:0; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:columns; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:schema; 161, identifier:columns; 162, argument_list; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:columns; 167, identifier:sort; 168, argument_list; 168, 169; 169, keyword_argument; 169, 170; 169, 171; 170, identifier:key; 171, lambda; 171, 172; 171, 174; 172, lambda_parameters; 172, 173; 173, identifier:x; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:x; 177, identifier:displayName; 178, argument_list; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:record; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:self; 185, identifier:record; 186, argument_list; 187, for_statement; 187, 188; 187, 189; 187, 190; 188, identifier:column; 189, identifier:columns; 190, block; 190, 191; 190, 205; 190, 213; 190, 221; 190, 229; 190, 236; 190, 245; 190, 252; 190, 259; 190, 266; 191, if_statement; 191, 192; 191, 203; 192, parenthesized_expression; 192, 193; 193, call; 193, 194; 193, 201; 194, attribute; 194, 195; 194, 200; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:column; 198, identifier:name; 199, argument_list; 200, identifier:startswith; 201, argument_list; 201, 202; 202, string:'_'; 203, block; 203, 204; 204, continue_statement; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:label; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:column; 211, identifier:displayName; 212, argument_list; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 216; 215, identifier:coltype; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:column; 219, identifier:columnType; 220, argument_list; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:name; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:column; 227, identifier:name; 228, argument_list; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 232; 231, identifier:widget; 232, call; 232, 233; 232, 234; 233, identifier:XOrbColumnEdit; 234, argument_list; 234, 235; 235, identifier:self; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:widget; 240, identifier:setObjectName; 241, argument_list; 241, 242; 242, binary_operator:+; 242, 243; 242, 244; 243, string:'ui_'; 244, identifier:name; 245, expression_statement; 245, 246; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:widget; 249, identifier:setColumnName; 250, argument_list; 250, 251; 251, identifier:name; 252, expression_statement; 252, 253; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:widget; 256, identifier:setColumnType; 257, argument_list; 257, 258; 258, identifier:coltype; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:widget; 263, identifier:setColumn; 264, argument_list; 264, 265; 265, identifier:column; 266, expression_statement; 266, 267; 267, call; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:layout; 270, identifier:addRow; 271, argument_list; 271, 272; 271, 277; 272, call; 272, 273; 272, 274; 273, identifier:QLabel; 274, argument_list; 274, 275; 274, 276; 275, identifier:label; 276, identifier:self; 277, identifier:widget; 278, expression_statement; 278, 279; 279, call; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:self; 282, identifier:setLayout; 283, argument_list; 283, 284; 284, identifier:layout; 285, expression_statement; 285, 286; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:self; 289, identifier:adjustSize; 290, argument_list; 291, expression_statement; 291, 292; 292, call; 292, 293; 292, 296; 293, attribute; 293, 294; 293, 295; 294, identifier:self; 295, identifier:setWindowTitle; 296, argument_list; 296, 297; 297, binary_operator:%; 297, 298; 297, 299; 298, string:'Edit %s'; 299, call; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:schema; 302, identifier:name; 303, argument_list; 304, else_clause; 304, 305; 305, block; 305, 306; 306, expression_statement; 306, 307; 307, call; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:self; 310, identifier:setEnabled; 311, argument_list; 311, 312; 312, False; 313, expression_statement; 313, 314; 314, call; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:self; 317, identifier:setUpdatesEnabled; 318, argument_list; 318, 319; 319, True; 320, expression_statement; 320, 321; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:self; 324, identifier:blockSignals; 325, argument_list; 325, 326; 326, False
def rebuild( self ): self.setUpdatesEnabled(False) self.blockSignals(True) for child in self.findChildren(QObject): child.setParent(None) child.deleteLater() schema = self.schema() if ( schema ): self.setEnabled(True) uifile = self.uiFile() if ( uifile ): projexui.loadUi('', self, uifile) for widget in self.findChildren(XOrbColumnEdit): columnName = widget.columnName() column = schema.column(columnName) if ( column ): widget.setColumn(column) else: logger.debug('%s is not a valid column of %s' % \ (columnName, schema.name())) else: layout = QFormLayout() layout.setContentsMargins(0, 0, 0, 0) columns = schema.columns() columns.sort(key = lambda x: x.displayName()) record = self.record() for column in columns: if ( column.name().startswith('_') ): continue label = column.displayName() coltype = column.columnType() name = column.name() widget = XOrbColumnEdit(self) widget.setObjectName('ui_' + name) widget.setColumnName(name) widget.setColumnType(coltype) widget.setColumn(column) layout.addRow(QLabel(label, self), widget) self.setLayout(layout) self.adjustSize() self.setWindowTitle('Edit %s' % schema.name()) else: self.setEnabled(False) self.setUpdatesEnabled(True) self.blockSignals(False)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:save; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 28; 5, 36; 5, 48; 5, 52; 5, 61; 5, 249; 5, 267; 5, 273; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:schema; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:schema; 13, argument_list; 14, if_statement; 14, 15; 14, 18; 15, parenthesized_expression; 15, 16; 16, not_operator; 16, 17; 17, identifier:schema; 18, block; 18, 19; 18, 27; 19, expression_statement; 19, 20; 20, call; 20, 21; 20, 26; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:saved; 25, identifier:emit; 26, argument_list; 27, return_statement; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:record; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:record; 35, argument_list; 36, if_statement; 36, 37; 36, 39; 37, not_operator; 37, 38; 38, identifier:record; 39, block; 39, 40; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:record; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:_model; 47, argument_list; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:save_data; 51, list:[]; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:column_edits; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:findChildren; 59, argument_list; 59, 60; 60, identifier:XOrbColumnEdit; 61, for_statement; 61, 62; 61, 63; 61, 64; 62, identifier:widget; 63, identifier:column_edits; 64, block; 64, 65; 64, 73; 64, 82; 64, 104; 64, 112; 64, 119; 64, 240; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:columnName; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:widget; 71, identifier:columnName; 72, argument_list; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:column; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:schema; 79, identifier:column; 80, argument_list; 80, 81; 81, identifier:columnName; 82, if_statement; 82, 83; 82, 86; 83, parenthesized_expression; 83, 84; 84, not_operator; 84, 85; 85, identifier:column; 86, block; 86, 87; 86, 103; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:logger; 91, identifier:warning; 92, argument_list; 92, 93; 93, binary_operator:%; 93, 94; 93, 95; 93, 96; 94, string:'%s is not a valid column of %s.'; 95, line_continuation:\; 96, tuple; 96, 97; 96, 98; 97, identifier:columnName; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:schema; 101, identifier:name; 102, argument_list; 103, continue_statement; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:value; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:widget; 110, identifier:value; 111, argument_list; 112, if_statement; 112, 113; 112, 117; 113, parenthesized_expression; 113, 114; 114, comparison_operator:==; 114, 115; 114, 116; 115, identifier:value; 116, identifier:IGNORED; 117, block; 117, 118; 118, continue_statement; 119, if_statement; 119, 120; 119, 129; 119, 150; 120, parenthesized_expression; 120, 121; 121, boolean_operator:and; 121, 122; 121, 127; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:column; 125, identifier:required; 126, argument_list; 127, not_operator; 127, 128; 128, identifier:value; 129, block; 129, 130; 129, 138; 129, 149; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:name; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:column; 136, identifier:displayName; 137, argument_list; 138, expression_statement; 138, 139; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:QMessageBox; 142, identifier:information; 143, argument_list; 143, 144; 143, 145; 143, 146; 144, identifier:self; 145, string:'Missing Required Field'; 146, binary_operator:%; 146, 147; 146, 148; 147, string:'%s is a required field.'; 148, identifier:name; 149, return_statement; 150, elif_clause; 150, 151; 150, 157; 151, parenthesized_expression; 151, 152; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:column; 155, identifier:unique; 156, argument_list; 157, block; 157, 158; 157, 171; 157, 190; 157, 204; 157, 220; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:query; 161, comparison_operator:==; 161, 162; 161, 170; 162, call; 162, 163; 162, 164; 163, identifier:Q; 164, argument_list; 164, 165; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:column; 168, identifier:name; 169, argument_list; 170, identifier:value; 171, if_statement; 171, 172; 171, 178; 172, parenthesized_expression; 172, 173; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:record; 176, identifier:isRecord; 177, argument_list; 178, block; 178, 179; 179, expression_statement; 179, 180; 180, augmented_assignment:&=; 180, 181; 180, 182; 181, identifier:query; 182, comparison_operator:!=; 182, 183; 182, 189; 183, call; 183, 184; 183, 185; 184, identifier:Q; 185, argument_list; 185, 186; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:_model; 189, identifier:record; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:columns; 193, call; 193, 194; 193, 203; 194, attribute; 194, 195; 194, 202; 195, call; 195, 196; 195, 201; 196, attribute; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:self; 199, identifier:_model; 200, identifier:schema; 201, argument_list; 202, identifier:primaryColumns; 203, argument_list; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 207; 206, identifier:result; 207, call; 207, 208; 207, 213; 208, attribute; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:self; 211, identifier:_model; 212, identifier:select; 213, argument_list; 213, 214; 213, 217; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:columns; 216, identifier:columns; 217, keyword_argument; 217, 218; 217, 219; 218, identifier:where; 219, identifier:query; 220, if_statement; 220, 221; 220, 227; 221, parenthesized_expression; 221, 222; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:result; 225, identifier:total; 226, argument_list; 227, block; 227, 228; 227, 239; 228, expression_statement; 228, 229; 229, call; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:QMessageBox; 232, identifier:information; 233, argument_list; 233, 234; 233, 235; 233, 236; 234, identifier:self; 235, string:'Duplicate Entry'; 236, binary_operator:%; 236, 237; 236, 238; 237, string:'%s already exists.'; 238, identifier:value; 239, return_statement; 240, expression_statement; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:save_data; 244, identifier:append; 245, argument_list; 245, 246; 246, tuple; 246, 247; 246, 248; 247, identifier:column; 248, identifier:value; 249, for_statement; 249, 250; 249, 253; 249, 254; 250, pattern_list; 250, 251; 250, 252; 251, identifier:column; 252, identifier:value; 253, identifier:save_data; 254, block; 254, 255; 255, expression_statement; 255, 256; 256, call; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:record; 259, identifier:setRecordValue; 260, argument_list; 260, 261; 260, 266; 261, call; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:column; 264, identifier:name; 265, argument_list; 266, identifier:value; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:self; 271, identifier:_record; 272, identifier:record; 273, expression_statement; 273, 274; 274, call; 274, 275; 274, 280; 275, attribute; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:self; 278, identifier:saved; 279, identifier:emit; 280, argument_list
def save( self ): schema = self.schema() if ( not schema ): self.saved.emit() return record = self.record() if not record: record = self._model() save_data = [] column_edits = self.findChildren(XOrbColumnEdit) for widget in column_edits: columnName = widget.columnName() column = schema.column(columnName) if ( not column ): logger.warning('%s is not a valid column of %s.' % \ (columnName, schema.name())) continue value = widget.value() if ( value == IGNORED ): continue if ( column.required() and not value ): name = column.displayName() QMessageBox.information(self, 'Missing Required Field', '%s is a required field.' % name) return elif ( column.unique() ): query = Q(column.name()) == value if ( record.isRecord() ): query &= Q(self._model) != record columns = self._model.schema().primaryColumns() result = self._model.select(columns = columns, where = query) if ( result.total() ): QMessageBox.information(self, 'Duplicate Entry', '%s already exists.' % value) return save_data.append((column, value)) for column, value in save_data: record.setRecordValue(column.name(), value) self._record = record self.saved.emit()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:register; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:service; 6, block; 6, 7; 6, 22; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:response; 10, await; 10, 11; 11, call; 11, 12; 11, 17; 12, attribute; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:_api; 16, identifier:put; 17, argument_list; 17, 18; 17, 19; 18, string:"/v1/agent/service/register"; 19, keyword_argument; 19, 20; 19, 21; 20, identifier:data; 21, identifier:service; 22, return_statement; 22, 23; 23, comparison_operator:==; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:response; 26, identifier:status; 27, integer:200
async def register(self, service): response = await self._api.put("/v1/agent/service/register", data=service) return response.status == 200
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:save; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 29; 5, 54; 5, 62; 5, 70; 5, 110; 5, 214; 5, 225; 5, 241; 5, 249; 5, 259; 5, 274; 5, 306; 5, 346; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:record; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:record; 13, argument_list; 14, if_statement; 14, 15; 14, 17; 15, not_operator; 15, 16; 16, identifier:record; 17, block; 17, 18; 17, 27; 18, expression_statement; 18, 19; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:logger; 22, identifier:warning; 23, argument_list; 23, 24; 24, binary_operator:%; 24, 25; 24, 26; 25, string:'No record has been defined for %s.'; 26, identifier:self; 27, return_statement; 27, 28; 28, False; 29, if_statement; 29, 30; 29, 36; 30, not_operator; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:signalsBlocked; 35, argument_list; 36, block; 36, 37; 36, 46; 37, expression_statement; 37, 38; 38, call; 38, 39; 38, 44; 39, attribute; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:aboutToSaveRecord; 43, identifier:emit; 44, argument_list; 44, 45; 45, identifier:record; 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:aboutToSave; 52, identifier:emit; 53, argument_list; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:values; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:saveValues; 61, argument_list; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:check; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:values; 68, identifier:copy; 69, argument_list; 70, for_statement; 70, 71; 70, 74; 70, 79; 71, pattern_list; 71, 72; 71, 73; 72, identifier:column_name; 73, identifier:value; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:check; 77, identifier:items; 78, argument_list; 79, block; 79, 80; 79, 100; 80, try_statement; 80, 81; 80, 93; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:equals; 85, comparison_operator:==; 85, 86; 85, 87; 86, identifier:value; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:record; 90, identifier:recordValue; 91, argument_list; 91, 92; 92, identifier:column_name; 93, except_clause; 93, 94; 93, 95; 94, identifier:UnicodeWarning; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:equals; 99, False; 100, if_statement; 100, 101; 100, 102; 101, identifier:equals; 102, block; 102, 103; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:check; 107, identifier:pop; 108, argument_list; 108, 109; 109, identifier:column_name; 110, if_statement; 110, 111; 110, 119; 111, boolean_operator:and; 111, 112; 111, 114; 112, not_operator; 112, 113; 113, identifier:check; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:record; 117, identifier:isRecord; 118, argument_list; 119, block; 119, 120; 119, 159; 119, 212; 120, if_statement; 120, 121; 120, 127; 120, 151; 121, not_operator; 121, 122; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:self; 125, identifier:signalsBlocked; 126, argument_list; 127, block; 127, 128; 127, 137; 127, 145; 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:recordSaved; 134, identifier:emit; 135, argument_list; 135, 136; 136, identifier:record; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 144; 139, attribute; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:saved; 143, identifier:emit; 144, argument_list; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:self; 149, identifier:_saveSignalBlocked; 150, False; 151, else_clause; 151, 152; 152, block; 152, 153; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:self; 157, identifier:_saveSignalBlocked; 158, True; 159, if_statement; 159, 160; 159, 165; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:autoCommitOnSave; 164, argument_list; 165, block; 165, 166; 165, 176; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 171; 168, pattern_list; 168, 169; 168, 170; 169, identifier:status; 170, identifier:result; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:record; 174, identifier:commit; 175, argument_list; 176, if_statement; 176, 177; 176, 180; 177, comparison_operator:==; 177, 178; 177, 179; 178, identifier:status; 179, string:'errored'; 180, block; 180, 181; 180, 201; 180, 210; 181, if_statement; 181, 182; 181, 185; 181, 195; 182, comparison_operator:in; 182, 183; 182, 184; 183, string:'db_error'; 184, identifier:result; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:msg; 189, call; 189, 190; 189, 191; 190, identifier:nativestring; 191, argument_list; 191, 192; 192, subscript; 192, 193; 192, 194; 193, identifier:result; 194, string:'db_error'; 195, else_clause; 195, 196; 196, block; 196, 197; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:msg; 200, string:'An unknown database error has occurred.'; 201, expression_statement; 201, 202; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:QMessageBox; 205, identifier:information; 206, argument_list; 206, 207; 206, 208; 206, 209; 207, identifier:self; 208, string:'Commit Error'; 209, identifier:msg; 210, return_statement; 210, 211; 211, False; 212, return_statement; 212, 213; 213, True; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 219; 216, pattern_list; 216, 217; 216, 218; 217, identifier:success; 218, identifier:msg; 219, call; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:record; 222, identifier:validateValues; 223, argument_list; 223, 224; 224, identifier:check; 225, if_statement; 225, 226; 225, 229; 226, parenthesized_expression; 226, 227; 227, not_operator; 227, 228; 228, identifier:success; 229, block; 229, 230; 229, 239; 230, expression_statement; 230, 231; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:QMessageBox; 234, identifier:information; 235, argument_list; 235, 236; 235, 237; 235, 238; 236, None; 237, string:'Could Not Save'; 238, identifier:msg; 239, return_statement; 239, 240; 240, False; 241, expression_statement; 241, 242; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:record; 245, identifier:setRecordValues; 246, argument_list; 246, 247; 247, dictionary_splat; 247, 248; 248, identifier:values; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 254; 251, pattern_list; 251, 252; 251, 253; 252, identifier:success; 253, identifier:msg; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:record; 257, identifier:validateRecord; 258, argument_list; 259, if_statement; 259, 260; 259, 262; 260, not_operator; 260, 261; 261, identifier:success; 262, block; 262, 263; 262, 272; 263, expression_statement; 263, 264; 264, call; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:QMessageBox; 267, identifier:information; 268, argument_list; 268, 269; 268, 270; 268, 271; 269, None; 270, string:'Could Not Save'; 271, identifier:msg; 272, return_statement; 272, 273; 273, False; 274, if_statement; 274, 275; 274, 281; 275, parenthesized_expression; 275, 276; 276, call; 276, 277; 276, 280; 277, attribute; 277, 278; 277, 279; 278, identifier:self; 279, identifier:autoCommitOnSave; 280, argument_list; 281, block; 281, 282; 281, 290; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:result; 285, call; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, identifier:record; 288, identifier:commit; 289, argument_list; 290, if_statement; 290, 291; 290, 294; 291, comparison_operator:in; 291, 292; 291, 293; 292, string:'errored'; 293, identifier:result; 294, block; 294, 295; 294, 304; 295, expression_statement; 295, 296; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:QMessageBox; 299, identifier:information; 300, argument_list; 300, 301; 300, 302; 300, 303; 301, None; 302, string:'Could Not Save'; 303, identifier:msg; 304, return_statement; 304, 305; 305, False; 306, if_statement; 306, 307; 306, 314; 306, 338; 307, parenthesized_expression; 307, 308; 308, not_operator; 308, 309; 309, call; 309, 310; 309, 313; 310, attribute; 310, 311; 310, 312; 311, identifier:self; 312, identifier:signalsBlocked; 313, argument_list; 314, block; 314, 315; 314, 324; 314, 332; 315, expression_statement; 315, 316; 316, call; 316, 317; 316, 322; 317, attribute; 317, 318; 317, 321; 318, attribute; 318, 319; 318, 320; 319, identifier:self; 320, identifier:recordSaved; 321, identifier:emit; 322, argument_list; 322, 323; 323, identifier:record; 324, expression_statement; 324, 325; 325, call; 325, 326; 325, 331; 326, attribute; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:self; 329, identifier:saved; 330, identifier:emit; 331, argument_list; 332, expression_statement; 332, 333; 333, assignment; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:self; 336, identifier:_saveSignalBlocked; 337, False; 338, else_clause; 338, 339; 339, block; 339, 340; 340, expression_statement; 340, 341; 341, assignment; 341, 342; 341, 345; 342, attribute; 342, 343; 342, 344; 343, identifier:self; 344, identifier:_saveSignalBlocked; 345, True; 346, return_statement; 346, 347; 347, True
def save(self): record = self.record() if not record: logger.warning('No record has been defined for %s.' % self) return False if not self.signalsBlocked(): self.aboutToSaveRecord.emit(record) self.aboutToSave.emit() values = self.saveValues() check = values.copy() for column_name, value in check.items(): try: equals = value == record.recordValue(column_name) except UnicodeWarning: equals = False if equals: check.pop(column_name) if not check and record.isRecord(): if not self.signalsBlocked(): self.recordSaved.emit(record) self.saved.emit() self._saveSignalBlocked = False else: self._saveSignalBlocked = True if self.autoCommitOnSave(): status, result = record.commit() if status == 'errored': if 'db_error' in result: msg = nativestring(result['db_error']) else: msg = 'An unknown database error has occurred.' QMessageBox.information(self, 'Commit Error', msg) return False return True success, msg = record.validateValues(check) if ( not success ): QMessageBox.information(None, 'Could Not Save', msg) return False record.setRecordValues(**values) success, msg = record.validateRecord() if not success: QMessageBox.information(None, 'Could Not Save', msg) return False if ( self.autoCommitOnSave() ): result = record.commit() if 'errored' in result: QMessageBox.information(None, 'Could Not Save', msg) return False if ( not self.signalsBlocked() ): self.recordSaved.emit(record) self.saved.emit() self._saveSignalBlocked = False else: self._saveSignalBlocked = True return True
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 5, 30; 5, 39; 5, 72; 5, 143; 5, 161; 5, 281; 5, 290; 5, 325; 5, 329; 5, 339; 5, 349; 5, 359; 5, 369; 5, 389; 5, 397; 5, 404; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:pixmap; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:property; 13, argument_list; 13, 14; 14, string:'pixmap'; 15, if_statement; 15, 16; 15, 19; 16, comparison_operator:is; 16, 17; 16, 18; 17, identifier:pixmap; 18, None; 19, block; 19, 20; 20, return_statement; 20, 21; 21, call; 21, 22; 21, 29; 22, attribute; 22, 23; 22, 28; 23, call; 23, 24; 23, 25; 24, identifier:super; 25, argument_list; 25, 26; 25, 27; 26, identifier:XWalkthroughSnapshot; 27, identifier:self; 28, identifier:prepare; 29, argument_list; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:widget; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:property; 37, argument_list; 37, 38; 38, string:'widget'; 39, if_statement; 39, 40; 39, 48; 40, comparison_operator:in; 40, 41; 40, 45; 41, call; 41, 42; 41, 43; 42, identifier:type; 43, argument_list; 43, 44; 44, identifier:widget; 45, tuple; 45, 46; 45, 47; 46, identifier:unicode; 47, identifier:str; 48, block; 48, 49; 48, 58; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:widget; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:findReference; 56, argument_list; 56, 57; 57, identifier:widget; 58, if_statement; 58, 59; 58, 61; 59, not_operator; 59, 60; 60, identifier:widget; 61, block; 61, 62; 62, return_statement; 62, 63; 63, call; 63, 64; 63, 71; 64, attribute; 64, 65; 64, 70; 65, call; 65, 66; 65, 67; 66, identifier:super; 67, argument_list; 67, 68; 67, 69; 68, identifier:XWalkthroughSnapshot; 69, identifier:self; 70, identifier:prepare; 71, argument_list; 72, if_statement; 72, 73; 72, 85; 73, boolean_operator:and; 73, 74; 73, 80; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:property; 78, argument_list; 78, 79; 79, string:'overlay'; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:widget; 83, identifier:parent; 84, argument_list; 85, block; 85, 86; 85, 94; 85, 135; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:ref; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:referenceWidget; 93, argument_list; 94, if_statement; 94, 95; 94, 98; 94, 109; 95, comparison_operator:==; 95, 96; 95, 97; 96, identifier:ref; 97, identifier:widget; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:pos; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:QtCore; 105, identifier:QPoint; 106, argument_list; 106, 107; 106, 108; 107, integer:0; 108, integer:0; 109, else_clause; 109, 110; 110, block; 110, 111; 110, 126; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:glbl_pos; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:widget; 117, identifier:mapToGlobal; 118, argument_list; 118, 119; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:QtCore; 122, identifier:QPoint; 123, argument_list; 123, 124; 123, 125; 124, integer:0; 125, integer:0; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:pos; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:ref; 132, identifier:mapFromGlobal; 133, argument_list; 133, 134; 134, identifier:glbl_pos; 135, expression_statement; 135, 136; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:setProperty; 140, argument_list; 140, 141; 140, 142; 141, string:'pos'; 142, identifier:pos; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 146; 145, identifier:crop; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:self; 149, identifier:property; 150, argument_list; 150, 151; 150, 152; 151, string:'crop'; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:QtCore; 155, identifier:QRect; 156, argument_list; 156, 157; 156, 158; 156, 159; 156, 160; 157, integer:0; 158, integer:0; 159, integer:0; 160, integer:0; 161, if_statement; 161, 162; 161, 163; 161, 268; 162, identifier:crop; 163, block; 163, 164; 163, 172; 163, 190; 163, 208; 163, 232; 163, 256; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:rect; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:widget; 170, identifier:rect; 171, argument_list; 172, if_statement; 172, 173; 172, 178; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:crop; 176, identifier:width; 177, argument_list; 178, block; 178, 179; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:rect; 183, identifier:setWidth; 184, argument_list; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:crop; 188, identifier:width; 189, argument_list; 190, if_statement; 190, 191; 190, 196; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:crop; 194, identifier:height; 195, argument_list; 196, block; 196, 197; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:rect; 201, identifier:setHeight; 202, argument_list; 202, 203; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:crop; 206, identifier:height; 207, argument_list; 208, if_statement; 208, 209; 208, 214; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:crop; 212, identifier:x; 213, argument_list; 214, block; 214, 215; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:rect; 219, identifier:setX; 220, argument_list; 220, 221; 221, binary_operator:-; 221, 222; 221, 227; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:rect; 225, identifier:width; 226, argument_list; 227, call; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:crop; 230, identifier:x; 231, argument_list; 232, if_statement; 232, 233; 232, 238; 233, call; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:crop; 236, identifier:y; 237, argument_list; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:rect; 243, identifier:setY; 244, argument_list; 244, 245; 245, binary_operator:-; 245, 246; 245, 251; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:rect; 249, identifier:height; 250, argument_list; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:crop; 254, identifier:y; 255, argument_list; 256, expression_statement; 256, 257; 257, assignment; 257, 258; 257, 259; 258, identifier:pixmap; 259, call; 259, 260; 259, 265; 260, attribute; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:QtGui; 263, identifier:QPixmap; 264, identifier:grabWidget; 265, argument_list; 265, 266; 265, 267; 266, identifier:widget; 267, identifier:rect; 268, else_clause; 268, 269; 269, block; 269, 270; 270, expression_statement; 270, 271; 271, assignment; 271, 272; 271, 273; 272, identifier:pixmap; 273, call; 273, 274; 273, 279; 274, attribute; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:QtGui; 277, identifier:QPixmap; 278, identifier:grabWidget; 279, argument_list; 279, 280; 280, identifier:widget; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 284; 283, identifier:scaled; 284, call; 284, 285; 284, 288; 285, attribute; 285, 286; 285, 287; 286, identifier:self; 287, identifier:property; 288, argument_list; 288, 289; 289, string:'scaled'; 290, if_statement; 290, 291; 290, 292; 291, identifier:scaled; 292, block; 292, 293; 293, expression_statement; 293, 294; 294, assignment; 294, 295; 294, 296; 295, identifier:pixmap; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:pixmap; 299, identifier:scaled; 300, argument_list; 300, 301; 300, 308; 300, 315; 300, 320; 301, binary_operator:*; 301, 302; 301, 307; 302, call; 302, 303; 302, 306; 303, attribute; 303, 304; 303, 305; 304, identifier:pixmap; 305, identifier:width; 306, argument_list; 307, identifier:scaled; 308, binary_operator:*; 308, 309; 308, 314; 309, call; 309, 310; 309, 313; 310, attribute; 310, 311; 310, 312; 311, identifier:pixmap; 312, identifier:height; 313, argument_list; 314, identifier:scaled; 315, attribute; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:QtCore; 318, identifier:Qt; 319, identifier:KeepAspectRatio; 320, attribute; 320, 321; 320, 324; 321, attribute; 321, 322; 321, 323; 322, identifier:QtCore; 323, identifier:Qt; 324, identifier:SmoothTransformation; 325, expression_statement; 325, 326; 326, assignment; 326, 327; 326, 328; 327, identifier:kwds; 328, dictionary; 329, expression_statement; 329, 330; 330, assignment; 330, 331; 330, 334; 331, subscript; 331, 332; 331, 333; 332, identifier:kwds; 333, string:'whatsThis'; 334, call; 334, 335; 334, 338; 335, attribute; 335, 336; 335, 337; 336, identifier:widget; 337, identifier:whatsThis; 338, argument_list; 339, expression_statement; 339, 340; 340, assignment; 340, 341; 340, 344; 341, subscript; 341, 342; 341, 343; 342, identifier:kwds; 343, string:'toolTip'; 344, call; 344, 345; 344, 348; 345, attribute; 345, 346; 345, 347; 346, identifier:widget; 347, identifier:toolTip; 348, argument_list; 349, expression_statement; 349, 350; 350, assignment; 350, 351; 350, 354; 351, subscript; 351, 352; 351, 353; 352, identifier:kwds; 353, string:'windowTitle'; 354, call; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:widget; 357, identifier:windowTitle; 358, argument_list; 359, expression_statement; 359, 360; 360, assignment; 360, 361; 360, 364; 361, subscript; 361, 362; 361, 363; 362, identifier:kwds; 363, string:'objectName'; 364, call; 364, 365; 364, 368; 365, attribute; 365, 366; 365, 367; 366, identifier:widget; 367, identifier:objectName; 368, argument_list; 369, expression_statement; 369, 370; 370, call; 370, 371; 370, 374; 371, attribute; 371, 372; 371, 373; 372, identifier:self; 373, identifier:setProperty; 374, argument_list; 374, 375; 374, 376; 375, string:'caption'; 376, call; 376, 377; 376, 386; 377, attribute; 377, 378; 377, 385; 378, call; 378, 379; 378, 382; 379, attribute; 379, 380; 379, 381; 380, identifier:self; 381, identifier:property; 382, argument_list; 382, 383; 382, 384; 383, string:'caption'; 384, string:''; 385, identifier:format; 386, argument_list; 386, 387; 387, dictionary_splat; 387, 388; 388, identifier:kwds; 389, expression_statement; 389, 390; 390, call; 390, 391; 390, 394; 391, attribute; 391, 392; 391, 393; 392, identifier:self; 393, identifier:setProperty; 394, argument_list; 394, 395; 394, 396; 395, string:'pixmap'; 396, identifier:pixmap; 397, expression_statement; 397, 398; 398, call; 398, 399; 398, 402; 399, attribute; 399, 400; 399, 401; 400, identifier:self; 401, identifier:addPixmap; 402, argument_list; 402, 403; 403, identifier:pixmap; 404, return_statement; 404, 405; 405, call; 405, 406; 405, 413; 406, attribute; 406, 407; 406, 412; 407, call; 407, 408; 407, 409; 408, identifier:super; 409, argument_list; 409, 410; 409, 411; 410, identifier:XWalkthroughSnapshot; 411, identifier:self; 412, identifier:prepare; 413, argument_list
def prepare(self): pixmap = self.property('pixmap') if pixmap is not None: return super(XWalkthroughSnapshot, self).prepare() widget = self.property('widget') if type(widget) in (unicode, str): widget = self.findReference(widget) if not widget: return super(XWalkthroughSnapshot, self).prepare() if self.property('overlay') and widget.parent(): ref = self.referenceWidget() if ref == widget: pos = QtCore.QPoint(0, 0) else: glbl_pos = widget.mapToGlobal(QtCore.QPoint(0, 0)) pos = ref.mapFromGlobal(glbl_pos) self.setProperty('pos', pos) crop = self.property('crop', QtCore.QRect(0, 0, 0, 0)) if crop: rect = widget.rect() if crop.width(): rect.setWidth(crop.width()) if crop.height(): rect.setHeight(crop.height()) if crop.x(): rect.setX(rect.width() - crop.x()) if crop.y(): rect.setY(rect.height() - crop.y()) pixmap = QtGui.QPixmap.grabWidget(widget, rect) else: pixmap = QtGui.QPixmap.grabWidget(widget) scaled = self.property('scaled') if scaled: pixmap = pixmap.scaled(pixmap.width() * scaled, pixmap.height() * scaled, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) kwds = {} kwds['whatsThis'] = widget.whatsThis() kwds['toolTip'] = widget.toolTip() kwds['windowTitle'] = widget.windowTitle() kwds['objectName'] = widget.objectName() self.setProperty('caption', self.property('caption', '').format(**kwds)) self.setProperty('pixmap', pixmap) self.addPixmap(pixmap) return super(XWalkthroughSnapshot, self).prepare()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:depends; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:func; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:after; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:before; 12, None; 13, default_parameter; 13, 14; 13, 15; 14, identifier:priority; 15, None; 16, block; 16, 17; 16, 43; 16, 57; 16, 76; 16, 97; 16, 173; 16, 178; 16, 184; 16, 195; 16, 217; 17, if_statement; 17, 18; 17, 37; 18, not_operator; 18, 19; 19, parenthesized_expression; 19, 20; 20, boolean_operator:or; 20, 21; 20, 31; 21, boolean_operator:or; 21, 22; 21, 25; 22, comparison_operator:is; 22, 23; 22, 24; 23, identifier:func; 24, None; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:inspect; 28, identifier:ismethod; 29, argument_list; 29, 30; 30, identifier:func; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:inspect; 34, identifier:isfunction; 35, argument_list; 35, 36; 36, identifier:func; 37, block; 37, 38; 38, raise_statement; 38, 39; 39, call; 39, 40; 39, 41; 40, identifier:ValueError; 41, argument_list; 41, 42; 42, string:"depends decorator can only be used on functions or methods"; 43, if_statement; 43, 44; 43, 51; 44, not_operator; 44, 45; 45, parenthesized_expression; 45, 46; 46, boolean_operator:or; 46, 47; 46, 50; 47, boolean_operator:or; 47, 48; 47, 49; 48, identifier:after; 49, identifier:before; 50, identifier:priority; 51, block; 51, 52; 52, raise_statement; 52, 53; 53, call; 53, 54; 53, 55; 54, identifier:ValueError; 55, argument_list; 55, 56; 56, string:"depends decorator needs at least one argument"; 57, if_statement; 57, 58; 57, 61; 58, comparison_operator:is; 58, 59; 58, 60; 59, identifier:func; 60, None; 61, block; 61, 62; 62, return_statement; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:partial; 65, argument_list; 65, 66; 65, 67; 65, 70; 65, 73; 66, identifier:depends; 67, keyword_argument; 67, 68; 67, 69; 68, identifier:after; 69, identifier:after; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:before; 72, identifier:before; 73, keyword_argument; 73, 74; 73, 75; 74, identifier:priority; 75, identifier:priority; 76, function_definition; 76, 77; 76, 78; 76, 81; 77, function_name:self_check; 78, parameters; 78, 79; 78, 80; 79, identifier:a; 80, identifier:b; 81, block; 81, 82; 82, if_statement; 82, 83; 82, 86; 83, comparison_operator:==; 83, 84; 83, 85; 84, identifier:a; 85, identifier:b; 86, block; 86, 87; 87, raise_statement; 87, 88; 88, call; 88, 89; 88, 90; 89, identifier:ValueError; 90, argument_list; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, string:"Test '{}' cannot depend on itself"; 94, identifier:format; 95, argument_list; 95, 96; 96, identifier:a; 97, function_definition; 97, 98; 97, 99; 97, 104; 98, function_name:handle_dep; 99, parameters; 99, 100; 99, 101; 100, identifier:conditions; 101, default_parameter; 101, 102; 101, 103; 102, identifier:_before; 103, True; 104, block; 104, 105; 105, if_statement; 105, 106; 105, 107; 106, identifier:conditions; 107, block; 107, 108; 107, 121; 108, if_statement; 108, 109; 108, 115; 109, comparison_operator:is; 109, 110; 109, 114; 110, call; 110, 111; 110, 112; 111, identifier:type; 112, argument_list; 112, 113; 113, identifier:conditions; 114, identifier:list; 115, block; 115, 116; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:conditions; 119, list:[conditions]; 119, 120; 120, identifier:conditions; 121, for_statement; 121, 122; 121, 123; 121, 124; 122, identifier:cond; 123, identifier:conditions; 124, block; 124, 125; 124, 138; 124, 146; 125, if_statement; 125, 126; 125, 131; 126, call; 126, 127; 126, 128; 127, identifier:hasattr; 128, argument_list; 128, 129; 128, 130; 129, identifier:cond; 130, string:'__call__'; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:cond; 135, attribute; 135, 136; 135, 137; 136, identifier:cond; 137, identifier:__name__; 138, expression_statement; 138, 139; 139, call; 139, 140; 139, 141; 140, identifier:self_check; 141, argument_list; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:func; 144, identifier:__name__; 145, identifier:cond; 146, if_statement; 146, 147; 146, 148; 146, 160; 147, identifier:_before; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 156; 151, attribute; 151, 152; 151, 155; 152, subscript; 152, 153; 152, 154; 153, identifier:soft_dependencies; 154, identifier:cond; 155, identifier:add; 156, argument_list; 156, 157; 157, attribute; 157, 158; 157, 159; 158, identifier:func; 159, identifier:__name__; 160, else_clause; 160, 161; 161, block; 161, 162; 162, expression_statement; 162, 163; 163, call; 163, 164; 163, 171; 164, attribute; 164, 165; 164, 170; 165, subscript; 165, 166; 165, 167; 166, identifier:dependencies; 167, attribute; 167, 168; 167, 169; 168, identifier:func; 169, identifier:__name__; 170, identifier:add; 171, argument_list; 171, 172; 172, identifier:cond; 173, expression_statement; 173, 174; 174, call; 174, 175; 174, 176; 175, identifier:handle_dep; 176, argument_list; 176, 177; 177, identifier:before; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 181; 180, identifier:handle_dep; 181, argument_list; 181, 182; 181, 183; 182, identifier:after; 183, False; 184, if_statement; 184, 185; 184, 186; 185, identifier:priority; 186, block; 186, 187; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 194; 189, subscript; 189, 190; 189, 191; 190, identifier:priorities; 191, attribute; 191, 192; 191, 193; 192, identifier:func; 193, identifier:__name__; 194, identifier:priority; 195, decorated_definition; 195, 196; 195, 201; 196, decorator; 196, 197; 197, call; 197, 198; 197, 199; 198, identifier:wraps; 199, argument_list; 199, 200; 200, identifier:func; 201, function_definition; 201, 202; 201, 203; 201, 208; 202, function_name:inner; 203, parameters; 203, 204; 203, 206; 204, list_splat_pattern; 204, 205; 205, identifier:args; 206, dictionary_splat_pattern; 206, 207; 207, identifier:kwargs; 208, block; 208, 209; 209, return_statement; 209, 210; 210, call; 210, 211; 210, 212; 211, identifier:func; 212, argument_list; 212, 213; 212, 215; 213, list_splat; 213, 214; 214, identifier:args; 215, dictionary_splat; 215, 216; 216, identifier:kwargs; 217, return_statement; 217, 218; 218, identifier:inner
def depends(func=None, after=None, before=None, priority=None): if not (func is None or inspect.ismethod(func) or inspect.isfunction(func)): raise ValueError("depends decorator can only be used on functions or methods") if not (after or before or priority): raise ValueError("depends decorator needs at least one argument") if func is None: return partial(depends, after=after, before=before, priority=priority) def self_check(a, b): if a == b: raise ValueError("Test '{}' cannot depend on itself".format(a)) def handle_dep(conditions, _before=True): if conditions: if type(conditions) is not list: conditions = [conditions] for cond in conditions: if hasattr(cond, '__call__'): cond = cond.__name__ self_check(func.__name__, cond) if _before: soft_dependencies[cond].add(func.__name__) else: dependencies[func.__name__].add(cond) handle_dep(before) handle_dep(after, False) if priority: priorities[func.__name__] = priority @wraps(func) def inner(*args, **kwargs): return func(*args, **kwargs) return inner
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_translate_language_name; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:language_name; 6, block; 6, 7; 6, 15; 6, 19; 6, 44; 6, 73; 6, 98; 6, 112; 6, 128; 6, 145; 6, 152; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:languages; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:languages; 14, argument_list; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:language_id; 18, None; 19, for_statement; 19, 20; 19, 23; 19, 28; 20, pattern_list; 20, 21; 20, 22; 21, identifier:ideone_index; 22, identifier:ideone_language; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:languages; 26, identifier:items; 27, argument_list; 28, block; 28, 29; 29, if_statement; 29, 30; 29, 41; 30, comparison_operator:==; 30, 31; 30, 36; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:ideone_language; 34, identifier:lower; 35, argument_list; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:language_name; 39, identifier:lower; 40, argument_list; 41, block; 41, 42; 42, return_statement; 42, 43; 43, identifier:ideone_index; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:simple_languages; 47, call; 47, 48; 47, 49; 48, identifier:dict; 49, generator_expression; 49, 50; 49, 64; 50, tuple; 50, 51; 50, 52; 51, identifier:k; 52, call; 52, 53; 52, 63; 53, attribute; 53, 54; 53, 62; 54, subscript; 54, 55; 54, 61; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:v; 58, identifier:split; 59, argument_list; 59, 60; 60, string:'('; 61, integer:0; 62, identifier:strip; 63, argument_list; 64, for_in_clause; 64, 65; 64, 68; 65, tuple_pattern; 65, 66; 65, 67; 66, identifier:k; 67, identifier:v; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:languages; 71, identifier:items; 72, argument_list; 73, for_statement; 73, 74; 73, 77; 73, 82; 74, pattern_list; 74, 75; 74, 76; 75, identifier:ideone_index; 76, identifier:simple_name; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:simple_languages; 80, identifier:items; 81, argument_list; 82, block; 82, 83; 83, if_statement; 83, 84; 83, 95; 84, comparison_operator:==; 84, 85; 84, 90; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:simple_name; 88, identifier:lower; 89, argument_list; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:language_name; 93, identifier:lower; 94, argument_list; 95, block; 95, 96; 96, return_statement; 96, 97; 97, identifier:ideone_index; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:language_choices; 101, binary_operator:+; 101, 102; 101, 107; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:languages; 105, identifier:values; 106, argument_list; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:simple_languages; 110, identifier:values; 111, argument_list; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:similar_choices; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:difflib; 118, identifier:get_close_matches; 119, argument_list; 119, 120; 119, 121; 119, 122; 119, 125; 120, identifier:language_name; 121, identifier:language_choices; 122, keyword_argument; 122, 123; 122, 124; 123, identifier:n; 124, integer:3; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:cutoff; 127, float:0.3; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:similar_choices_string; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, string:", "; 134, identifier:join; 135, argument_list; 135, 136; 136, list_comprehension; 136, 137; 136, 142; 137, binary_operator:+; 137, 138; 137, 141; 138, binary_operator:+; 138, 139; 138, 140; 139, string:"'"; 140, identifier:s; 141, string:"'"; 142, for_in_clause; 142, 143; 142, 144; 143, identifier:s; 144, identifier:similar_choices; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:error_string; 148, parenthesized_expression; 148, 149; 149, concatenated_string; 149, 150; 149, 151; 150, string:"Couldn't match '%s' to an Ideone accepted language.\n"; 151, string:"Did you mean one of the following: %s"; 152, raise_statement; 152, 153; 153, call; 153, 154; 153, 155; 154, identifier:IdeoneError; 155, argument_list; 155, 156; 156, binary_operator:%; 156, 157; 156, 158; 157, identifier:error_string; 158, tuple; 158, 159; 158, 160; 159, identifier:language_name; 160, identifier:similar_choices_string
def _translate_language_name(self, language_name): languages = self.languages() language_id = None for ideone_index, ideone_language in languages.items(): if ideone_language.lower() == language_name.lower(): return ideone_index simple_languages = dict((k,v.split('(')[0].strip()) for (k,v) in languages.items()) for ideone_index, simple_name in simple_languages.items(): if simple_name.lower() == language_name.lower(): return ideone_index language_choices = languages.values() + simple_languages.values() similar_choices = difflib.get_close_matches(language_name, language_choices, n=3, cutoff=0.3) similar_choices_string = ", ".join(["'" + s + "'" for s in similar_choices]) error_string = ("Couldn't match '%s' to an Ideone accepted language.\n" "Did you mean one of the following: %s") raise IdeoneError(error_string % (language_name, similar_choices_string))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:headerSortAscending; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:setSortingEnabled; 11, argument_list; 11, 12; 12, True; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:sortByColumn; 18, argument_list; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:_headerIndex; 22, attribute; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:QtCore; 25, identifier:Qt; 26, identifier:AscendingOrder
def headerSortAscending( self ): self.setSortingEnabled(True) self.sortByColumn(self._headerIndex, QtCore.Qt.AscendingOrder)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:headerSortDescending; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:setSortingEnabled; 11, argument_list; 11, 12; 12, True; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:sortByColumn; 18, argument_list; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:_headerIndex; 22, attribute; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:QtCore; 25, identifier:Qt; 26, identifier:DescendingOrder
def headerSortDescending( self ): self.setSortingEnabled(True) self.sortByColumn(self._headerIndex, QtCore.Qt.DescendingOrder)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:from_api; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:api; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 19; 8, 90; 8, 114; 8, 147; 8, 172; 8, 179; 8, 252; 9, if_statement; 9, 10; 9, 14; 10, not_operator; 10, 11; 11, attribute; 11, 12; 11, 13; 12, identifier:cls; 13, identifier:_api_attrs; 14, block; 14, 15; 15, raise_statement; 15, 16; 16, call; 16, 17; 16, 18; 17, identifier:NotImplementedError; 18, argument_list; 19, function_definition; 19, 20; 19, 21; 19, 23; 20, function_name:resolve_attribute_type; 21, parameters; 21, 22; 22, identifier:attr_type; 23, block; 23, 24; 23, 37; 23, 46; 23, 59; 23, 68; 23, 88; 24, while_statement; 24, 25; 24, 30; 25, call; 25, 26; 25, 27; 26, identifier:isinstance; 27, argument_list; 27, 28; 27, 29; 28, identifier:attr_type; 29, identifier:list; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:attr_type; 34, subscript; 34, 35; 34, 36; 35, identifier:attr_type; 36, integer:0; 37, if_statement; 37, 38; 37, 41; 38, comparison_operator:==; 38, 39; 38, 40; 39, identifier:attr_type; 40, string:'self'; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:attr_type; 45, identifier:cls; 46, if_statement; 46, 47; 46, 50; 47, comparison_operator:==; 47, 48; 47, 49; 48, identifier:attr_type; 49, string:'date'; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:attr_type; 54, attribute; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:datetime; 57, identifier:datetime; 58, identifier:fromtimestamp; 59, if_statement; 59, 60; 59, 63; 60, comparison_operator:is; 60, 61; 60, 62; 61, identifier:attr_type; 62, identifier:str; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:attr_type; 67, identifier:unicode; 68, if_statement; 68, 69; 68, 74; 69, call; 69, 70; 69, 71; 70, identifier:hasattr; 71, argument_list; 71, 72; 71, 73; 72, identifier:attr_type; 73, string:'from_api'; 74, block; 74, 75; 75, return_statement; 75, 76; 76, lambda; 76, 77; 76, 80; 77, lambda_parameters; 77, 78; 78, dictionary_splat_pattern; 78, 79; 79, identifier:kw; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:attr_type; 83, identifier:from_api; 84, argument_list; 84, 85; 84, 86; 85, identifier:api; 86, dictionary_splat; 86, 87; 87, identifier:kw; 88, return_statement; 88, 89; 89, identifier:attr_type; 90, function_definition; 90, 91; 90, 92; 90, 95; 91, function_name:instantiate_attr; 92, parameters; 92, 93; 92, 94; 93, identifier:attr_value; 94, identifier:attr_type; 95, block; 95, 96; 95, 109; 96, if_statement; 96, 97; 96, 102; 97, call; 97, 98; 97, 99; 98, identifier:isinstance; 99, argument_list; 99, 100; 99, 101; 100, identifier:attr_value; 101, identifier:dict; 102, block; 102, 103; 103, return_statement; 103, 104; 104, call; 104, 105; 104, 106; 105, identifier:attr_type; 106, argument_list; 106, 107; 107, dictionary_splat; 107, 108; 108, identifier:attr_value; 109, return_statement; 109, 110; 110, call; 110, 111; 110, 112; 111, identifier:attr_type; 112, argument_list; 112, 113; 113, identifier:attr_value; 114, function_definition; 114, 115; 114, 116; 114, 119; 115, function_name:instantiate_array; 116, parameters; 116, 117; 116, 118; 117, identifier:attr_values; 118, identifier:attr_type; 119, block; 119, 120; 119, 124; 119, 137; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:func; 123, identifier:instantiate_attr; 124, if_statement; 124, 125; 124, 132; 125, call; 125, 126; 125, 127; 126, identifier:isinstance; 127, argument_list; 127, 128; 127, 131; 128, subscript; 128, 129; 128, 130; 129, identifier:attr_values; 130, integer:0; 131, identifier:list; 132, block; 132, 133; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:func; 136, identifier:instantiate_array; 137, return_statement; 137, 138; 138, list_comprehension; 138, 139; 138, 144; 139, call; 139, 140; 139, 141; 140, identifier:func; 141, argument_list; 141, 142; 141, 143; 142, identifier:val; 143, identifier:attr_type; 144, for_in_clause; 144, 145; 144, 146; 145, identifier:val; 146, identifier:attr_values; 147, function_definition; 147, 148; 147, 149; 147, 152; 148, function_name:instantiate; 149, parameters; 149, 150; 149, 151; 150, identifier:attr_value; 151, identifier:attr_type; 152, block; 152, 153; 152, 166; 153, if_statement; 153, 154; 153, 159; 154, call; 154, 155; 154, 156; 155, identifier:isinstance; 156, argument_list; 156, 157; 156, 158; 157, identifier:attr_value; 158, identifier:list; 159, block; 159, 160; 160, return_statement; 160, 161; 161, call; 161, 162; 161, 163; 162, identifier:instantiate_array; 163, argument_list; 163, 164; 163, 165; 164, identifier:attr_value; 165, identifier:attr_type; 166, return_statement; 166, 167; 167, call; 167, 168; 167, 169; 168, identifier:instantiate_attr; 169, argument_list; 169, 170; 169, 171; 170, identifier:attr_value; 171, identifier:attr_type; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:instance; 175, call; 175, 176; 175, 177; 176, identifier:cls; 177, argument_list; 177, 178; 178, identifier:api; 179, for_statement; 179, 180; 179, 184; 179, 187; 180, pattern_list; 180, 181; 180, 182; 180, 183; 181, identifier:attr_name; 182, identifier:attr_type; 183, identifier:attr_default; 184, attribute; 184, 185; 184, 186; 185, identifier:cls; 186, identifier:_api_attrs; 187, block; 187, 188; 187, 198; 187, 216; 187, 223; 187, 236; 187, 245; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 191; 190, identifier:attr_value; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:kwargs; 194, identifier:get; 195, argument_list; 195, 196; 195, 197; 196, identifier:attr_name; 197, identifier:attr_default; 198, if_statement; 198, 199; 198, 202; 199, comparison_operator:is; 199, 200; 199, 201; 200, identifier:attr_value; 201, identifier:TypeError; 202, block; 202, 203; 203, raise_statement; 203, 204; 204, call; 204, 205; 204, 206; 205, identifier:TypeError; 206, argument_list; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, string:'{} requires argument {}'; 210, identifier:format; 211, argument_list; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:cls; 214, identifier:__name__; 215, identifier:attr_name; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:attr_type; 219, call; 219, 220; 219, 221; 220, identifier:resolve_attribute_type; 221, argument_list; 221, 222; 222, identifier:attr_type; 223, if_statement; 223, 224; 223, 227; 224, comparison_operator:!=; 224, 225; 224, 226; 225, identifier:attr_value; 226, identifier:attr_default; 227, block; 227, 228; 228, expression_statement; 228, 229; 229, assignment; 229, 230; 229, 231; 230, identifier:attr_value; 231, call; 231, 232; 231, 233; 232, identifier:instantiate; 233, argument_list; 233, 234; 233, 235; 234, identifier:attr_value; 235, identifier:attr_type; 236, if_statement; 236, 237; 236, 240; 237, comparison_operator:==; 237, 238; 237, 239; 238, identifier:attr_name; 239, string:'from'; 240, block; 240, 241; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:attr_name; 244, string:'froom'; 245, expression_statement; 245, 246; 246, call; 246, 247; 246, 248; 247, identifier:setattr; 248, argument_list; 248, 249; 248, 250; 248, 251; 249, identifier:instance; 250, identifier:attr_name; 251, identifier:attr_value; 252, return_statement; 252, 253; 253, identifier:instance
def from_api(cls, api, **kwargs): if not cls._api_attrs: raise NotImplementedError() def resolve_attribute_type(attr_type): while isinstance(attr_type, list): attr_type = attr_type[0] if attr_type == 'self': attr_type = cls if attr_type == 'date': attr_type = datetime.datetime.fromtimestamp if attr_type is str: attr_type = unicode if hasattr(attr_type, 'from_api'): return lambda **kw: attr_type.from_api(api, **kw) return attr_type def instantiate_attr(attr_value, attr_type): if isinstance(attr_value, dict): return attr_type(**attr_value) return attr_type(attr_value) def instantiate_array(attr_values, attr_type): func = instantiate_attr if isinstance(attr_values[0], list): func = instantiate_array return [func(val, attr_type) for val in attr_values] def instantiate(attr_value, attr_type): if isinstance(attr_value, list): return instantiate_array(attr_value, attr_type) return instantiate_attr(attr_value, attr_type) instance = cls(api) for attr_name, attr_type, attr_default in cls._api_attrs: attr_value = kwargs.get(attr_name, attr_default) if attr_value is TypeError: raise TypeError('{} requires argument {}'.format(cls.__name__, attr_name)) attr_type = resolve_attribute_type(attr_type) if attr_value != attr_default: attr_value = instantiate(attr_value, attr_type) if attr_name == 'from': attr_name = 'froom' setattr(instance, attr_name, attr_value) return instance
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:updateEditor; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 22; 5, 32; 5, 36; 5, 40; 5, 53; 5, 101; 5, 110; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:rule; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:currentRule; 13, argument_list; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:operator; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:currentOperator; 21, argument_list; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:widget; 25, call; 25, 26; 25, 31; 26, attribute; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:uiWidgetAREA; 30, identifier:widget; 31, argument_list; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:editorType; 35, None; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:text; 39, string:''; 40, if_statement; 40, 41; 40, 43; 41, parenthesized_expression; 41, 42; 42, identifier:rule; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:editorType; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:rule; 50, identifier:editorType; 51, argument_list; 51, 52; 52, identifier:operator; 53, if_statement; 53, 54; 53, 65; 53, 67; 54, parenthesized_expression; 54, 55; 55, boolean_operator:and; 55, 56; 55, 59; 56, boolean_operator:and; 56, 57; 56, 58; 57, identifier:widget; 58, identifier:editorType; 59, comparison_operator:==; 59, 60; 59, 64; 60, call; 60, 61; 60, 62; 61, identifier:type; 62, argument_list; 62, 63; 63, identifier:widget; 64, identifier:editorType; 65, block; 65, 66; 66, return_statement; 67, elif_clause; 67, 68; 67, 70; 68, parenthesized_expression; 68, 69; 69, identifier:widget; 70, block; 70, 71; 70, 88; 70, 95; 71, if_statement; 71, 72; 71, 79; 72, parenthesized_expression; 72, 73; 73, comparison_operator:!=; 73, 74; 73, 78; 74, call; 74, 75; 74, 76; 75, identifier:type; 76, argument_list; 76, 77; 77, identifier:widget; 78, identifier:QWidget; 79, block; 79, 80; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:text; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:widget; 86, identifier:text; 87, argument_list; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:widget; 92, identifier:setParent; 93, argument_list; 93, 94; 94, None; 95, expression_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:widget; 99, identifier:deleteLater; 100, argument_list; 101, expression_statement; 101, 102; 102, call; 102, 103; 102, 108; 103, attribute; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:uiWidgetAREA; 107, identifier:setWidget; 108, argument_list; 108, 109; 109, None; 110, if_statement; 110, 111; 110, 113; 111, parenthesized_expression; 111, 112; 112, identifier:editorType; 113, block; 113, 114; 113, 121; 113, 177; 113, 186; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:widget; 117, call; 117, 118; 117, 119; 118, identifier:editorType; 119, argument_list; 119, 120; 120, identifier:self; 121, if_statement; 121, 122; 121, 128; 122, parenthesized_expression; 122, 123; 123, call; 123, 124; 123, 125; 124, identifier:isinstance; 125, argument_list; 125, 126; 125, 127; 126, identifier:widget; 127, identifier:QLineEdit; 128, block; 128, 129; 128, 137; 128, 162; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:terms; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:rule; 135, identifier:completionTerms; 136, argument_list; 137, if_statement; 137, 138; 137, 141; 138, parenthesized_expression; 138, 139; 139, not_operator; 139, 140; 140, identifier:terms; 141, block; 141, 142; 141, 150; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:qwidget; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:self; 148, identifier:queryBuilderWidget; 149, argument_list; 150, if_statement; 150, 151; 150, 153; 151, parenthesized_expression; 151, 152; 152, identifier:qwidget; 153, block; 153, 154; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:terms; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:qwidget; 160, identifier:completionTerms; 161, argument_list; 162, if_statement; 162, 163; 162, 165; 163, parenthesized_expression; 163, 164; 164, identifier:terms; 165, block; 165, 166; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:widget; 170, identifier:setCompleter; 171, argument_list; 171, 172; 172, call; 172, 173; 172, 174; 173, identifier:XQueryCompleter; 174, argument_list; 174, 175; 174, 176; 175, identifier:terms; 176, identifier:widget; 177, expression_statement; 177, 178; 178, call; 178, 179; 178, 184; 179, attribute; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:uiWidgetAREA; 183, identifier:setWidget; 184, argument_list; 184, 185; 185, identifier:widget; 186, if_statement; 186, 187; 186, 194; 187, parenthesized_expression; 187, 188; 188, comparison_operator:!=; 188, 189; 188, 193; 189, call; 189, 190; 189, 191; 190, identifier:type; 191, argument_list; 191, 192; 192, identifier:widget; 193, identifier:QWidget; 194, block; 194, 195; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:widget; 199, identifier:setText; 200, argument_list; 200, 201; 201, identifier:text
def updateEditor( self ): rule = self.currentRule() operator = self.currentOperator() widget = self.uiWidgetAREA.widget() editorType = None text = '' if ( rule ): editorType = rule.editorType(operator) if ( widget and editorType and type(widget) == editorType ): return elif ( widget ): if ( type(widget) != QWidget ): text = widget.text() widget.setParent(None) widget.deleteLater() self.uiWidgetAREA.setWidget(None) if ( editorType ): widget = editorType(self) if ( isinstance(widget, QLineEdit) ): terms = rule.completionTerms() if ( not terms ): qwidget = self.queryBuilderWidget() if ( qwidget ): terms = qwidget.completionTerms() if ( terms ): widget.setCompleter(XQueryCompleter(terms, widget)) self.uiWidgetAREA.setWidget(widget) if ( type(widget) != QWidget ): widget.setText(text)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:StreamMetrics; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request_iterator; 6, identifier:context; 7, block; 7, 8; 7, 15; 7, 23; 7, 27; 7, 31; 7, 46; 7, 77; 7, 108; 7, 119; 7, 130; 7, 147; 7, 153; 7, 159; 7, 163; 7, 167; 7, 173; 7, 402; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:LOG; 12, identifier:debug; 13, argument_list; 13, 14; 14, string:"StreamMetrics called"; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:collect_args; 18, parenthesized_expression; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:next; 21, argument_list; 21, 22; 22, identifier:request_iterator; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:max_metrics_buffer; 26, integer:0; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:max_collect_duration; 30, integer:0; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:cfg; 34, call; 34, 35; 34, 36; 35, identifier:Metric; 36, argument_list; 36, 37; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:pb; 39, subscript; 39, 40; 39, 45; 40, attribute; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:collect_args; 43, identifier:Metrics_Arg; 44, identifier:metrics; 45, integer:0; 46, try_statement; 46, 47; 46, 59; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:max_metrics_buffer; 51, call; 51, 52; 51, 53; 52, identifier:int; 53, argument_list; 53, 54; 54, subscript; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:cfg; 57, identifier:config; 58, string:"max-metrics-buffer"; 59, except_clause; 59, 60; 59, 64; 60, as_pattern; 60, 61; 60, 62; 61, identifier:Exception; 62, as_pattern_target; 62, 63; 63, identifier:ex; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:LOG; 69, identifier:debug; 70, argument_list; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, string:"Unable to get schedule parameters: {}"; 74, identifier:format; 75, argument_list; 75, 76; 76, identifier:ex; 77, try_statement; 77, 78; 77, 90; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:max_collect_duration; 82, call; 82, 83; 82, 84; 83, identifier:int; 84, argument_list; 84, 85; 85, subscript; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:cfg; 88, identifier:config; 89, string:"max-collect-duration"; 90, except_clause; 90, 91; 90, 95; 91, as_pattern; 91, 92; 91, 93; 92, identifier:Exception; 93, as_pattern_target; 93, 94; 94, identifier:ex; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:LOG; 100, identifier:debug; 101, argument_list; 101, 102; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, string:"Unable to get schedule parameters: {}"; 105, identifier:format; 106, argument_list; 106, 107; 107, identifier:ex; 108, if_statement; 108, 109; 108, 112; 109, comparison_operator:>; 109, 110; 109, 111; 110, identifier:max_metrics_buffer; 111, integer:0; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:self; 117, identifier:max_metrics_buffer; 118, identifier:max_metrics_buffer; 119, if_statement; 119, 120; 119, 123; 120, comparison_operator:>; 120, 121; 120, 122; 121, identifier:max_collect_duration; 122, integer:0; 123, block; 123, 124; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:max_collect_duration; 129, identifier:max_collect_duration; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:thread; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:threading; 136, identifier:Thread; 137, argument_list; 137, 138; 137, 143; 138, keyword_argument; 138, 139; 138, 140; 139, identifier:target; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:_stream_wrapper; 143, keyword_argument; 143, 144; 143, 145; 144, identifier:args; 145, tuple; 145, 146; 146, identifier:collect_args; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:thread; 151, identifier:daemon; 152, True; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:thread; 157, identifier:start; 158, argument_list; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:metrics; 162, list:[]; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:metrics_to_stream; 166, list:[]; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:stream_timeout; 170, attribute; 170, 171; 170, 172; 171, identifier:self; 172, identifier:max_collect_duration; 173, while_statement; 173, 174; 173, 179; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:context; 177, identifier:is_active; 178, argument_list; 179, block; 179, 180; 180, try_statement; 180, 181; 180, 223; 180, 276; 181, block; 181, 182; 181, 190; 181, 206; 181, 219; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:t_start; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:time; 188, identifier:time; 189, argument_list; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:metrics; 193, call; 193, 194; 193, 199; 194, attribute; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:self; 197, identifier:metrics_queue; 198, identifier:get; 199, argument_list; 199, 200; 199, 203; 200, keyword_argument; 200, 201; 200, 202; 201, identifier:block; 202, True; 203, keyword_argument; 203, 204; 203, 205; 204, identifier:timeout; 205, identifier:stream_timeout; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 209; 208, identifier:elapsed; 209, call; 209, 210; 209, 211; 210, identifier:round; 211, argument_list; 211, 212; 212, binary_operator:-; 212, 213; 212, 218; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:time; 216, identifier:time; 217, argument_list; 218, identifier:t_start; 219, expression_statement; 219, 220; 220, augmented_assignment:-=; 220, 221; 220, 222; 221, identifier:stream_timeout; 222, identifier:elapsed; 223, except_clause; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:queue; 226, identifier:Empty; 227, block; 227, 228; 227, 243; 227, 263; 227, 267; 227, 273; 228, expression_statement; 228, 229; 229, call; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:LOG; 232, identifier:debug; 233, argument_list; 233, 234; 234, call; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, string:"Max collect duration exceeded. Streaming {} metrics"; 237, identifier:format; 238, argument_list; 238, 239; 239, call; 239, 240; 239, 241; 240, identifier:len; 241, argument_list; 241, 242; 242, identifier:metrics_to_stream; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:metrics_col; 246, call; 246, 247; 246, 248; 247, identifier:CollectReply; 248, argument_list; 248, 249; 249, keyword_argument; 249, 250; 249, 251; 250, identifier:Metrics_Reply; 251, call; 251, 252; 251, 253; 252, identifier:MetricsReply; 253, argument_list; 253, 254; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:metrics; 256, list_comprehension; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:m; 259, identifier:pb; 260, for_in_clause; 260, 261; 260, 262; 261, identifier:m; 262, identifier:metrics_to_stream; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:metrics_to_stream; 266, list:[]; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:stream_timeout; 270, attribute; 270, 271; 270, 272; 271, identifier:self; 272, identifier:max_collect_duration; 273, expression_statement; 273, 274; 274, yield; 274, 275; 275, identifier:metrics_col; 276, else_clause; 276, 277; 277, block; 277, 278; 277, 347; 278, for_statement; 278, 279; 278, 280; 278, 281; 279, identifier:metric; 280, identifier:metrics; 281, block; 281, 282; 281, 289; 282, expression_statement; 282, 283; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:metrics_to_stream; 286, identifier:append; 287, argument_list; 287, 288; 288, identifier:metric; 289, if_statement; 289, 290; 289, 298; 290, comparison_operator:==; 290, 291; 290, 295; 291, call; 291, 292; 291, 293; 292, identifier:len; 293, argument_list; 293, 294; 294, identifier:metrics_to_stream; 295, attribute; 295, 296; 295, 297; 296, identifier:self; 297, identifier:max_metrics_buffer; 298, block; 298, 299; 298, 314; 298, 334; 298, 338; 298, 344; 299, expression_statement; 299, 300; 300, call; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:LOG; 303, identifier:debug; 304, argument_list; 304, 305; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, string:"Max metrics buffer reached. Streaming {} metrics"; 308, identifier:format; 309, argument_list; 309, 310; 310, call; 310, 311; 310, 312; 311, identifier:len; 312, argument_list; 312, 313; 313, identifier:metrics_to_stream; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 317; 316, identifier:metrics_col; 317, call; 317, 318; 317, 319; 318, identifier:CollectReply; 319, argument_list; 319, 320; 320, keyword_argument; 320, 321; 320, 322; 321, identifier:Metrics_Reply; 322, call; 322, 323; 322, 324; 323, identifier:MetricsReply; 324, argument_list; 324, 325; 325, keyword_argument; 325, 326; 325, 327; 326, identifier:metrics; 327, list_comprehension; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:m; 330, identifier:pb; 331, for_in_clause; 331, 332; 331, 333; 332, identifier:m; 333, identifier:metrics_to_stream; 334, expression_statement; 334, 335; 335, assignment; 335, 336; 335, 337; 336, identifier:metrics_to_stream; 337, list:[]; 338, expression_statement; 338, 339; 339, assignment; 339, 340; 339, 341; 340, identifier:stream_timeout; 341, attribute; 341, 342; 341, 343; 342, identifier:self; 343, identifier:max_collect_duration; 344, expression_statement; 344, 345; 345, yield; 345, 346; 346, identifier:metrics_col; 347, if_statement; 347, 348; 347, 353; 348, comparison_operator:==; 348, 349; 348, 352; 349, attribute; 349, 350; 349, 351; 350, identifier:self; 351, identifier:max_metrics_buffer; 352, integer:0; 353, block; 353, 354; 353, 369; 353, 389; 353, 393; 353, 399; 354, expression_statement; 354, 355; 355, call; 355, 356; 355, 359; 356, attribute; 356, 357; 356, 358; 357, identifier:LOG; 358, identifier:debug; 359, argument_list; 359, 360; 360, call; 360, 361; 360, 364; 361, attribute; 361, 362; 361, 363; 362, string:"Max metrics buffer set to 0. Streaming {} metrics"; 363, identifier:format; 364, argument_list; 364, 365; 365, call; 365, 366; 365, 367; 366, identifier:len; 367, argument_list; 367, 368; 368, identifier:metrics_to_stream; 369, expression_statement; 369, 370; 370, assignment; 370, 371; 370, 372; 371, identifier:metrics_col; 372, call; 372, 373; 372, 374; 373, identifier:CollectReply; 374, argument_list; 374, 375; 375, keyword_argument; 375, 376; 375, 377; 376, identifier:Metrics_Reply; 377, call; 377, 378; 377, 379; 378, identifier:MetricsReply; 379, argument_list; 379, 380; 380, keyword_argument; 380, 381; 380, 382; 381, identifier:metrics; 382, list_comprehension; 382, 383; 382, 386; 383, attribute; 383, 384; 383, 385; 384, identifier:m; 385, identifier:pb; 386, for_in_clause; 386, 387; 386, 388; 387, identifier:m; 388, identifier:metrics_to_stream; 389, expression_statement; 389, 390; 390, assignment; 390, 391; 390, 392; 391, identifier:metrics_to_stream; 392, list:[]; 393, expression_statement; 393, 394; 394, assignment; 394, 395; 394, 396; 395, identifier:stream_timeout; 396, attribute; 396, 397; 396, 398; 397, identifier:self; 398, identifier:max_collect_duration; 399, expression_statement; 399, 400; 400, yield; 400, 401; 401, identifier:metrics_col; 402, expression_statement; 402, 403; 403, call; 403, 404; 403, 409; 404, attribute; 404, 405; 404, 408; 405, attribute; 405, 406; 405, 407; 406, identifier:self; 407, identifier:done_queue; 408, identifier:put; 409, argument_list; 409, 410; 410, True
def StreamMetrics(self, request_iterator, context): LOG.debug("StreamMetrics called") collect_args = (next(request_iterator)) max_metrics_buffer = 0 max_collect_duration = 0 cfg = Metric(pb=collect_args.Metrics_Arg.metrics[0]) try: max_metrics_buffer = int(cfg.config["max-metrics-buffer"]) except Exception as ex: LOG.debug("Unable to get schedule parameters: {}".format(ex)) try: max_collect_duration = int(cfg.config["max-collect-duration"]) except Exception as ex: LOG.debug("Unable to get schedule parameters: {}".format(ex)) if max_metrics_buffer > 0: self.max_metrics_buffer = max_metrics_buffer if max_collect_duration > 0: self.max_collect_duration = max_collect_duration thread = threading.Thread(target=self._stream_wrapper, args=(collect_args,),) thread.daemon = True thread.start() metrics = [] metrics_to_stream = [] stream_timeout = self.max_collect_duration while context.is_active(): try: t_start = time.time() metrics = self.metrics_queue.get(block=True, timeout=stream_timeout) elapsed = round(time.time() - t_start) stream_timeout -= elapsed except queue.Empty: LOG.debug("Max collect duration exceeded. Streaming {} metrics".format(len(metrics_to_stream))) metrics_col = CollectReply(Metrics_Reply=MetricsReply(metrics=[m.pb for m in metrics_to_stream])) metrics_to_stream = [] stream_timeout = self.max_collect_duration yield metrics_col else: for metric in metrics: metrics_to_stream.append(metric) if len(metrics_to_stream) == self.max_metrics_buffer: LOG.debug("Max metrics buffer reached. Streaming {} metrics".format(len(metrics_to_stream))) metrics_col = CollectReply( Metrics_Reply=MetricsReply(metrics=[m.pb for m in metrics_to_stream])) metrics_to_stream = [] stream_timeout = self.max_collect_duration yield metrics_col if self.max_metrics_buffer == 0: LOG.debug("Max metrics buffer set to 0. Streaming {} metrics".format(len(metrics_to_stream))) metrics_col = CollectReply(Metrics_Reply=MetricsReply(metrics=[m.pb for m in metrics_to_stream])) metrics_to_stream = [] stream_timeout = self.max_collect_duration yield metrics_col self.done_queue.put(True)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare_node; 3, parameters; 3, 4; 4, identifier:data; 5, block; 5, 6; 5, 14; 5, 25; 5, 49; 5, 53; 5, 66; 5, 90; 5, 105; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:data; 9, block; 9, 10; 10, return_statement; 10, 11; 11, expression_list; 11, 12; 11, 13; 12, None; 13, dictionary; 14, if_statement; 14, 15; 14, 20; 15, call; 15, 16; 15, 17; 16, identifier:isinstance; 17, argument_list; 17, 18; 17, 19; 18, identifier:data; 19, identifier:str; 20, block; 20, 21; 21, return_statement; 21, 22; 22, expression_list; 22, 23; 22, 24; 23, identifier:data; 24, dictionary; 25, if_statement; 25, 26; 25, 38; 26, call; 26, 27; 26, 28; 27, identifier:all; 28, generator_expression; 28, 29; 28, 32; 29, comparison_operator:in; 29, 30; 29, 31; 30, identifier:field; 31, identifier:data; 32, for_in_clause; 32, 33; 32, 34; 33, identifier:field; 34, tuple; 34, 35; 34, 36; 34, 37; 35, string:"Node"; 36, string:"Service"; 37, string:"Checks"; 38, block; 38, 39; 39, return_statement; 39, 40; 40, expression_list; 40, 41; 40, 46; 41, subscript; 41, 42; 41, 45; 42, subscript; 42, 43; 42, 44; 43, identifier:data; 44, string:"Node"; 45, string:"Node"; 46, subscript; 46, 47; 46, 48; 47, identifier:data; 48, string:"Node"; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:result; 52, dictionary; 53, if_statement; 53, 54; 53, 57; 54, comparison_operator:in; 54, 55; 54, 56; 55, string:"ID"; 56, identifier:data; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:result; 62, string:"Node"; 63, subscript; 63, 64; 63, 65; 64, identifier:data; 65, string:"ID"; 66, for_statement; 66, 67; 66, 68; 66, 76; 67, identifier:k; 68, tuple; 68, 69; 68, 70; 68, 71; 68, 72; 68, 73; 68, 74; 68, 75; 69, string:"Datacenter"; 70, string:"Node"; 71, string:"Address"; 72, string:"TaggedAddresses"; 73, string:"Service"; 74, string:"Check"; 75, string:"Checks"; 76, block; 76, 77; 77, if_statement; 77, 78; 77, 81; 78, comparison_operator:in; 78, 79; 78, 80; 79, identifier:k; 80, identifier:data; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 87; 84, subscript; 84, 85; 84, 86; 85, identifier:result; 86, identifier:k; 87, subscript; 87, 88; 87, 89; 88, identifier:data; 89, identifier:k; 90, if_statement; 90, 91; 90, 98; 91, comparison_operator:==; 91, 92; 91, 96; 92, call; 92, 93; 92, 94; 93, identifier:list; 94, argument_list; 94, 95; 95, identifier:result; 96, list:["Node"]; 96, 97; 97, string:"Node"; 98, block; 98, 99; 99, return_statement; 99, 100; 100, expression_list; 100, 101; 100, 104; 101, subscript; 101, 102; 101, 103; 102, identifier:result; 103, string:"Node"; 104, dictionary; 105, return_statement; 105, 106; 106, expression_list; 106, 107; 106, 113; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:result; 110, identifier:get; 111, argument_list; 111, 112; 112, string:"Node"; 113, identifier:result
def prepare_node(data): if not data: return None, {} if isinstance(data, str): return data, {} if all(field in data for field in ("Node", "Service", "Checks")): return data["Node"]["Node"], data["Node"] result = {} if "ID" in data: result["Node"] = data["ID"] for k in ("Datacenter", "Node", "Address", "TaggedAddresses", "Service", "Check", "Checks"): if k in data: result[k] = data[k] if list(result) == ["Node"]: return result["Node"], {} return result.get("Node"), result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare_service; 3, parameters; 3, 4; 4, identifier:data; 5, block; 5, 6; 5, 14; 5, 25; 5, 49; 5, 102; 5, 117; 5, 121; 5, 134; 5, 156; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:data; 9, block; 9, 10; 10, return_statement; 10, 11; 11, expression_list; 11, 12; 11, 13; 12, None; 13, dictionary; 14, if_statement; 14, 15; 14, 20; 15, call; 15, 16; 15, 17; 16, identifier:isinstance; 17, argument_list; 17, 18; 17, 19; 18, identifier:data; 19, identifier:str; 20, block; 20, 21; 21, return_statement; 21, 22; 22, expression_list; 22, 23; 22, 24; 23, identifier:data; 24, dictionary; 25, if_statement; 25, 26; 25, 38; 26, call; 26, 27; 26, 28; 27, identifier:all; 28, generator_expression; 28, 29; 28, 32; 29, comparison_operator:in; 29, 30; 29, 31; 30, identifier:field; 31, identifier:data; 32, for_in_clause; 32, 33; 32, 34; 33, identifier:field; 34, tuple; 34, 35; 34, 36; 34, 37; 35, string:"Node"; 36, string:"Service"; 37, string:"Checks"; 38, block; 38, 39; 39, return_statement; 39, 40; 40, expression_list; 40, 41; 40, 46; 41, subscript; 41, 42; 41, 45; 42, subscript; 42, 43; 42, 44; 43, identifier:data; 44, string:"Service"; 45, string:"ID"; 46, subscript; 46, 47; 46, 48; 47, identifier:data; 48, string:"Service"; 49, if_statement; 49, 50; 49, 61; 50, call; 50, 51; 50, 52; 51, identifier:all; 52, generator_expression; 52, 53; 52, 56; 53, comparison_operator:in; 53, 54; 53, 55; 54, identifier:field; 55, identifier:data; 56, for_in_clause; 56, 57; 56, 58; 57, identifier:field; 58, tuple; 58, 59; 58, 60; 59, string:"ServiceName"; 60, string:"ServiceID"; 61, block; 61, 62; 62, return_statement; 62, 63; 63, expression_list; 63, 64; 63, 67; 64, subscript; 64, 65; 64, 66; 65, identifier:data; 66, string:"ServiceID"; 67, dictionary; 67, 68; 67, 73; 67, 78; 67, 86; 67, 94; 68, pair; 68, 69; 68, 70; 69, string:"ID"; 70, subscript; 70, 71; 70, 72; 71, identifier:data; 72, string:"ServiceID"; 73, pair; 73, 74; 73, 75; 74, string:"Service"; 75, subscript; 75, 76; 75, 77; 76, identifier:data; 77, string:"ServiceName"; 78, pair; 78, 79; 78, 80; 79, string:"Tags"; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:data; 83, identifier:get; 84, argument_list; 84, 85; 85, string:"ServiceTags"; 86, pair; 86, 87; 86, 88; 87, string:"Address"; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:data; 91, identifier:get; 92, argument_list; 92, 93; 93, string:"ServiceAddress"; 94, pair; 94, 95; 94, 96; 95, string:"Port"; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:data; 99, identifier:get; 100, argument_list; 100, 101; 101, string:"ServicePort"; 102, if_statement; 102, 103; 102, 110; 103, comparison_operator:==; 103, 104; 103, 108; 104, call; 104, 105; 104, 106; 105, identifier:list; 106, argument_list; 106, 107; 107, identifier:data; 108, list:["ID"]; 108, 109; 109, string:"ID"; 110, block; 110, 111; 111, return_statement; 111, 112; 112, expression_list; 112, 113; 112, 116; 113, subscript; 113, 114; 113, 115; 114, identifier:data; 115, string:"ID"; 116, dictionary; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:result; 120, dictionary; 121, if_statement; 121, 122; 121, 125; 122, comparison_operator:in; 122, 123; 122, 124; 123, string:"Name"; 124, identifier:data; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 131; 128, subscript; 128, 129; 128, 130; 129, identifier:result; 130, string:"Service"; 131, subscript; 131, 132; 131, 133; 132, identifier:data; 133, string:"Name"; 134, for_statement; 134, 135; 134, 136; 134, 142; 135, identifier:k; 136, tuple; 136, 137; 136, 138; 136, 139; 136, 140; 136, 141; 137, string:"Service"; 138, string:"ID"; 139, string:"Tags"; 140, string:"Address"; 141, string:"Port"; 142, block; 142, 143; 143, if_statement; 143, 144; 143, 147; 144, comparison_operator:in; 144, 145; 144, 146; 145, identifier:k; 146, identifier:data; 147, block; 147, 148; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 153; 150, subscript; 150, 151; 150, 152; 151, identifier:result; 152, identifier:k; 153, subscript; 153, 154; 153, 155; 154, identifier:data; 155, identifier:k; 156, return_statement; 156, 157; 157, expression_list; 157, 158; 157, 164; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:result; 161, identifier:get; 162, argument_list; 162, 163; 163, string:"ID"; 164, identifier:result
def prepare_service(data): if not data: return None, {} if isinstance(data, str): return data, {} if all(field in data for field in ("Node", "Service", "Checks")): return data["Service"]["ID"], data["Service"] if all(field in data for field in ("ServiceName", "ServiceID")): return data["ServiceID"], { "ID": data["ServiceID"], "Service": data["ServiceName"], "Tags": data.get("ServiceTags"), "Address": data.get("ServiceAddress"), "Port": data.get("ServicePort"), } if list(data) == ["ID"]: return data["ID"], {} result = {} if "Name" in data: result["Service"] = data["Name"] for k in ("Service", "ID", "Tags", "Address", "Port"): if k in data: result[k] = data[k] return result.get("ID"), result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:add_measurement; 3, parameters; 3, 4; 4, identifier:measurement; 5, block; 5, 6; 5, 8; 5, 23; 5, 37; 5, 50; 5, 61; 5, 76; 5, 84; 5, 95; 5, 116; 5, 122; 6, global_statement; 6, 7; 7, identifier:_buffer_size; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:_enabled; 11, block; 11, 12; 11, 22; 12, expression_statement; 12, 13; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:LOGGER; 16, identifier:debug; 17, argument_list; 17, 18; 17, 19; 18, string:'Discarding measurement for %s while not enabled'; 19, attribute; 19, 20; 19, 21; 20, identifier:measurement; 21, identifier:database; 22, return_statement; 23, if_statement; 23, 24; 23, 25; 24, identifier:_stopping; 25, block; 25, 26; 25, 36; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:LOGGER; 30, identifier:warning; 31, argument_list; 31, 32; 31, 33; 32, string:'Discarding measurement for %s while stopping'; 33, attribute; 33, 34; 33, 35; 34, identifier:measurement; 35, identifier:database; 36, return_statement; 37, if_statement; 37, 38; 37, 41; 38, comparison_operator:>; 38, 39; 38, 40; 39, identifier:_buffer_size; 40, identifier:_max_buffer_size; 41, block; 41, 42; 41, 49; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:LOGGER; 46, identifier:warning; 47, argument_list; 47, 48; 48, string:'Discarding measurement due to buffer size limit'; 49, return_statement; 50, if_statement; 50, 51; 50, 55; 51, not_operator; 51, 52; 52, attribute; 52, 53; 52, 54; 53, identifier:measurement; 54, identifier:fields; 55, block; 55, 56; 56, raise_statement; 56, 57; 57, call; 57, 58; 57, 59; 58, identifier:ValueError; 59, argument_list; 59, 60; 60, string:'Measurement does not contain a field'; 61, if_statement; 61, 62; 61, 67; 62, comparison_operator:not; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:measurement; 65, identifier:database; 66, identifier:_measurements; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 75; 70, subscript; 70, 71; 70, 72; 71, identifier:_measurements; 72, attribute; 72, 73; 72, 74; 73, identifier:measurement; 74, identifier:database; 75, list:[]; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:value; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:measurement; 82, identifier:marshall; 83, argument_list; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 93; 86, attribute; 86, 87; 86, 92; 87, subscript; 87, 88; 87, 89; 88, identifier:_measurements; 89, attribute; 89, 90; 89, 91; 90, identifier:measurement; 91, identifier:database; 92, identifier:append; 93, argument_list; 93, 94; 94, identifier:value; 95, if_statement; 95, 96; 95, 98; 96, not_operator; 96, 97; 97, identifier:_timeout; 98, block; 98, 99; 99, if_statement; 99, 100; 99, 111; 100, boolean_operator:or; 100, 101; 100, 109; 101, parenthesized_expression; 101, 102; 102, boolean_operator:and; 102, 103; 102, 104; 103, identifier:_batch_future; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:_batch_future; 107, identifier:done; 108, argument_list; 109, not_operator; 109, 110; 110, identifier:_batch_future; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 115; 114, identifier:_start_timeout; 115, argument_list; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:_buffer_size; 119, call; 119, 120; 119, 121; 120, identifier:_pending_measurements; 121, argument_list; 122, if_statement; 122, 123; 122, 126; 123, comparison_operator:>=; 123, 124; 123, 125; 124, identifier:_buffer_size; 125, identifier:_trigger_size; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 130; 129, identifier:_trigger_batch_write; 130, argument_list
def add_measurement(measurement): global _buffer_size if not _enabled: LOGGER.debug('Discarding measurement for %s while not enabled', measurement.database) return if _stopping: LOGGER.warning('Discarding measurement for %s while stopping', measurement.database) return if _buffer_size > _max_buffer_size: LOGGER.warning('Discarding measurement due to buffer size limit') return if not measurement.fields: raise ValueError('Measurement does not contain a field') if measurement.database not in _measurements: _measurements[measurement.database] = [] value = measurement.marshall() _measurements[measurement.database].append(value) if not _timeout: if (_batch_future and _batch_future.done()) or not _batch_future: _start_timeout() _buffer_size = _pending_measurements() if _buffer_size >= _trigger_size: _trigger_batch_write()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:refresh; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reloadData; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:force; 10, False; 11, block; 11, 12; 11, 32; 11, 40; 11, 49; 11, 57; 11, 67; 11, 80; 11, 88; 11, 103; 11, 118; 11, 167; 11, 192; 11, 208; 11, 237; 11, 250; 12, if_statement; 12, 13; 12, 22; 13, not_operator; 13, 14; 14, parenthesized_expression; 14, 15; 15, boolean_operator:or; 15, 16; 15, 21; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:isVisible; 20, argument_list; 21, identifier:force; 22, block; 22, 23; 22, 31; 23, expression_statement; 23, 24; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:_refreshTimer; 29, identifier:start; 30, argument_list; 31, return_statement; 32, if_statement; 32, 33; 32, 38; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:isLoading; 37, argument_list; 38, block; 38, 39; 39, return_statement; 40, if_statement; 40, 41; 40, 42; 41, identifier:reloadData; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:refreshQueryRecords; 48, argument_list; 49, expression_statement; 49, 50; 50, call; 50, 51; 50, 56; 51, attribute; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:_refreshTimer; 55, identifier:stop; 56, argument_list; 57, expression_statement; 57, 58; 58, call; 58, 59; 58, 66; 59, attribute; 59, 60; 59, 65; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:worker; 64, argument_list; 65, identifier:cancel; 66, argument_list; 67, if_statement; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:_popup; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, call; 73, 74; 73, 79; 74, attribute; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:_popup; 78, identifier:close; 79, argument_list; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:currset; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:self; 86, identifier:currentRecordSet; 87, argument_list; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 97; 90, attribute; 90, 91; 90, 96; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:self; 94, identifier:worker; 95, argument_list; 96, identifier:setBatched; 97, argument_list; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:self; 101, identifier:isPaged; 102, argument_list; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 112; 105, attribute; 105, 106; 105, 111; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:worker; 110, argument_list; 111, identifier:setBatchSize; 112, argument_list; 112, 113; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:pageSize; 117, argument_list; 118, if_statement; 118, 119; 118, 122; 118, 134; 118, 158; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:_searchTerms; 122, block; 122, 123; 122, 130; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:currset; 127, identifier:setGroupBy; 128, argument_list; 128, 129; 129, None; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:pageSize; 133, integer:0; 134, elif_clause; 134, 135; 134, 146; 135, boolean_operator:and; 135, 136; 135, 141; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:groupBy; 140, argument_list; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:self; 144, identifier:isGroupingActive; 145, argument_list; 146, block; 146, 147; 147, expression_statement; 147, 148; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:currset; 151, identifier:setGroupBy; 152, argument_list; 152, 153; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:self; 156, identifier:groupBy; 157, argument_list; 158, else_clause; 158, 159; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:currset; 164, identifier:setGroupBy; 165, argument_list; 165, 166; 166, None; 167, if_statement; 167, 168; 167, 173; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:self; 171, identifier:order; 172, argument_list; 173, block; 173, 174; 173, 181; 174, expression_statement; 174, 175; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:currset; 178, identifier:setOrdered; 179, argument_list; 179, 180; 180, True; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:currset; 185, identifier:setOrder; 186, argument_list; 186, 187; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:self; 190, identifier:order; 191, argument_list; 192, if_statement; 192, 193; 192, 198; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:self; 196, identifier:useLoader; 197, argument_list; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 202; 201, identifier:loader; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:XLoaderWidget; 205, identifier:start; 206, argument_list; 206, 207; 207, identifier:self; 208, if_statement; 208, 209; 208, 214; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:self; 212, identifier:specifiedColumnsOnly; 213, argument_list; 214, block; 214, 215; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:currset; 219, identifier:setColumns; 220, argument_list; 220, 221; 221, call; 221, 222; 221, 223; 222, identifier:map; 223, argument_list; 223, 224; 223, 232; 224, lambda; 224, 225; 224, 227; 225, lambda_parameters; 225, 226; 226, identifier:x; 227, call; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:x; 230, identifier:name; 231, argument_list; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:self; 235, identifier:specifiedColumns; 236, argument_list; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:self; 241, identifier:_loadedColumns; 242, call; 242, 243; 242, 244; 243, identifier:set; 244, argument_list; 244, 245; 245, call; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, identifier:self; 248, identifier:visibleColumns; 249, argument_list; 250, if_statement; 250, 251; 250, 262; 250, 285; 251, boolean_operator:and; 251, 252; 251, 257; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:self; 255, identifier:isThreadEnabled; 256, argument_list; 257, call; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:currset; 260, identifier:isThreadEnabled; 261, argument_list; 262, block; 262, 263; 262, 276; 263, expression_statement; 263, 264; 264, call; 264, 265; 264, 272; 265, attribute; 265, 266; 265, 271; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:self; 269, identifier:worker; 270, argument_list; 271, identifier:setPreloadColumns; 272, argument_list; 272, 273; 273, attribute; 273, 274; 273, 275; 274, identifier:self; 275, identifier:_preloadColumns; 276, expression_statement; 276, 277; 277, call; 277, 278; 277, 283; 278, attribute; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:self; 281, identifier:loadRequested; 282, identifier:emit; 283, argument_list; 283, 284; 284, identifier:currset; 285, else_clause; 285, 286; 286, block; 286, 287; 286, 296; 286, 307; 287, expression_statement; 287, 288; 288, call; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:QApplication; 291, identifier:setOverrideCursor; 292, argument_list; 292, 293; 293, attribute; 293, 294; 293, 295; 294, identifier:Qt; 295, identifier:WaitCursor; 296, expression_statement; 296, 297; 297, call; 297, 298; 297, 305; 298, attribute; 298, 299; 298, 304; 299, call; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:self; 302, identifier:worker; 303, argument_list; 304, identifier:loadRecords; 305, argument_list; 305, 306; 306, identifier:currset; 307, expression_statement; 307, 308; 308, call; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:QApplication; 311, identifier:restoreOverrideCursor; 312, argument_list
def refresh(self, reloadData=False, force=False): if not (self.isVisible() or force): self._refreshTimer.start() return if self.isLoading(): return if reloadData: self.refreshQueryRecords() self._refreshTimer.stop() self.worker().cancel() if self._popup: self._popup.close() currset = self.currentRecordSet() self.worker().setBatched(self.isPaged()) self.worker().setBatchSize(self.pageSize()) if self._searchTerms: currset.setGroupBy(None) pageSize = 0 elif self.groupBy() and self.isGroupingActive(): currset.setGroupBy(self.groupBy()) else: currset.setGroupBy(None) if self.order(): currset.setOrdered(True) currset.setOrder(self.order()) if self.useLoader(): loader = XLoaderWidget.start(self) if self.specifiedColumnsOnly(): currset.setColumns(map(lambda x: x.name(), self.specifiedColumns())) self._loadedColumns = set(self.visibleColumns()) if self.isThreadEnabled() and currset.isThreadEnabled(): self.worker().setPreloadColumns(self._preloadColumns) self.loadRequested.emit(currset) else: QApplication.setOverrideCursor(Qt.WaitCursor) self.worker().loadRecords(currset) QApplication.restoreOverrideCursor()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:tornado_run; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:app; 5, default_parameter; 5, 6; 5, 7; 6, identifier:port; 7, integer:5000; 8, default_parameter; 8, 9; 8, 10; 9, identifier:address; 10, string:""; 11, default_parameter; 11, 12; 11, 13; 12, identifier:use_gevent; 13, False; 14, default_parameter; 14, 15; 14, 16; 15, identifier:start; 16, True; 17, default_parameter; 17, 18; 17, 19; 18, identifier:monkey_patch; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:Container; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:Server; 25, None; 26, default_parameter; 26, 27; 26, 28; 27, identifier:threadpool; 28, None; 29, block; 29, 30; 29, 45; 29, 60; 29, 69; 29, 73; 29, 136; 29, 205; 29, 215; 29, 223; 29, 230; 30, if_statement; 30, 31; 30, 34; 31, comparison_operator:is; 31, 32; 31, 33; 32, identifier:Container; 33, None; 34, block; 34, 35; 34, 41; 35, import_from_statement; 35, 36; 35, 39; 36, dotted_name; 36, 37; 36, 38; 37, identifier:tornado; 38, identifier:wsgi; 39, dotted_name; 39, 40; 40, identifier:WSGIContainer; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:Container; 44, identifier:WSGIContainer; 45, if_statement; 45, 46; 45, 49; 46, comparison_operator:is; 46, 47; 46, 48; 47, identifier:Server; 48, None; 49, block; 49, 50; 49, 56; 50, import_from_statement; 50, 51; 50, 54; 51, dotted_name; 51, 52; 51, 53; 52, identifier:tornado; 53, identifier:httpserver; 54, dotted_name; 54, 55; 55, identifier:HTTPServer; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:Server; 59, identifier:HTTPServer; 60, if_statement; 60, 61; 60, 64; 61, comparison_operator:is; 61, 62; 61, 63; 62, identifier:monkey_patch; 63, None; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:monkey_patch; 68, identifier:use_gevent; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:CustomWSGIContainer; 72, identifier:Container; 73, if_statement; 73, 74; 73, 75; 74, identifier:use_gevent; 75, block; 75, 76; 75, 90; 75, 93; 75, 132; 76, if_statement; 76, 77; 76, 78; 77, identifier:monkey_patch; 78, block; 78, 79; 78, 84; 79, import_from_statement; 79, 80; 79, 82; 80, dotted_name; 80, 81; 81, identifier:gevent; 82, dotted_name; 82, 83; 83, identifier:monkey; 84, expression_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:monkey; 88, identifier:patch_all; 89, argument_list; 90, import_statement; 90, 91; 91, dotted_name; 91, 92; 92, identifier:gevent; 93, class_definition; 93, 94; 93, 95; 93, 97; 94, identifier:GeventWSGIContainer; 95, argument_list; 95, 96; 96, identifier:Container; 97, block; 97, 98; 98, function_definition; 98, 99; 98, 100; 98, 106; 99, function_name:__call__; 100, parameters; 100, 101; 100, 102; 100, 104; 101, identifier:self; 102, list_splat_pattern; 102, 103; 103, identifier:args; 104, dictionary_splat_pattern; 104, 105; 105, identifier:kwargs; 106, block; 106, 107; 106, 125; 107, function_definition; 107, 108; 107, 109; 107, 110; 108, function_name:async_task; 109, parameters; 110, block; 110, 111; 111, expression_statement; 111, 112; 112, call; 112, 113; 112, 120; 113, attribute; 113, 114; 113, 119; 114, call; 114, 115; 114, 116; 115, identifier:super; 116, argument_list; 116, 117; 116, 118; 117, identifier:GeventWSGIContainer; 118, identifier:self; 119, identifier:__call__; 120, argument_list; 120, 121; 120, 123; 121, list_splat; 121, 122; 122, identifier:args; 123, dictionary_splat; 123, 124; 124, identifier:kwargs; 125, expression_statement; 125, 126; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:gevent; 129, identifier:spawn; 130, argument_list; 130, 131; 131, identifier:async_task; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:CustomWSGIContainer; 135, identifier:GeventWSGIContainer; 136, if_statement; 136, 137; 136, 140; 137, comparison_operator:is; 137, 138; 137, 139; 138, identifier:threadpool; 139, None; 140, block; 140, 141; 140, 147; 140, 162; 140, 201; 141, import_from_statement; 141, 142; 141, 145; 142, dotted_name; 142, 143; 142, 144; 143, identifier:multiprocessing; 144, identifier:pool; 145, dotted_name; 145, 146; 146, identifier:ThreadPool; 147, if_statement; 147, 148; 147, 154; 148, not_operator; 148, 149; 149, call; 149, 150; 149, 151; 150, identifier:isinstance; 151, argument_list; 151, 152; 151, 153; 152, identifier:threadpool; 153, identifier:ThreadPool; 154, block; 154, 155; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:threadpool; 158, call; 158, 159; 158, 160; 159, identifier:ThreadPool; 160, argument_list; 160, 161; 161, identifier:threadpool; 162, class_definition; 162, 163; 162, 164; 162, 166; 163, identifier:ThreadPoolWSGIContainer; 164, argument_list; 164, 165; 165, identifier:Container; 166, block; 166, 167; 167, function_definition; 167, 168; 167, 169; 167, 175; 168, function_name:__call__; 169, parameters; 169, 170; 169, 171; 169, 173; 170, identifier:self; 171, list_splat_pattern; 171, 172; 172, identifier:args; 173, dictionary_splat_pattern; 173, 174; 174, identifier:kwargs; 175, block; 175, 176; 175, 194; 176, function_definition; 176, 177; 176, 178; 176, 179; 177, function_name:async_task; 178, parameters; 179, block; 179, 180; 180, expression_statement; 180, 181; 181, call; 181, 182; 181, 189; 182, attribute; 182, 183; 182, 188; 183, call; 183, 184; 183, 185; 184, identifier:super; 185, argument_list; 185, 186; 185, 187; 186, identifier:ThreadPoolWSGIContainer; 187, identifier:self; 188, identifier:__call__; 189, argument_list; 189, 190; 189, 192; 190, list_splat; 190, 191; 191, identifier:args; 192, dictionary_splat; 192, 193; 193, identifier:kwargs; 194, expression_statement; 194, 195; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:threadpool; 198, identifier:apply_async; 199, argument_list; 199, 200; 200, identifier:async_task; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:CustomWSGIContainer; 204, identifier:ThreadPoolWSGIContainer; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:http_server; 208, call; 208, 209; 208, 210; 209, identifier:Server; 210, argument_list; 210, 211; 211, call; 211, 212; 211, 213; 212, identifier:CustomWSGIContainer; 213, argument_list; 213, 214; 214, identifier:app; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:http_server; 219, identifier:listen; 220, argument_list; 220, 221; 220, 222; 221, identifier:port; 222, identifier:address; 223, if_statement; 223, 224; 223, 225; 224, identifier:start; 225, block; 225, 226; 226, expression_statement; 226, 227; 227, call; 227, 228; 227, 229; 228, identifier:tornado_start; 229, argument_list; 230, return_statement; 230, 231; 231, identifier:http_server
def tornado_run(app, port=5000, address="", use_gevent=False, start=True, monkey_patch=None, Container=None, Server=None, threadpool=None): if Container is None: from tornado.wsgi import WSGIContainer Container = WSGIContainer if Server is None: from tornado.httpserver import HTTPServer Server = HTTPServer if monkey_patch is None: monkey_patch = use_gevent CustomWSGIContainer = Container if use_gevent: if monkey_patch: from gevent import monkey monkey.patch_all() import gevent class GeventWSGIContainer(Container): def __call__(self, *args, **kwargs): def async_task(): super(GeventWSGIContainer, self).__call__(*args, **kwargs) gevent.spawn(async_task) CustomWSGIContainer = GeventWSGIContainer if threadpool is not None: from multiprocessing.pool import ThreadPool if not isinstance(threadpool, ThreadPool): threadpool = ThreadPool(threadpool) class ThreadPoolWSGIContainer(Container): def __call__(self, *args, **kwargs): def async_task(): super(ThreadPoolWSGIContainer, self).__call__(*args, **kwargs) threadpool.apply_async(async_task) CustomWSGIContainer = ThreadPoolWSGIContainer http_server = Server(CustomWSGIContainer(app)) http_server.listen(port, address) if start: tornado_start() return http_server
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:tornado_combiner; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:configs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_gevent; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, True; 11, default_parameter; 11, 12; 11, 13; 12, identifier:monkey_patch; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:Container; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:Server; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:threadpool; 22, None; 23, block; 23, 24; 23, 28; 23, 37; 23, 54; 23, 80; 23, 148; 23, 155; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:servers; 27, list:[]; 28, if_statement; 28, 29; 28, 32; 29, comparison_operator:is; 29, 30; 29, 31; 30, identifier:monkey_patch; 31, None; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:monkey_patch; 36, identifier:use_gevent; 37, if_statement; 37, 38; 37, 39; 38, identifier:use_gevent; 39, block; 39, 40; 40, if_statement; 40, 41; 40, 42; 41, identifier:monkey_patch; 42, block; 42, 43; 42, 48; 43, import_from_statement; 43, 44; 43, 46; 44, dotted_name; 44, 45; 45, identifier:gevent; 46, dotted_name; 46, 47; 47, identifier:monkey; 48, expression_statement; 48, 49; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:monkey; 52, identifier:patch_all; 53, argument_list; 54, if_statement; 54, 55; 54, 58; 55, comparison_operator:is; 55, 56; 55, 57; 56, identifier:threadpool; 57, None; 58, block; 58, 59; 58, 65; 59, import_from_statement; 59, 60; 59, 63; 60, dotted_name; 60, 61; 60, 62; 61, identifier:multiprocessing; 62, identifier:pool; 63, dotted_name; 63, 64; 64, identifier:ThreadPool; 65, if_statement; 65, 66; 65, 72; 66, not_operator; 66, 67; 67, call; 67, 68; 67, 69; 68, identifier:isinstance; 69, argument_list; 69, 70; 69, 71; 70, identifier:threadpool; 71, identifier:ThreadPool; 72, block; 72, 73; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:threadpool; 76, call; 76, 77; 76, 78; 77, identifier:ThreadPool; 78, argument_list; 78, 79; 79, identifier:threadpool; 80, for_statement; 80, 81; 80, 82; 80, 83; 81, identifier:config; 82, identifier:configs; 83, block; 83, 84; 83, 90; 83, 100; 83, 110; 83, 141; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:app; 87, subscript; 87, 88; 87, 89; 88, identifier:config; 89, string:'app'; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:port; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:config; 96, identifier:get; 97, argument_list; 97, 98; 97, 99; 98, string:'port'; 99, integer:5000; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:address; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:config; 106, identifier:get; 107, argument_list; 107, 108; 107, 109; 108, string:'address'; 109, string:''; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:server; 113, call; 113, 114; 113, 115; 114, identifier:tornado_run; 115, argument_list; 115, 116; 115, 117; 115, 120; 115, 123; 115, 126; 115, 129; 115, 132; 115, 135; 115, 138; 116, identifier:app; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:use_gevent; 119, identifier:use_gevent; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:port; 122, identifier:port; 123, keyword_argument; 123, 124; 123, 125; 124, identifier:monkey_patch; 125, False; 126, keyword_argument; 126, 127; 126, 128; 127, identifier:address; 128, identifier:address; 129, keyword_argument; 129, 130; 129, 131; 130, identifier:start; 131, False; 132, keyword_argument; 132, 133; 132, 134; 133, identifier:Container; 134, identifier:Container; 135, keyword_argument; 135, 136; 135, 137; 136, identifier:Server; 137, identifier:Server; 138, keyword_argument; 138, 139; 138, 140; 139, identifier:threadpool; 140, identifier:threadpool; 141, expression_statement; 141, 142; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:servers; 145, identifier:append; 146, argument_list; 146, 147; 147, identifier:server; 148, if_statement; 148, 149; 148, 150; 149, identifier:start; 150, block; 150, 151; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 154; 153, identifier:tornado_start; 154, argument_list; 155, return_statement; 155, 156; 156, identifier:servers
def tornado_combiner(configs, use_gevent=False, start=True, monkey_patch=None, Container=None, Server=None, threadpool=None): servers = [] if monkey_patch is None: monkey_patch = use_gevent if use_gevent: if monkey_patch: from gevent import monkey monkey.patch_all() if threadpool is not None: from multiprocessing.pool import ThreadPool if not isinstance(threadpool, ThreadPool): threadpool = ThreadPool(threadpool) for config in configs: app = config['app'] port = config.get('port', 5000) address = config.get('address', '') server = tornado_run(app, use_gevent=use_gevent, port=port, monkey_patch=False, address=address, start=False, Container=Container, Server=Server, threadpool=threadpool) servers.append(server) if start: tornado_start() return servers
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:rebuild; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 24; 5, 31; 5, 41; 5, 47; 5, 55; 5, 93; 5, 101; 5, 109; 5, 116; 5, 123; 5, 130; 5, 139; 5, 150; 5, 161; 5, 165; 5, 174; 5, 182; 5, 221; 5, 228; 5, 451; 5, 490; 5, 497; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:navitem; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:currentItem; 13, argument_list; 14, if_statement; 14, 15; 14, 17; 15, parenthesized_expression; 15, 16; 16, identifier:navitem; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:navitem; 22, identifier:initialize; 23, argument_list; 24, expression_statement; 24, 25; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:setUpdatesEnabled; 29, argument_list; 29, 30; 30, False; 31, expression_statement; 31, 32; 32, call; 32, 33; 32, 40; 33, attribute; 33, 34; 33, 39; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:scrollWidget; 38, argument_list; 39, identifier:show; 40, argument_list; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:_originalText; 46, string:''; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:partsw; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:partsWidget; 54, argument_list; 55, for_statement; 55, 56; 55, 57; 55, 64; 56, identifier:button; 57, call; 57, 58; 57, 63; 58, attribute; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:_buttonGroup; 62, identifier:buttons; 63, argument_list; 64, block; 64, 65; 64, 74; 64, 80; 64, 87; 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:self; 70, identifier:_buttonGroup; 71, identifier:removeButton; 72, argument_list; 72, 73; 73, identifier:button; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:button; 78, identifier:close; 79, argument_list; 80, expression_statement; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:button; 84, identifier:setParent; 85, argument_list; 85, 86; 86, None; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:button; 91, identifier:deleteLater; 92, argument_list; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:layout; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:partsw; 99, identifier:layout; 100, argument_list; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:parts; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:self; 107, identifier:parts; 108, argument_list; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:button; 112, call; 112, 113; 112, 114; 113, identifier:QToolButton; 114, argument_list; 114, 115; 115, identifier:partsw; 116, expression_statement; 116, 117; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:button; 120, identifier:setAutoRaise; 121, argument_list; 121, 122; 122, True; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:button; 127, identifier:setMaximumWidth; 128, argument_list; 128, 129; 129, integer:12; 130, expression_statement; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:button; 134, identifier:setArrowType; 135, argument_list; 135, 136; 136, attribute; 136, 137; 136, 138; 137, identifier:Qt; 138, identifier:RightArrow; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:button; 143, identifier:setProperty; 144, argument_list; 144, 145; 144, 146; 145, string:'path'; 146, call; 146, 147; 146, 148; 147, identifier:wrapVariant; 148, argument_list; 148, 149; 149, string:''; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:button; 154, identifier:setProperty; 155, argument_list; 155, 156; 155, 157; 156, string:'is_completer'; 157, call; 157, 158; 157, 159; 158, identifier:wrapVariant; 159, argument_list; 159, 160; 160, True; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:last_button; 164, identifier:button; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 172; 167, attribute; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:_buttonGroup; 171, identifier:addButton; 172, argument_list; 172, 173; 173, identifier:button; 174, expression_statement; 174, 175; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:layout; 178, identifier:insertWidget; 179, argument_list; 179, 180; 179, 181; 180, integer:0; 181, identifier:button; 182, if_statement; 182, 183; 182, 187; 182, 215; 183, parenthesized_expression; 183, 184; 184, attribute; 184, 185; 184, 186; 185, identifier:self; 186, identifier:_navigationModel; 187, block; 187, 188; 187, 203; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 191; 190, identifier:last_item; 191, call; 191, 192; 191, 197; 192, attribute; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:self; 195, identifier:_navigationModel; 196, identifier:itemByPath; 197, argument_list; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:self; 201, identifier:text; 202, argument_list; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:show_last; 206, boolean_operator:and; 206, 207; 206, 208; 207, identifier:last_item; 208, comparison_operator:>; 208, 209; 208, 214; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:last_item; 212, identifier:rowCount; 213, argument_list; 214, integer:0; 215, else_clause; 215, 216; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:show_last; 220, False; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:count; 224, call; 224, 225; 224, 226; 225, identifier:len; 226, argument_list; 226, 227; 227, identifier:parts; 228, for_statement; 228, 229; 228, 232; 228, 236; 229, pattern_list; 229, 230; 229, 231; 230, identifier:i; 231, identifier:part; 232, call; 232, 233; 232, 234; 233, identifier:enumerate; 234, argument_list; 234, 235; 235, identifier:parts; 236, block; 236, 237; 236, 256; 236, 263; 236, 270; 236, 277; 236, 318; 236, 329; 236, 340; 236, 349; 236, 362; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:path; 240, call; 240, 241; 240, 248; 241, attribute; 241, 242; 241, 247; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:self; 245, identifier:separator; 246, argument_list; 247, identifier:join; 248, argument_list; 248, 249; 249, subscript; 249, 250; 249, 251; 250, identifier:parts; 251, slice; 251, 252; 251, 253; 252, colon; 253, binary_operator:+; 253, 254; 253, 255; 254, identifier:i; 255, integer:1; 256, expression_statement; 256, 257; 257, assignment; 257, 258; 257, 259; 258, identifier:button; 259, call; 259, 260; 259, 261; 260, identifier:QToolButton; 261, argument_list; 261, 262; 262, identifier:partsw; 263, expression_statement; 263, 264; 264, call; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:button; 267, identifier:setAutoRaise; 268, argument_list; 268, 269; 269, True; 270, expression_statement; 270, 271; 271, call; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:button; 274, identifier:setText; 275, argument_list; 275, 276; 276, identifier:part; 277, if_statement; 277, 278; 277, 282; 278, parenthesized_expression; 278, 279; 279, attribute; 279, 280; 279, 281; 280, identifier:self; 281, identifier:_navigationModel; 282, block; 282, 283; 282, 294; 283, expression_statement; 283, 284; 284, assignment; 284, 285; 284, 286; 285, identifier:item; 286, call; 286, 287; 286, 292; 287, attribute; 287, 288; 287, 291; 288, attribute; 288, 289; 288, 290; 289, identifier:self; 290, identifier:_navigationModel; 291, identifier:itemByPath; 292, argument_list; 292, 293; 293, identifier:path; 294, if_statement; 294, 295; 294, 297; 295, parenthesized_expression; 295, 296; 296, identifier:item; 297, block; 297, 298; 297, 309; 298, expression_statement; 298, 299; 299, call; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:button; 302, identifier:setIcon; 303, argument_list; 303, 304; 304, call; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:item; 307, identifier:icon; 308, argument_list; 309, expression_statement; 309, 310; 310, call; 310, 311; 310, 314; 311, attribute; 311, 312; 311, 313; 312, identifier:button; 313, identifier:setToolButtonStyle; 314, argument_list; 314, 315; 315, attribute; 315, 316; 315, 317; 316, identifier:Qt; 317, identifier:ToolButtonTextBesideIcon; 318, expression_statement; 318, 319; 319, call; 319, 320; 319, 323; 320, attribute; 320, 321; 320, 322; 321, identifier:button; 322, identifier:setProperty; 323, argument_list; 323, 324; 323, 325; 324, string:'path'; 325, call; 325, 326; 325, 327; 326, identifier:wrapVariant; 327, argument_list; 327, 328; 328, identifier:path; 329, expression_statement; 329, 330; 330, call; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:button; 333, identifier:setProperty; 334, argument_list; 334, 335; 334, 336; 335, string:'is_completer'; 336, call; 336, 337; 336, 338; 337, identifier:wrapVariant; 338, argument_list; 338, 339; 339, False; 340, expression_statement; 340, 341; 341, call; 341, 342; 341, 347; 342, attribute; 342, 343; 342, 346; 343, attribute; 343, 344; 343, 345; 344, identifier:self; 345, identifier:_buttonGroup; 346, identifier:addButton; 347, argument_list; 347, 348; 348, identifier:button; 349, expression_statement; 349, 350; 350, call; 350, 351; 350, 354; 351, attribute; 351, 352; 351, 353; 352, identifier:layout; 353, identifier:insertWidget; 354, argument_list; 354, 355; 354, 361; 355, binary_operator:+; 355, 356; 355, 360; 356, parenthesized_expression; 356, 357; 357, binary_operator:*; 357, 358; 357, 359; 358, identifier:i; 359, integer:2; 360, integer:1; 361, identifier:button; 362, if_statement; 362, 363; 362, 372; 363, parenthesized_expression; 363, 364; 364, boolean_operator:or; 364, 365; 364, 366; 365, identifier:show_last; 366, comparison_operator:<; 366, 367; 366, 368; 367, identifier:i; 368, parenthesized_expression; 368, 369; 369, binary_operator:-; 369, 370; 369, 371; 370, identifier:count; 371, integer:1; 372, block; 372, 373; 372, 380; 372, 387; 372, 394; 372, 403; 372, 414; 372, 425; 372, 434; 372, 447; 373, expression_statement; 373, 374; 374, assignment; 374, 375; 374, 376; 375, identifier:button; 376, call; 376, 377; 376, 378; 377, identifier:QToolButton; 378, argument_list; 378, 379; 379, identifier:partsw; 380, expression_statement; 380, 381; 381, call; 381, 382; 381, 385; 382, attribute; 382, 383; 382, 384; 383, identifier:button; 384, identifier:setAutoRaise; 385, argument_list; 385, 386; 386, True; 387, expression_statement; 387, 388; 388, call; 388, 389; 388, 392; 389, attribute; 389, 390; 389, 391; 390, identifier:button; 391, identifier:setMaximumWidth; 392, argument_list; 392, 393; 393, integer:12; 394, expression_statement; 394, 395; 395, call; 395, 396; 395, 399; 396, attribute; 396, 397; 396, 398; 397, identifier:button; 398, identifier:setArrowType; 399, argument_list; 399, 400; 400, attribute; 400, 401; 400, 402; 401, identifier:Qt; 402, identifier:RightArrow; 403, expression_statement; 403, 404; 404, call; 404, 405; 404, 408; 405, attribute; 405, 406; 405, 407; 406, identifier:button; 407, identifier:setProperty; 408, argument_list; 408, 409; 408, 410; 409, string:'path'; 410, call; 410, 411; 410, 412; 411, identifier:wrapVariant; 412, argument_list; 412, 413; 413, identifier:path; 414, expression_statement; 414, 415; 415, call; 415, 416; 415, 419; 416, attribute; 416, 417; 416, 418; 417, identifier:button; 418, identifier:setProperty; 419, argument_list; 419, 420; 419, 421; 420, string:'is_completer'; 421, call; 421, 422; 421, 423; 422, identifier:wrapVariant; 423, argument_list; 423, 424; 424, True; 425, expression_statement; 425, 426; 426, call; 426, 427; 426, 432; 427, attribute; 427, 428; 427, 431; 428, attribute; 428, 429; 428, 430; 429, identifier:self; 430, identifier:_buttonGroup; 431, identifier:addButton; 432, argument_list; 432, 433; 433, identifier:button; 434, expression_statement; 434, 435; 435, call; 435, 436; 435, 439; 436, attribute; 436, 437; 436, 438; 437, identifier:layout; 438, identifier:insertWidget; 439, argument_list; 439, 440; 439, 446; 440, binary_operator:+; 440, 441; 440, 445; 441, parenthesized_expression; 441, 442; 442, binary_operator:*; 442, 443; 442, 444; 443, identifier:i; 444, integer:2; 445, integer:2; 446, identifier:button; 447, expression_statement; 447, 448; 448, assignment; 448, 449; 448, 450; 449, identifier:last_button; 450, identifier:button; 451, if_statement; 451, 452; 451, 468; 452, parenthesized_expression; 452, 453; 453, comparison_operator:<; 453, 454; 453, 463; 454, call; 454, 455; 454, 462; 455, attribute; 455, 456; 455, 461; 456, call; 456, 457; 456, 460; 457, attribute; 457, 458; 457, 459; 458, identifier:self; 459, identifier:scrollWidget; 460, argument_list; 461, identifier:width; 462, argument_list; 463, call; 463, 464; 463, 467; 464, attribute; 464, 465; 464, 466; 465, identifier:partsw; 466, identifier:width; 467, argument_list; 468, block; 468, 469; 469, expression_statement; 469, 470; 470, call; 470, 471; 470, 474; 471, attribute; 471, 472; 471, 473; 472, identifier:self; 473, identifier:scrollParts; 474, argument_list; 474, 475; 475, binary_operator:-; 475, 476; 475, 481; 476, call; 476, 477; 476, 480; 477, attribute; 477, 478; 477, 479; 478, identifier:partsw; 479, identifier:width; 480, argument_list; 481, call; 481, 482; 481, 489; 482, attribute; 482, 483; 482, 488; 483, call; 483, 484; 483, 487; 484, attribute; 484, 485; 484, 486; 485, identifier:self; 486, identifier:scrollWidget; 487, argument_list; 488, identifier:width; 489, argument_list; 490, expression_statement; 490, 491; 491, call; 491, 492; 491, 495; 492, attribute; 492, 493; 492, 494; 493, identifier:self; 494, identifier:setUpdatesEnabled; 495, argument_list; 495, 496; 496, True; 497, expression_statement; 497, 498; 498, call; 498, 499; 498, 504; 499, attribute; 499, 500; 499, 503; 500, attribute; 500, 501; 500, 502; 501, identifier:self; 502, identifier:navigationChanged; 503, identifier:emit; 504, argument_list
def rebuild( self ): navitem = self.currentItem() if ( navitem ): navitem.initialize() self.setUpdatesEnabled(False) self.scrollWidget().show() self._originalText = '' partsw = self.partsWidget() for button in self._buttonGroup.buttons(): self._buttonGroup.removeButton(button) button.close() button.setParent(None) button.deleteLater() layout = partsw.layout() parts = self.parts() button = QToolButton(partsw) button.setAutoRaise(True) button.setMaximumWidth(12) button.setArrowType(Qt.RightArrow) button.setProperty('path', wrapVariant('')) button.setProperty('is_completer', wrapVariant(True)) last_button = button self._buttonGroup.addButton(button) layout.insertWidget(0, button) if ( self._navigationModel ): last_item = self._navigationModel.itemByPath(self.text()) show_last = last_item and last_item.rowCount() > 0 else: show_last = False count = len(parts) for i, part in enumerate(parts): path = self.separator().join(parts[:i+1]) button = QToolButton(partsw) button.setAutoRaise(True) button.setText(part) if ( self._navigationModel ): item = self._navigationModel.itemByPath(path) if ( item ): button.setIcon(item.icon()) button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) button.setProperty('path', wrapVariant(path)) button.setProperty('is_completer', wrapVariant(False)) self._buttonGroup.addButton(button) layout.insertWidget((i * 2) + 1, button) if ( show_last or i < (count - 1) ): button = QToolButton(partsw) button.setAutoRaise(True) button.setMaximumWidth(12) button.setArrowType(Qt.RightArrow) button.setProperty('path', wrapVariant(path)) button.setProperty('is_completer', wrapVariant(True)) self._buttonGroup.addButton(button) layout.insertWidget((i * 2) + 2, button) last_button = button if ( self.scrollWidget().width() < partsw.width() ): self.scrollParts(partsw.width() - self.scrollWidget().width()) self.setUpdatesEnabled(True) self.navigationChanged.emit()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:syncView; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:recursive; 7, False; 8, block; 8, 9; 8, 17; 8, 25; 8, 30; 8, 38; 8, 46; 8, 54; 8, 68; 8, 80; 8, 85; 8, 102; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:gantt; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:ganttWidget; 16, argument_list; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:tree; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:treeWidget; 24, argument_list; 25, if_statement; 25, 26; 25, 28; 26, not_operator; 26, 27; 27, identifier:gantt; 28, block; 28, 29; 29, return_statement; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:vwidget; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:gantt; 36, identifier:viewWidget; 37, argument_list; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:scene; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:vwidget; 44, identifier:scene; 45, argument_list; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:cell_w; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:gantt; 52, identifier:cellWidth; 53, argument_list; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:tree_offset_y; 57, binary_operator:+; 57, 58; 57, 67; 58, call; 58, 59; 58, 66; 59, attribute; 59, 60; 59, 65; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:tree; 63, identifier:header; 64, argument_list; 65, identifier:height; 66, argument_list; 67, integer:1; 68, expression_statement; 68, 69; 69, augmented_assignment:+=; 69, 70; 69, 71; 70, identifier:tree_offset_y; 71, call; 71, 72; 71, 79; 72, attribute; 72, 73; 72, 78; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:tree; 76, identifier:verticalScrollBar; 77, argument_list; 78, identifier:value; 79, argument_list; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:items; 83, list:[self]; 83, 84; 84, identifier:self; 85, if_statement; 85, 86; 85, 87; 86, identifier:recursive; 87, block; 87, 88; 88, expression_statement; 88, 89; 89, augmented_assignment:+=; 89, 90; 89, 91; 90, identifier:items; 91, call; 91, 92; 91, 93; 92, identifier:list; 93, argument_list; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:children; 98, argument_list; 98, 99; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:recursive; 101, True; 102, for_statement; 102, 103; 102, 104; 102, 105; 103, identifier:item; 104, identifier:items; 105, block; 105, 106; 105, 114; 105, 129; 105, 146; 105, 152; 105, 161; 105, 171; 105, 179; 105, 195; 105, 424; 105, 432; 105, 439; 105, 447; 105, 457; 105, 464; 105, 470; 105, 476; 105, 493; 105, 500; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:vitem; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:item; 112, identifier:viewItem; 113, argument_list; 114, if_statement; 114, 115; 114, 121; 115, not_operator; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:vitem; 119, identifier:scene; 120, argument_list; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:scene; 126, identifier:addItem; 127, argument_list; 127, 128; 128, identifier:vitem; 129, if_statement; 129, 130; 129, 138; 130, boolean_operator:or; 130, 131; 130, 136; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:item; 134, identifier:isHidden; 135, argument_list; 136, not_operator; 136, 137; 137, identifier:tree; 138, block; 138, 139; 138, 145; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:vitem; 143, identifier:hide; 144, argument_list; 145, continue_statement; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:vitem; 150, identifier:show; 151, argument_list; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:tree_rect; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:tree; 158, identifier:visualItemRect; 159, argument_list; 159, 160; 160, identifier:item; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:tree_y; 164, binary_operator:+; 164, 165; 164, 170; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:tree_rect; 168, identifier:y; 169, argument_list; 170, identifier:tree_offset_y; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:tree_h; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:tree_rect; 177, identifier:height; 178, argument_list; 179, if_statement; 179, 180; 179, 187; 180, comparison_operator:==; 180, 181; 180, 186; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:tree_rect; 184, identifier:height; 185, argument_list; 186, integer:0; 187, block; 187, 188; 187, 194; 188, expression_statement; 188, 189; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:vitem; 192, identifier:hide; 193, argument_list; 194, continue_statement; 195, if_statement; 195, 196; 195, 218; 195, 259; 196, comparison_operator:in; 196, 197; 196, 202; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:gantt; 200, identifier:timescale; 201, argument_list; 202, tuple; 202, 203; 202, 208; 202, 213; 203, attribute; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:gantt; 206, identifier:Timescale; 207, identifier:Minute; 208, attribute; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:gantt; 211, identifier:Timescale; 212, identifier:Hour; 213, attribute; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:gantt; 216, identifier:Timescale; 217, identifier:Day; 218, block; 218, 219; 218, 227; 218, 235; 218, 244; 218, 253; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 222; 221, identifier:dstart; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:item; 225, identifier:dateTimeStart; 226, argument_list; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:dend; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:item; 233, identifier:dateTimeEnd; 234, argument_list; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:view_x; 238, call; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:scene; 241, identifier:datetimeXPos; 242, argument_list; 242, 243; 243, identifier:dstart; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 247; 246, identifier:view_r; 247, call; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:scene; 250, identifier:datetimeXPos; 251, argument_list; 251, 252; 252, identifier:dend; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 256; 255, identifier:view_w; 256, binary_operator:-; 256, 257; 256, 258; 257, identifier:view_r; 258, identifier:view_x; 259, else_clause; 259, 260; 260, block; 260, 261; 260, 274; 260, 284; 261, expression_statement; 261, 262; 262, assignment; 262, 263; 262, 264; 263, identifier:view_x; 264, call; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:scene; 267, identifier:dateXPos; 268, argument_list; 268, 269; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:item; 272, identifier:dateStart; 273, argument_list; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:view_w; 277, binary_operator:*; 277, 278; 277, 283; 278, call; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:item; 281, identifier:duration; 282, argument_list; 283, identifier:cell_w; 284, if_statement; 284, 285; 284, 291; 285, not_operator; 285, 286; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:item; 289, identifier:isAllDay; 290, argument_list; 291, block; 291, 292; 291, 300; 291, 308; 291, 321; 291, 332; 291, 341; 291, 353; 291, 361; 291, 374; 291, 385; 291, 396; 291, 409; 291, 413; 291, 417; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 295; 294, identifier:full_day; 295, binary_operator:*; 295, 296; 295, 299; 296, binary_operator:*; 296, 297; 296, 298; 297, integer:24; 298, integer:60; 299, integer:60; 300, expression_statement; 300, 301; 301, assignment; 301, 302; 301, 303; 302, identifier:start; 303, call; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, identifier:item; 306, identifier:timeStart; 307, argument_list; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:start_day; 311, parenthesized_expression; 311, 312; 312, binary_operator:*; 312, 313; 312, 320; 313, binary_operator:*; 313, 314; 313, 319; 314, call; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:start; 317, identifier:hour; 318, argument_list; 319, integer:60; 320, integer:60; 321, expression_statement; 321, 322; 322, augmented_assignment:+=; 322, 323; 322, 324; 323, identifier:start_day; 324, parenthesized_expression; 324, 325; 325, binary_operator:*; 325, 326; 325, 331; 326, call; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:start; 329, identifier:minute; 330, argument_list; 331, integer:60; 332, expression_statement; 332, 333; 333, augmented_assignment:+=; 333, 334; 333, 335; 334, identifier:start_day; 335, parenthesized_expression; 335, 336; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:start; 339, identifier:second; 340, argument_list; 341, expression_statement; 341, 342; 342, assignment; 342, 343; 342, 344; 343, identifier:offset_start; 344, binary_operator:*; 344, 345; 344, 352; 345, parenthesized_expression; 345, 346; 346, binary_operator:/; 346, 347; 346, 348; 347, identifier:start_day; 348, call; 348, 349; 348, 350; 349, identifier:float; 350, argument_list; 350, 351; 351, identifier:full_day; 352, identifier:cell_w; 353, expression_statement; 353, 354; 354, assignment; 354, 355; 354, 356; 355, identifier:end; 356, call; 356, 357; 356, 360; 357, attribute; 357, 358; 357, 359; 358, identifier:item; 359, identifier:timeEnd; 360, argument_list; 361, expression_statement; 361, 362; 362, assignment; 362, 363; 362, 364; 363, identifier:end_day; 364, parenthesized_expression; 364, 365; 365, binary_operator:*; 365, 366; 365, 373; 366, binary_operator:*; 366, 367; 366, 372; 367, call; 367, 368; 367, 371; 368, attribute; 368, 369; 368, 370; 369, identifier:end; 370, identifier:hour; 371, argument_list; 372, integer:60; 373, integer:60; 374, expression_statement; 374, 375; 375, augmented_assignment:+=; 375, 376; 375, 377; 376, identifier:end_day; 377, parenthesized_expression; 377, 378; 378, binary_operator:*; 378, 379; 378, 384; 379, call; 379, 380; 379, 383; 380, attribute; 380, 381; 380, 382; 381, identifier:start; 382, identifier:minute; 383, argument_list; 384, integer:60; 385, expression_statement; 385, 386; 386, augmented_assignment:+=; 386, 387; 386, 388; 387, identifier:end_day; 388, parenthesized_expression; 388, 389; 389, binary_operator:+; 389, 390; 389, 395; 390, call; 390, 391; 390, 394; 391, attribute; 391, 392; 391, 393; 392, identifier:start; 393, identifier:second; 394, argument_list; 395, integer:1; 396, expression_statement; 396, 397; 397, assignment; 397, 398; 397, 399; 398, identifier:offset_end; 399, parenthesized_expression; 399, 400; 400, binary_operator:/; 400, 401; 400, 405; 401, parenthesized_expression; 401, 402; 402, binary_operator:-; 402, 403; 402, 404; 403, identifier:full_day; 404, identifier:end_day; 405, call; 405, 406; 405, 407; 406, identifier:float; 407, argument_list; 407, 408; 408, identifier:full_day; 409, expression_statement; 409, 410; 410, augmented_assignment:*=; 410, 411; 410, 412; 411, identifier:offset_end; 412, identifier:cell_w; 413, expression_statement; 413, 414; 414, augmented_assignment:+=; 414, 415; 414, 416; 415, identifier:view_x; 416, identifier:offset_start; 417, expression_statement; 417, 418; 418, augmented_assignment:-=; 418, 419; 418, 420; 419, identifier:view_w; 420, parenthesized_expression; 420, 421; 421, binary_operator:+; 421, 422; 421, 423; 422, identifier:offset_start; 423, identifier:offset_end; 424, expression_statement; 424, 425; 425, assignment; 425, 426; 425, 427; 426, identifier:view_w; 427, call; 427, 428; 427, 429; 428, identifier:max; 429, argument_list; 429, 430; 429, 431; 430, identifier:view_w; 431, integer:5; 432, expression_statement; 432, 433; 433, call; 433, 434; 433, 437; 434, attribute; 434, 435; 434, 436; 435, identifier:vitem; 436, identifier:setSyncing; 437, argument_list; 437, 438; 438, True; 439, expression_statement; 439, 440; 440, call; 440, 441; 440, 444; 441, attribute; 441, 442; 441, 443; 442, identifier:vitem; 443, identifier:setPos; 444, argument_list; 444, 445; 444, 446; 445, identifier:view_x; 446, identifier:tree_y; 447, expression_statement; 447, 448; 448, call; 448, 449; 448, 452; 449, attribute; 449, 450; 449, 451; 450, identifier:vitem; 451, identifier:setRect; 452, argument_list; 452, 453; 452, 454; 452, 455; 452, 456; 453, integer:0; 454, integer:0; 455, identifier:view_w; 456, identifier:tree_h; 457, expression_statement; 457, 458; 458, call; 458, 459; 458, 462; 459, attribute; 459, 460; 459, 461; 460, identifier:vitem; 461, identifier:setSyncing; 462, argument_list; 462, 463; 463, False; 464, expression_statement; 464, 465; 465, assignment; 465, 466; 465, 467; 466, identifier:flags; 467, attribute; 467, 468; 467, 469; 468, identifier:vitem; 469, identifier:ItemIsSelectable; 470, expression_statement; 470, 471; 471, augmented_assignment:|=; 471, 472; 471, 473; 472, identifier:flags; 473, attribute; 473, 474; 473, 475; 474, identifier:vitem; 475, identifier:ItemIsFocusable; 476, if_statement; 476, 477; 476, 486; 477, binary_operator:&; 477, 478; 477, 483; 478, call; 478, 479; 478, 482; 479, attribute; 479, 480; 479, 481; 480, identifier:item; 481, identifier:flags; 482, argument_list; 483, attribute; 483, 484; 483, 485; 484, identifier:Qt; 485, identifier:ItemIsEditable; 486, block; 486, 487; 487, expression_statement; 487, 488; 488, augmented_assignment:|=; 488, 489; 488, 490; 489, identifier:flags; 490, attribute; 490, 491; 490, 492; 491, identifier:vitem; 492, identifier:ItemIsMovable; 493, expression_statement; 493, 494; 494, call; 494, 495; 494, 498; 495, attribute; 495, 496; 495, 497; 496, identifier:vitem; 497, identifier:setFlags; 498, argument_list; 498, 499; 499, identifier:flags; 500, expression_statement; 500, 501; 501, call; 501, 502; 501, 505; 502, attribute; 502, 503; 502, 504; 503, identifier:item; 504, identifier:syncDependencies; 505, argument_list
def syncView(self, recursive=False): gantt = self.ganttWidget() tree = self.treeWidget() if not gantt: return vwidget = gantt.viewWidget() scene = vwidget.scene() cell_w = gantt.cellWidth() tree_offset_y = tree.header().height() + 1 tree_offset_y += tree.verticalScrollBar().value() items = [self] if recursive: items += list(self.children(recursive=True)) for item in items: vitem = item.viewItem() if not vitem.scene(): scene.addItem(vitem) if item.isHidden() or not tree: vitem.hide() continue vitem.show() tree_rect = tree.visualItemRect(item) tree_y = tree_rect.y() + tree_offset_y tree_h = tree_rect.height() if tree_rect.height() == 0: vitem.hide() continue if gantt.timescale() in (gantt.Timescale.Minute, gantt.Timescale.Hour, gantt.Timescale.Day): dstart = item.dateTimeStart() dend = item.dateTimeEnd() view_x = scene.datetimeXPos(dstart) view_r = scene.datetimeXPos(dend) view_w = view_r - view_x else: view_x = scene.dateXPos(item.dateStart()) view_w = item.duration() * cell_w if not item.isAllDay(): full_day = 24 * 60 * 60 start = item.timeStart() start_day = (start.hour() * 60 * 60) start_day += (start.minute() * 60) start_day += (start.second()) offset_start = (start_day / float(full_day)) * cell_w end = item.timeEnd() end_day = (end.hour() * 60 * 60) end_day += (start.minute() * 60) end_day += (start.second() + 1) offset_end = ((full_day - end_day) / float(full_day)) offset_end *= cell_w view_x += offset_start view_w -= (offset_start + offset_end) view_w = max(view_w, 5) vitem.setSyncing(True) vitem.setPos(view_x, tree_y) vitem.setRect(0, 0, view_w, tree_h) vitem.setSyncing(False) flags = vitem.ItemIsSelectable flags |= vitem.ItemIsFocusable if item.flags() & Qt.ItemIsEditable: flags |= vitem.ItemIsMovable vitem.setFlags(flags) item.syncDependencies()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, keyword_separator; 6, default_parameter; 6, 7; 6, 8; 7, identifier:dc; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:near; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:watch; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:consistency; 17, None; 18, block; 18, 19; 18, 29; 18, 50; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:params; 22, dictionary; 22, 23; 22, 26; 23, pair; 23, 24; 23, 25; 24, string:"dc"; 25, identifier:dc; 26, pair; 26, 27; 26, 28; 27, string:"near"; 28, identifier:near; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:response; 32, await; 32, 33; 33, call; 33, 34; 33, 39; 34, attribute; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:_api; 38, identifier:get; 39, argument_list; 39, 40; 39, 41; 39, 44; 39, 47; 40, string:"/v1/catalog/nodes"; 41, keyword_argument; 41, 42; 41, 43; 42, identifier:params; 43, identifier:params; 44, keyword_argument; 44, 45; 44, 46; 45, identifier:watch; 46, identifier:watch; 47, keyword_argument; 47, 48; 47, 49; 48, identifier:consistency; 49, identifier:consistency; 50, return_statement; 50, 51; 51, call; 51, 52; 51, 53; 52, identifier:consul; 53, argument_list; 53, 54; 54, identifier:response
async def nodes(self, *, dc=None, near=None, watch=None, consistency=None): params = {"dc": dc, "near": near} response = await self._api.get("/v1/catalog/nodes", params=params, watch=watch, consistency=consistency) return consul(response)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:keyphrases_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:keyphrases; 5, identifier:texts; 6, default_parameter; 6, 7; 6, 8; 7, identifier:referral_confidence; 8, float:0.6; 9, default_parameter; 9, 10; 9, 11; 10, identifier:relevance_threshold; 11, float:0.25; 12, default_parameter; 12, 13; 12, 14; 13, identifier:support_threshold; 14, integer:1; 15, default_parameter; 15, 16; 15, 17; 16, identifier:similarity_measure; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:synonimizer; 20, None; 21, default_parameter; 21, 22; 21, 23; 22, identifier:language; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:consts; 26, identifier:Language; 27, identifier:ENGLISH; 28, block; 28, 29; 28, 39; 28, 50; 28, 75; 28, 117; 28, 140; 28, 237; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:similarity_measure; 32, boolean_operator:or; 32, 33; 32, 34; 33, identifier:similarity_measure; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:relevance; 37, identifier:ASTRelevanceMeasure; 38, argument_list; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:table; 42, call; 42, 43; 42, 44; 43, identifier:keyphrases_table; 44, argument_list; 44, 45; 44, 46; 44, 47; 44, 48; 44, 49; 45, identifier:keyphrases; 46, identifier:texts; 47, identifier:similarity_measure; 48, identifier:synonimizer; 49, identifier:language; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:keyphrase_texts; 53, dictionary_comprehension; 53, 54; 53, 72; 54, pair; 54, 55; 54, 56; 55, identifier:keyphrase; 56, call; 56, 57; 56, 58; 57, identifier:set; 58, argument_list; 58, 59; 59, list_comprehension; 59, 60; 59, 61; 59, 64; 60, identifier:text; 61, for_in_clause; 61, 62; 61, 63; 62, identifier:text; 63, identifier:texts; 64, if_clause; 64, 65; 65, comparison_operator:>=; 65, 66; 65, 71; 66, subscript; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:table; 69, identifier:keyphrase; 70, identifier:text; 71, identifier:relevance_threshold; 72, for_in_clause; 72, 73; 72, 74; 73, identifier:keyphrase; 74, identifier:keyphrases; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:graph; 78, dictionary; 78, 79; 78, 105; 78, 108; 78, 111; 78, 114; 79, pair; 79, 80; 79, 81; 80, string:"nodes"; 81, list_comprehension; 81, 82; 81, 97; 82, dictionary; 82, 83; 82, 86; 82, 89; 83, pair; 83, 84; 83, 85; 84, string:"id"; 85, identifier:i; 86, pair; 86, 87; 86, 88; 87, string:"label"; 88, identifier:keyphrase; 89, pair; 89, 90; 89, 91; 90, string:"support"; 91, call; 91, 92; 91, 93; 92, identifier:len; 93, argument_list; 93, 94; 94, subscript; 94, 95; 94, 96; 95, identifier:keyphrase_texts; 96, identifier:keyphrase; 97, for_in_clause; 97, 98; 97, 101; 98, pattern_list; 98, 99; 98, 100; 99, identifier:i; 100, identifier:keyphrase; 101, call; 101, 102; 101, 103; 102, identifier:enumerate; 103, argument_list; 103, 104; 104, identifier:keyphrases; 105, pair; 105, 106; 105, 107; 106, string:"edges"; 107, list:[]; 108, pair; 108, 109; 108, 110; 109, string:"referral_confidence"; 110, identifier:referral_confidence; 111, pair; 111, 112; 111, 113; 112, string:"relevance_threshold"; 113, identifier:relevance_threshold; 114, pair; 114, 115; 114, 116; 115, string:"support_threshold"; 116, identifier:support_threshold; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 122; 119, subscript; 119, 120; 119, 121; 120, identifier:graph; 121, string:"nodes"; 122, list_comprehension; 122, 123; 122, 124; 122, 129; 123, identifier:n; 124, for_in_clause; 124, 125; 124, 126; 125, identifier:n; 126, subscript; 126, 127; 126, 128; 127, identifier:graph; 128, string:"nodes"; 129, if_clause; 129, 130; 130, comparison_operator:>=; 130, 131; 130, 139; 131, call; 131, 132; 131, 133; 132, identifier:len; 133, argument_list; 133, 134; 134, subscript; 134, 135; 134, 136; 135, identifier:keyphrase_texts; 136, subscript; 136, 137; 136, 138; 137, identifier:n; 138, string:"label"; 139, identifier:support_threshold; 140, for_statement; 140, 141; 140, 144; 140, 159; 141, pattern_list; 141, 142; 141, 143; 142, identifier:i1; 143, identifier:i2; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:itertools; 147, identifier:permutations; 148, argument_list; 148, 149; 148, 158; 149, call; 149, 150; 149, 151; 150, identifier:range; 151, argument_list; 151, 152; 152, call; 152, 153; 152, 154; 153, identifier:len; 154, argument_list; 154, 155; 155, subscript; 155, 156; 155, 157; 156, identifier:graph; 157, string:"nodes"; 158, integer:2; 159, block; 159, 160; 159, 168; 159, 176; 159, 210; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:node1; 163, subscript; 163, 164; 163, 167; 164, subscript; 164, 165; 164, 166; 165, identifier:graph; 166, string:"nodes"; 167, identifier:i1; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:node2; 171, subscript; 171, 172; 171, 175; 172, subscript; 172, 173; 172, 174; 173, identifier:graph; 174, string:"nodes"; 175, identifier:i2; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:confidence; 179, parenthesized_expression; 179, 180; 180, binary_operator:/; 180, 181; 180, 198; 181, call; 181, 182; 181, 183; 182, identifier:float; 183, argument_list; 183, 184; 184, call; 184, 185; 184, 186; 185, identifier:len; 186, argument_list; 186, 187; 187, binary_operator:&; 187, 188; 187, 193; 188, subscript; 188, 189; 188, 190; 189, identifier:keyphrase_texts; 190, subscript; 190, 191; 190, 192; 191, identifier:node1; 192, string:"label"; 193, subscript; 193, 194; 193, 195; 194, identifier:keyphrase_texts; 195, subscript; 195, 196; 195, 197; 196, identifier:node2; 197, string:"label"; 198, call; 198, 199; 198, 200; 199, identifier:max; 200, argument_list; 200, 201; 200, 209; 201, call; 201, 202; 201, 203; 202, identifier:len; 203, argument_list; 203, 204; 204, subscript; 204, 205; 204, 206; 205, identifier:keyphrase_texts; 206, subscript; 206, 207; 206, 208; 207, identifier:node1; 208, string:"label"; 209, integer:1; 210, if_statement; 210, 211; 210, 214; 211, comparison_operator:>=; 211, 212; 211, 213; 212, identifier:confidence; 213, identifier:referral_confidence; 214, block; 214, 215; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 222; 217, attribute; 217, 218; 217, 221; 218, subscript; 218, 219; 218, 220; 219, identifier:graph; 220, string:"edges"; 221, identifier:append; 222, argument_list; 222, 223; 223, dictionary; 223, 224; 223, 229; 223, 234; 224, pair; 224, 225; 224, 226; 225, string:"source"; 226, subscript; 226, 227; 226, 228; 227, identifier:node1; 228, string:"id"; 229, pair; 229, 230; 229, 231; 230, string:"target"; 231, subscript; 231, 232; 231, 233; 232, identifier:node2; 233, string:"id"; 234, pair; 234, 235; 234, 236; 235, string:"confidence"; 236, identifier:confidence; 237, return_statement; 237, 238; 238, identifier:graph
def keyphrases_graph(keyphrases, texts, referral_confidence=0.6, relevance_threshold=0.25, support_threshold=1, similarity_measure=None, synonimizer=None, language=consts.Language.ENGLISH): similarity_measure = similarity_measure or relevance.ASTRelevanceMeasure() table = keyphrases_table(keyphrases, texts, similarity_measure, synonimizer, language) keyphrase_texts = {keyphrase: set([text for text in texts if table[keyphrase][text] >= relevance_threshold]) for keyphrase in keyphrases} graph = { "nodes": [ { "id": i, "label": keyphrase, "support": len(keyphrase_texts[keyphrase]) } for i, keyphrase in enumerate(keyphrases) ], "edges": [], "referral_confidence": referral_confidence, "relevance_threshold": relevance_threshold, "support_threshold": support_threshold } graph["nodes"] = [n for n in graph["nodes"] if len(keyphrase_texts[n["label"]]) >= support_threshold] for i1, i2 in itertools.permutations(range(len(graph["nodes"])), 2): node1 = graph["nodes"][i1] node2 = graph["nodes"][i2] confidence = (float(len(keyphrase_texts[node1["label"]] & keyphrase_texts[node2["label"]])) / max(len(keyphrase_texts[node1["label"]]), 1)) if confidence >= referral_confidence: graph["edges"].append({ "source": node1["id"], "target": node2["id"], "confidence": confidence }) return graph
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_hm_verify_message_crc_uk; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:thermostat_id; 6, identifier:protocol; 7, identifier:source; 8, identifier:expectedFunction; 9, identifier:expectedLength; 10, identifier:datal; 11, block; 11, 12; 11, 16; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:badresponse; 15, integer:0; 16, if_statement; 16, 17; 16, 22; 16, 442; 17, comparison_operator:==; 17, 18; 17, 19; 18, identifier:protocol; 19, attribute; 19, 20; 19, 21; 20, identifier:constants; 21, identifier:HMV3_ID; 22, block; 22, 23; 22, 36; 22, 49; 22, 55; 22, 64; 22, 102; 22, 108; 22, 114; 22, 120; 22, 129; 22, 135; 22, 141; 22, 178; 22, 210; 22, 247; 22, 279; 22, 320; 22, 352; 22, 391; 22, 430; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:checksum; 26, subscript; 26, 27; 26, 28; 27, identifier:datal; 28, slice; 28, 29; 28, 35; 29, binary_operator:-; 29, 30; 29, 34; 30, call; 30, 31; 30, 32; 31, identifier:len; 32, argument_list; 32, 33; 33, identifier:datal; 34, integer:2; 35, colon; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:rxmsg; 39, subscript; 39, 40; 39, 41; 40, identifier:datal; 41, slice; 41, 42; 41, 43; 42, colon; 43, binary_operator:-; 43, 44; 43, 48; 44, call; 44, 45; 44, 46; 45, identifier:len; 46, argument_list; 46, 47; 47, identifier:datal; 48, integer:2; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:crc; 52, call; 52, 53; 52, 54; 53, identifier:CRC16; 54, argument_list; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:expectedchecksum; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:crc; 61, identifier:run; 62, argument_list; 62, 63; 63, identifier:rxmsg; 64, if_statement; 64, 65; 64, 68; 64, 76; 65, comparison_operator:==; 65, 66; 65, 67; 66, identifier:expectedchecksum; 67, identifier:checksum; 68, block; 68, 69; 69, expression_statement; 69, 70; 70, call; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:logging; 73, identifier:info; 74, argument_list; 74, 75; 75, string:"CRC is correct"; 76, else_clause; 76, 77; 77, block; 77, 78; 77, 85; 77, 89; 77, 98; 78, expression_statement; 78, 79; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:logging; 82, identifier:error; 83, argument_list; 83, 84; 84, string:"CRC is INCORRECT"; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:serror; 88, string:"Incorrect CRC"; 89, expression_statement; 89, 90; 90, call; 90, 91; 90, 96; 91, attribute; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:sys; 94, identifier:stderr; 95, identifier:write; 96, argument_list; 96, 97; 97, identifier:serror; 98, expression_statement; 98, 99; 99, augmented_assignment:+=; 99, 100; 99, 101; 100, identifier:badresponse; 101, integer:1; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:dest_addr; 105, subscript; 105, 106; 105, 107; 106, identifier:datal; 107, integer:0; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:frame_len_l; 111, subscript; 111, 112; 111, 113; 112, identifier:datal; 113, integer:1; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:frame_len_h; 117, subscript; 117, 118; 117, 119; 118, identifier:datal; 119, integer:2; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:frame_len; 123, binary_operator:|; 123, 124; 123, 128; 124, parenthesized_expression; 124, 125; 125, binary_operator:<<; 125, 126; 125, 127; 126, identifier:frame_len_h; 127, integer:8; 128, identifier:frame_len_l; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:source_addr; 132, subscript; 132, 133; 132, 134; 133, identifier:datal; 134, integer:3; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:func_code; 138, subscript; 138, 139; 138, 140; 139, identifier:datal; 140, integer:4; 141, if_statement; 141, 142; 141, 150; 142, parenthesized_expression; 142, 143; 143, boolean_operator:and; 143, 144; 143, 147; 144, comparison_operator:!=; 144, 145; 144, 146; 145, identifier:dest_addr; 146, integer:129; 147, comparison_operator:!=; 147, 148; 147, 149; 148, identifier:dest_addr; 149, integer:160; 150, block; 150, 151; 150, 158; 150, 165; 150, 174; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:logging; 155, identifier:info; 156, argument_list; 156, 157; 157, string:"dest_addr is ILLEGAL"; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:serror; 161, binary_operator:%; 161, 162; 161, 163; 162, string:"Illegal Dest Addr: %s\n"; 163, parenthesized_expression; 163, 164; 164, identifier:dest_addr; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 172; 167, attribute; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:sys; 170, identifier:stderr; 171, identifier:write; 172, argument_list; 172, 173; 173, identifier:serror; 174, expression_statement; 174, 175; 175, augmented_assignment:+=; 175, 176; 175, 177; 176, identifier:badresponse; 177, integer:1; 178, if_statement; 178, 179; 178, 182; 179, comparison_operator:!=; 179, 180; 179, 181; 180, identifier:dest_addr; 181, identifier:thermostat_id; 182, block; 182, 183; 182, 190; 182, 197; 182, 206; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:logging; 187, identifier:info; 188, argument_list; 188, 189; 189, string:"dest_addr is INCORRECT"; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:serror; 193, binary_operator:%; 193, 194; 193, 195; 194, string:"Incorrect Dest Addr: %s\n"; 195, parenthesized_expression; 195, 196; 196, identifier:dest_addr; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 204; 199, attribute; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:sys; 202, identifier:stderr; 203, identifier:write; 204, argument_list; 204, 205; 205, identifier:serror; 206, expression_statement; 206, 207; 207, augmented_assignment:+=; 207, 208; 207, 209; 208, identifier:badresponse; 209, integer:1; 210, if_statement; 210, 211; 210, 219; 211, parenthesized_expression; 211, 212; 212, boolean_operator:or; 212, 213; 212, 216; 213, comparison_operator:<; 213, 214; 213, 215; 214, identifier:source_addr; 215, integer:1; 216, comparison_operator:>; 216, 217; 216, 218; 217, identifier:source_addr; 218, integer:32; 219, block; 219, 220; 219, 227; 219, 234; 219, 243; 220, expression_statement; 220, 221; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:logging; 224, identifier:info; 225, argument_list; 225, 226; 226, string:"source_addr is ILLEGAL"; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:serror; 230, binary_operator:%; 230, 231; 230, 232; 231, string:"Illegal Src Addr: %s\n"; 232, parenthesized_expression; 232, 233; 233, identifier:source_addr; 234, expression_statement; 234, 235; 235, call; 235, 236; 235, 241; 236, attribute; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:sys; 239, identifier:stderr; 240, identifier:write; 241, argument_list; 241, 242; 242, identifier:serror; 243, expression_statement; 243, 244; 244, augmented_assignment:+=; 244, 245; 244, 246; 245, identifier:badresponse; 246, integer:1; 247, if_statement; 247, 248; 247, 251; 248, comparison_operator:!=; 248, 249; 248, 250; 249, identifier:source_addr; 250, identifier:source; 251, block; 251, 252; 251, 259; 251, 266; 251, 275; 252, expression_statement; 252, 253; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:logging; 256, identifier:info; 257, argument_list; 257, 258; 258, string:"source addr is INCORRECT"; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 262; 261, identifier:serror; 262, binary_operator:%; 262, 263; 262, 264; 263, string:"Incorrect Src Addr: %s\n"; 264, parenthesized_expression; 264, 265; 265, identifier:source_addr; 266, expression_statement; 266, 267; 267, call; 267, 268; 267, 273; 268, attribute; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:sys; 271, identifier:stderr; 272, identifier:write; 273, argument_list; 273, 274; 274, identifier:serror; 275, expression_statement; 275, 276; 276, augmented_assignment:+=; 276, 277; 276, 278; 277, identifier:badresponse; 278, integer:1; 279, if_statement; 279, 280; 279, 292; 280, parenthesized_expression; 280, 281; 281, boolean_operator:and; 281, 282; 281, 287; 282, comparison_operator:!=; 282, 283; 282, 284; 283, identifier:func_code; 284, attribute; 284, 285; 284, 286; 285, identifier:constants; 286, identifier:FUNC_WRITE; 287, comparison_operator:!=; 287, 288; 287, 289; 288, identifier:func_code; 289, attribute; 289, 290; 289, 291; 290, identifier:constants; 291, identifier:FUNC_READ; 292, block; 292, 293; 292, 300; 292, 307; 292, 316; 293, expression_statement; 293, 294; 294, call; 294, 295; 294, 298; 295, attribute; 295, 296; 295, 297; 296, identifier:logging; 297, identifier:info; 298, argument_list; 298, 299; 299, string:"Func Code is UNKNWON"; 300, expression_statement; 300, 301; 301, assignment; 301, 302; 301, 303; 302, identifier:serror; 303, binary_operator:%; 303, 304; 303, 305; 304, string:"Unknown Func Code: %s\n"; 305, parenthesized_expression; 305, 306; 306, identifier:func_code; 307, expression_statement; 307, 308; 308, call; 308, 309; 308, 314; 309, attribute; 309, 310; 309, 313; 310, attribute; 310, 311; 310, 312; 311, identifier:sys; 312, identifier:stderr; 313, identifier:write; 314, argument_list; 314, 315; 315, identifier:serror; 316, expression_statement; 316, 317; 317, augmented_assignment:+=; 317, 318; 317, 319; 318, identifier:badresponse; 319, integer:1; 320, if_statement; 320, 321; 320, 324; 321, comparison_operator:!=; 321, 322; 321, 323; 322, identifier:func_code; 323, identifier:expectedFunction; 324, block; 324, 325; 324, 332; 324, 339; 324, 348; 325, expression_statement; 325, 326; 326, call; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:logging; 329, identifier:info; 330, argument_list; 330, 331; 331, string:"Func Code is UNEXPECTED"; 332, expression_statement; 332, 333; 333, assignment; 333, 334; 333, 335; 334, identifier:serror; 335, binary_operator:%; 335, 336; 335, 337; 336, string:"Unexpected Func Code: %s\n"; 337, parenthesized_expression; 337, 338; 338, identifier:func_code; 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:sys; 344, identifier:stderr; 345, identifier:write; 346, argument_list; 346, 347; 347, identifier:serror; 348, expression_statement; 348, 349; 349, augmented_assignment:+=; 349, 350; 349, 351; 350, identifier:badresponse; 351, integer:1; 352, if_statement; 352, 353; 352, 363; 353, parenthesized_expression; 353, 354; 354, boolean_operator:and; 354, 355; 354, 360; 355, comparison_operator:==; 355, 356; 355, 357; 356, identifier:func_code; 357, attribute; 357, 358; 357, 359; 358, identifier:constants; 359, identifier:FUNC_WRITE; 360, comparison_operator:!=; 360, 361; 360, 362; 361, identifier:frame_len; 362, integer:7; 363, block; 363, 364; 363, 371; 363, 378; 363, 387; 364, expression_statement; 364, 365; 365, call; 365, 366; 365, 369; 366, attribute; 366, 367; 366, 368; 367, identifier:logging; 368, identifier:info; 369, argument_list; 369, 370; 370, string:"response length is INCORRECT"; 371, expression_statement; 371, 372; 372, assignment; 372, 373; 372, 374; 373, identifier:serror; 374, binary_operator:%; 374, 375; 374, 376; 375, string:"Incorrect length: %s\n"; 376, parenthesized_expression; 376, 377; 377, identifier:frame_len; 378, expression_statement; 378, 379; 379, call; 379, 380; 379, 385; 380, attribute; 380, 381; 380, 384; 381, attribute; 381, 382; 381, 383; 382, identifier:sys; 383, identifier:stderr; 384, identifier:write; 385, argument_list; 385, 386; 386, identifier:serror; 387, expression_statement; 387, 388; 388, augmented_assignment:+=; 388, 389; 388, 390; 389, identifier:badresponse; 390, integer:1; 391, if_statement; 391, 392; 391, 398; 392, comparison_operator:!=; 392, 393; 392, 397; 393, call; 393, 394; 393, 395; 394, identifier:len; 395, argument_list; 395, 396; 396, identifier:datal; 397, identifier:frame_len; 398, block; 398, 399; 398, 406; 398, 417; 398, 426; 399, expression_statement; 399, 400; 400, call; 400, 401; 400, 404; 401, attribute; 401, 402; 401, 403; 402, identifier:logging; 403, identifier:info; 404, argument_list; 404, 405; 405, string:"response length MISMATCHES header"; 406, expression_statement; 406, 407; 407, assignment; 407, 408; 407, 409; 408, identifier:serror; 409, binary_operator:%; 409, 410; 409, 411; 410, string:"Mismatch length: %s %s\n"; 411, tuple; 411, 412; 411, 416; 412, call; 412, 413; 412, 414; 413, identifier:len; 414, argument_list; 414, 415; 415, identifier:datal; 416, identifier:frame_len; 417, expression_statement; 417, 418; 418, call; 418, 419; 418, 424; 419, attribute; 419, 420; 419, 423; 420, attribute; 420, 421; 420, 422; 421, identifier:sys; 422, identifier:stderr; 423, identifier:write; 424, argument_list; 424, 425; 425, identifier:serror; 426, expression_statement; 426, 427; 427, augmented_assignment:+=; 427, 428; 427, 429; 428, identifier:badresponse; 429, integer:1; 430, if_statement; 430, 431; 430, 435; 430, 438; 431, parenthesized_expression; 431, 432; 432, comparison_operator:==; 432, 433; 432, 434; 433, identifier:badresponse; 434, integer:0; 435, block; 435, 436; 436, return_statement; 436, 437; 437, True; 438, else_clause; 438, 439; 439, block; 439, 440; 440, return_statement; 440, 441; 441, False; 442, else_clause; 442, 443; 443, block; 443, 444; 444, assert_statement; 444, 445; 444, 446; 445, integer:0; 446, binary_operator:%; 446, 447; 446, 448; 447, string:"Un-supported protocol found %s"; 448, identifier:protocol
def _hm_verify_message_crc_uk( self, thermostat_id, protocol, source, expectedFunction, expectedLength, datal ): badresponse = 0 if protocol == constants.HMV3_ID: checksum = datal[len(datal) - 2:] rxmsg = datal[:len(datal) - 2] crc = CRC16() expectedchecksum = crc.run(rxmsg) if expectedchecksum == checksum: logging.info("CRC is correct") else: logging.error("CRC is INCORRECT") serror = "Incorrect CRC" sys.stderr.write(serror) badresponse += 1 dest_addr = datal[0] frame_len_l = datal[1] frame_len_h = datal[2] frame_len = (frame_len_h << 8) | frame_len_l source_addr = datal[3] func_code = datal[4] if (dest_addr != 129 and dest_addr != 160): logging.info("dest_addr is ILLEGAL") serror = "Illegal Dest Addr: %s\n" % (dest_addr) sys.stderr.write(serror) badresponse += 1 if dest_addr != thermostat_id: logging.info("dest_addr is INCORRECT") serror = "Incorrect Dest Addr: %s\n" % (dest_addr) sys.stderr.write(serror) badresponse += 1 if (source_addr < 1 or source_addr > 32): logging.info("source_addr is ILLEGAL") serror = "Illegal Src Addr: %s\n" % (source_addr) sys.stderr.write(serror) badresponse += 1 if source_addr != source: logging.info("source addr is INCORRECT") serror = "Incorrect Src Addr: %s\n" % (source_addr) sys.stderr.write(serror) badresponse += 1 if ( func_code != constants.FUNC_WRITE and func_code != constants.FUNC_READ ): logging.info("Func Code is UNKNWON") serror = "Unknown Func Code: %s\n" % (func_code) sys.stderr.write(serror) badresponse += 1 if func_code != expectedFunction: logging.info("Func Code is UNEXPECTED") serror = "Unexpected Func Code: %s\n" % (func_code) sys.stderr.write(serror) badresponse += 1 if ( func_code == constants.FUNC_WRITE and frame_len != 7 ): logging.info("response length is INCORRECT") serror = "Incorrect length: %s\n" % (frame_len) sys.stderr.write(serror) badresponse += 1 if len(datal) != frame_len: logging.info("response length MISMATCHES header") serror = "Mismatch length: %s %s\n" % (len(datal), frame_len) sys.stderr.write(serror) badresponse += 1 if (badresponse == 0): return True else: return False else: assert 0, "Un-supported protocol found %s" % protocol
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:checks; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:service; 6, keyword_separator; 7, default_parameter; 7, 8; 7, 9; 8, identifier:dc; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:near; 12, None; 13, default_parameter; 13, 14; 13, 15; 14, identifier:watch; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:consistency; 18, None; 19, block; 19, 20; 19, 32; 19, 42; 19, 64; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:service_id; 23, call; 23, 24; 23, 25; 24, identifier:extract_attr; 25, argument_list; 25, 26; 25, 27; 26, identifier:service; 27, keyword_argument; 27, 28; 27, 29; 28, identifier:keys; 29, list:["ServiceID", "ID"]; 29, 30; 29, 31; 30, string:"ServiceID"; 31, string:"ID"; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:params; 35, dictionary; 35, 36; 35, 39; 36, pair; 36, 37; 36, 38; 37, string:"dc"; 38, identifier:dc; 39, pair; 39, 40; 39, 41; 40, string:"near"; 41, identifier:near; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:response; 45, await; 45, 46; 46, call; 46, 47; 46, 52; 47, attribute; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:_api; 51, identifier:get; 52, argument_list; 52, 53; 52, 54; 52, 55; 52, 58; 52, 61; 53, string:"/v1/health/checks"; 54, identifier:service_id; 55, keyword_argument; 55, 56; 55, 57; 56, identifier:params; 57, identifier:params; 58, keyword_argument; 58, 59; 58, 60; 59, identifier:watch; 60, identifier:watch; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:consistency; 63, identifier:consistency; 64, return_statement; 64, 65; 65, call; 65, 66; 65, 67; 66, identifier:consul; 67, argument_list; 67, 68; 68, identifier:response
async def checks(self, service, *, dc=None, near=None, watch=None, consistency=None): service_id = extract_attr(service, keys=["ServiceID", "ID"]) params = {"dc": dc, "near": near} response = await self._api.get("/v1/health/checks", service_id, params=params, watch=watch, consistency=consistency) return consul(response)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:cap; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 19; 9, 37; 9, 53; 9, 62; 9, 129; 10, if_statement; 10, 11; 10, 16; 11, comparison_operator:in; 11, 12; 11, 13; 12, string:'READTHEDOCS'; 13, attribute; 13, 14; 13, 15; 14, identifier:os; 15, identifier:environ; 16, block; 16, 17; 17, return_statement; 17, 18; 18, string:''; 19, if_statement; 19, 20; 19, 23; 20, comparison_operator:!=; 20, 21; 20, 22; 21, identifier:kwargs; 22, dictionary; 23, block; 23, 24; 24, raise_statement; 24, 25; 25, call; 25, 26; 25, 27; 26, identifier:TypeError; 27, argument_list; 27, 28; 28, binary_operator:%; 28, 29; 28, 30; 29, string:"get(): No such argument %r"; 30, subscript; 30, 31; 30, 36; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:kwargs; 34, identifier:popitem; 35, argument_list; 36, integer:0; 37, if_statement; 37, 38; 37, 41; 38, comparison_operator:==; 38, 39; 38, 40; 39, identifier:_cache; 40, dictionary; 41, block; 41, 42; 42, try_statement; 42, 43; 42, 50; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:curses; 48, identifier:setupterm; 49, argument_list; 50, except_clause; 50, 51; 51, block; 51, 52; 52, pass_statement; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:s; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:_cache; 59, identifier:get; 60, argument_list; 60, 61; 61, identifier:cap; 62, if_statement; 62, 63; 62, 65; 63, not_operator; 63, 64; 64, identifier:s; 65, block; 65, 66; 65, 75; 65, 123; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:s; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:curses; 72, identifier:tigetstr; 73, argument_list; 73, 74; 74, identifier:cap; 75, if_statement; 75, 76; 75, 79; 76, comparison_operator:==; 76, 77; 76, 78; 77, identifier:s; 78, None; 79, block; 79, 80; 79, 89; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:s; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:curses; 86, identifier:tigetnum; 87, argument_list; 87, 88; 88, identifier:cap; 89, if_statement; 89, 90; 89, 94; 90, comparison_operator:==; 90, 91; 90, 92; 91, identifier:s; 92, unary_operator:-; 92, 93; 93, integer:2; 94, block; 94, 95; 94, 104; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:s; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:curses; 101, identifier:tigetflag; 102, argument_list; 102, 103; 103, identifier:cap; 104, if_statement; 104, 105; 104, 109; 104, 114; 105, comparison_operator:==; 105, 106; 105, 107; 106, identifier:s; 107, unary_operator:-; 107, 108; 108, integer:1; 109, block; 109, 110; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:s; 113, string:''; 114, else_clause; 114, 115; 115, block; 115, 116; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:s; 119, call; 119, 120; 119, 121; 120, identifier:bool; 121, argument_list; 121, 122; 122, identifier:s; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 128; 125, subscript; 125, 126; 125, 127; 126, identifier:_cache; 127, identifier:cap; 128, identifier:s; 129, if_statement; 129, 130; 129, 133; 129, 152; 130, boolean_operator:and; 130, 131; 130, 132; 131, identifier:args; 132, identifier:s; 133, block; 133, 134; 133, 145; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:r; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:curses; 140, identifier:tparm; 141, argument_list; 141, 142; 141, 143; 142, identifier:s; 143, list_splat; 143, 144; 144, identifier:args; 145, return_statement; 145, 146; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:r; 149, identifier:decode; 150, argument_list; 150, 151; 151, string:'utf-8'; 152, else_clause; 152, 153; 153, block; 153, 154; 154, if_statement; 154, 155; 154, 160; 154, 168; 155, call; 155, 156; 155, 157; 156, identifier:isinstance; 157, argument_list; 157, 158; 157, 159; 158, identifier:s; 159, identifier:bytes; 160, block; 160, 161; 161, return_statement; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:s; 165, identifier:decode; 166, argument_list; 166, 167; 167, string:'utf-8'; 168, else_clause; 168, 169; 169, block; 169, 170; 170, return_statement; 170, 171; 171, identifier:s
def get(cap, *args, **kwargs): if 'READTHEDOCS' in os.environ: return '' if kwargs != {}: raise TypeError("get(): No such argument %r" % kwargs.popitem()[0]) if _cache == {}: try: curses.setupterm() except: pass s = _cache.get(cap) if not s: s = curses.tigetstr(cap) if s == None: s = curses.tigetnum(cap) if s == -2: s = curses.tigetflag(cap) if s == -1: s = '' else: s = bool(s) _cache[cap] = s if args and s: r = curses.tparm(s, *args) return r.decode('utf-8') else: if isinstance(s, bytes): return s.decode('utf-8') else: return s
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:draw; 3, parameters; 3, 4; 3, 5; 4, identifier:canvas; 5, identifier:mol; 6, block; 6, 7; 6, 14; 6, 22; 6, 31; 6, 71; 6, 233; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:mol; 11, identifier:require; 12, argument_list; 12, 13; 13, string:"ScaleAndCenter"; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:mlb; 17, subscript; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:mol; 20, identifier:size2d; 21, integer:2; 22, if_statement; 22, 23; 22, 29; 23, not_operator; 23, 24; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:mol; 27, identifier:atom_count; 28, argument_list; 29, block; 29, 30; 30, return_statement; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:bond_type_fn; 34, dictionary; 34, 35; 34, 50; 34, 65; 35, pair; 35, 36; 35, 37; 36, integer:1; 37, dictionary; 37, 38; 37, 41; 37, 44; 37, 47; 38, pair; 38, 39; 38, 40; 39, integer:0; 40, identifier:single_bond; 41, pair; 41, 42; 41, 43; 42, integer:1; 43, identifier:wedged_single; 44, pair; 44, 45; 44, 46; 45, integer:2; 46, identifier:dashed_wedged_single; 47, pair; 47, 48; 47, 49; 48, integer:3; 49, identifier:wave_single; 50, pair; 50, 51; 50, 52; 51, integer:2; 52, dictionary; 52, 53; 52, 56; 52, 59; 52, 62; 53, pair; 53, 54; 53, 55; 54, integer:0; 55, identifier:cw_double; 56, pair; 56, 57; 56, 58; 57, integer:1; 58, identifier:counter_cw_double; 59, pair; 59, 60; 59, 61; 60, integer:2; 61, identifier:double_bond; 62, pair; 62, 63; 62, 64; 63, integer:3; 64, identifier:cross_double; 65, pair; 65, 66; 65, 67; 66, integer:3; 67, dictionary; 67, 68; 68, pair; 68, 69; 68, 70; 69, integer:0; 70, identifier:triple_bond; 71, for_statement; 71, 72; 71, 76; 71, 81; 72, pattern_list; 72, 73; 72, 74; 72, 75; 73, identifier:u; 74, identifier:v; 75, identifier:bond; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:mol; 79, identifier:bonds_iter; 80, argument_list; 81, block; 81, 82; 81, 89; 81, 117; 81, 128; 81, 139; 81, 145; 81, 169; 81, 193; 81, 204; 81, 215; 82, if_statement; 82, 83; 82, 87; 83, not_operator; 83, 84; 84, attribute; 84, 85; 84, 86; 85, identifier:bond; 86, identifier:visible; 87, block; 87, 88; 88, continue_statement; 89, if_statement; 89, 90; 89, 98; 89, 107; 90, comparison_operator:==; 90, 91; 90, 95; 91, parenthesized_expression; 91, 92; 92, comparison_operator:<; 92, 93; 92, 94; 93, identifier:u; 94, identifier:v; 95, attribute; 95, 96; 95, 97; 96, identifier:bond; 97, identifier:is_lower_first; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 104; 101, pattern_list; 101, 102; 101, 103; 102, identifier:f; 103, identifier:s; 104, tuple; 104, 105; 104, 106; 105, identifier:u; 106, identifier:v; 107, else_clause; 107, 108; 108, block; 108, 109; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 114; 111, pattern_list; 111, 112; 111, 113; 112, identifier:s; 113, identifier:f; 114, tuple; 114, 115; 114, 116; 115, identifier:u; 116, identifier:v; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:p1; 120, attribute; 120, 121; 120, 127; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:mol; 124, identifier:atom; 125, argument_list; 125, 126; 126, identifier:f; 127, identifier:coords; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:p2; 131, attribute; 131, 132; 131, 138; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:mol; 135, identifier:atom; 136, argument_list; 136, 137; 137, identifier:s; 138, identifier:coords; 139, if_statement; 139, 140; 139, 143; 140, comparison_operator:==; 140, 141; 140, 142; 141, identifier:p1; 142, identifier:p2; 143, block; 143, 144; 144, continue_statement; 145, if_statement; 145, 146; 145, 154; 146, attribute; 146, 147; 146, 153; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:mol; 150, identifier:atom; 151, argument_list; 151, 152; 152, identifier:f; 153, identifier:visible; 154, block; 154, 155; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:p1; 158, subscript; 158, 159; 158, 168; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:gm; 162, identifier:t_seg; 163, argument_list; 163, 164; 163, 165; 163, 166; 163, 167; 164, identifier:p1; 165, identifier:p2; 166, identifier:F_AOVL; 167, integer:2; 168, integer:0; 169, if_statement; 169, 170; 169, 178; 170, attribute; 170, 171; 170, 177; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:mol; 174, identifier:atom; 175, argument_list; 175, 176; 176, identifier:s; 177, identifier:visible; 178, block; 178, 179; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:p2; 182, subscript; 182, 183; 182, 192; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:gm; 186, identifier:t_seg; 187, argument_list; 187, 188; 187, 189; 187, 190; 187, 191; 188, identifier:p1; 189, identifier:p2; 190, identifier:F_AOVL; 191, integer:1; 192, integer:1; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 196; 195, identifier:color1; 196, attribute; 196, 197; 196, 203; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:mol; 200, identifier:atom; 201, argument_list; 201, 202; 202, identifier:f; 203, identifier:color; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 207; 206, identifier:color2; 207, attribute; 207, 208; 207, 214; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:mol; 211, identifier:atom; 212, argument_list; 212, 213; 213, identifier:s; 214, identifier:color; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 226; 217, subscript; 217, 218; 217, 223; 218, subscript; 218, 219; 218, 220; 219, identifier:bond_type_fn; 220, attribute; 220, 221; 220, 222; 221, identifier:bond; 222, identifier:order; 223, attribute; 223, 224; 223, 225; 224, identifier:bond; 225, identifier:type; 226, argument_list; 226, 227; 226, 228; 226, 229; 226, 230; 226, 231; 226, 232; 227, identifier:canvas; 228, identifier:p1; 229, identifier:p2; 230, identifier:color1; 231, identifier:color2; 232, identifier:mlb; 233, for_statement; 233, 234; 233, 237; 233, 242; 234, pattern_list; 234, 235; 234, 236; 235, identifier:n; 236, identifier:atom; 237, call; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:mol; 240, identifier:atoms_iter; 241, argument_list; 242, block; 242, 243; 242, 250; 242, 256; 242, 262; 242, 391; 242, 399; 243, if_statement; 243, 244; 243, 248; 244, not_operator; 244, 245; 245, attribute; 245, 246; 245, 247; 246, identifier:atom; 247, identifier:visible; 248, block; 248, 249; 249, continue_statement; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:p; 253, attribute; 253, 254; 253, 255; 254, identifier:atom; 255, identifier:coords; 256, expression_statement; 256, 257; 257, assignment; 257, 258; 257, 259; 258, identifier:color; 259, attribute; 259, 260; 259, 261; 260, identifier:atom; 261, identifier:color; 262, if_statement; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, identifier:atom; 265, identifier:H_count; 266, block; 266, 267; 266, 271; 266, 283; 266, 333; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:cosnbrs; 270, list:[]; 271, expression_statement; 271, 272; 272, assignment; 272, 273; 272, 274; 273, identifier:hrzn; 274, tuple; 274, 275; 274, 280; 275, binary_operator:+; 275, 276; 275, 279; 276, subscript; 276, 277; 276, 278; 277, identifier:p; 278, integer:0; 279, integer:1; 280, subscript; 280, 281; 280, 282; 281, identifier:p; 282, integer:1; 283, for_statement; 283, 284; 283, 285; 283, 293; 284, identifier:nbr; 285, call; 285, 286; 285, 291; 286, attribute; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:mol; 289, identifier:graph; 290, identifier:neighbors; 291, argument_list; 291, 292; 292, identifier:n; 293, block; 293, 294; 293, 305; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 297; 296, identifier:pnbr; 297, attribute; 297, 298; 297, 304; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:mol; 301, identifier:atom; 302, argument_list; 302, 303; 303, identifier:nbr; 304, identifier:coords; 305, try_statement; 305, 306; 305, 329; 306, block; 306, 307; 307, expression_statement; 307, 308; 308, call; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:cosnbrs; 311, identifier:append; 312, argument_list; 312, 313; 313, binary_operator:/; 313, 314; 313, 322; 314, call; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:gm; 317, identifier:dot_product; 318, argument_list; 318, 319; 318, 320; 318, 321; 319, identifier:hrzn; 320, identifier:pnbr; 321, identifier:p; 322, call; 322, 323; 322, 326; 323, attribute; 323, 324; 323, 325; 324, identifier:gm; 325, identifier:distance; 326, argument_list; 326, 327; 326, 328; 327, identifier:p; 328, identifier:pnbr; 329, except_clause; 329, 330; 329, 331; 330, identifier:ZeroDivisionError; 331, block; 331, 332; 332, pass_statement; 333, if_statement; 333, 334; 333, 343; 333, 364; 334, boolean_operator:or; 334, 335; 334, 337; 335, not_operator; 335, 336; 336, identifier:cosnbrs; 337, comparison_operator:>; 337, 338; 337, 342; 338, call; 338, 339; 338, 340; 339, identifier:min; 340, argument_list; 340, 341; 341, identifier:cosnbrs; 342, integer:0; 343, block; 343, 344; 343, 353; 343, 363; 344, expression_statement; 344, 345; 345, assignment; 345, 346; 345, 347; 346, identifier:text; 347, call; 347, 348; 347, 351; 348, attribute; 348, 349; 348, 350; 349, identifier:atom; 350, identifier:formula_html; 351, argument_list; 351, 352; 352, True; 353, expression_statement; 353, 354; 354, call; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:canvas; 357, identifier:draw_text; 358, argument_list; 358, 359; 358, 360; 358, 361; 358, 362; 359, identifier:p; 360, identifier:text; 361, identifier:color; 362, string:"right"; 363, continue_statement; 364, elif_clause; 364, 365; 364, 371; 365, comparison_operator:<; 365, 366; 365, 370; 366, call; 366, 367; 366, 368; 367, identifier:max; 368, argument_list; 368, 369; 369, identifier:cosnbrs; 370, integer:0; 371, block; 371, 372; 371, 380; 371, 390; 372, expression_statement; 372, 373; 373, assignment; 373, 374; 373, 375; 374, identifier:text; 375, call; 375, 376; 375, 379; 376, attribute; 376, 377; 376, 378; 377, identifier:atom; 378, identifier:formula_html; 379, argument_list; 380, expression_statement; 380, 381; 381, call; 381, 382; 381, 385; 382, attribute; 382, 383; 382, 384; 383, identifier:canvas; 384, identifier:draw_text; 385, argument_list; 385, 386; 385, 387; 385, 388; 385, 389; 386, identifier:p; 387, identifier:text; 388, identifier:color; 389, string:"left"; 390, continue_statement; 391, expression_statement; 391, 392; 392, assignment; 392, 393; 392, 394; 393, identifier:text; 394, call; 394, 395; 394, 398; 395, attribute; 395, 396; 395, 397; 396, identifier:atom; 397, identifier:formula_html; 398, argument_list; 399, expression_statement; 399, 400; 400, call; 400, 401; 400, 404; 401, attribute; 401, 402; 401, 403; 402, identifier:canvas; 403, identifier:draw_text; 404, argument_list; 404, 405; 404, 406; 404, 407; 404, 408; 405, identifier:p; 406, identifier:text; 407, identifier:color; 408, string:"center"
def draw(canvas, mol): mol.require("ScaleAndCenter") mlb = mol.size2d[2] if not mol.atom_count(): return bond_type_fn = { 1: { 0: single_bond, 1: wedged_single, 2: dashed_wedged_single, 3: wave_single, }, 2: { 0: cw_double, 1: counter_cw_double, 2: double_bond, 3: cross_double }, 3: { 0: triple_bond } } for u, v, bond in mol.bonds_iter(): if not bond.visible: continue if (u < v) == bond.is_lower_first: f, s = (u, v) else: s, f = (u, v) p1 = mol.atom(f).coords p2 = mol.atom(s).coords if p1 == p2: continue if mol.atom(f).visible: p1 = gm.t_seg(p1, p2, F_AOVL, 2)[0] if mol.atom(s).visible: p2 = gm.t_seg(p1, p2, F_AOVL, 1)[1] color1 = mol.atom(f).color color2 = mol.atom(s).color bond_type_fn[bond.order][bond.type]( canvas, p1, p2, color1, color2, mlb) for n, atom in mol.atoms_iter(): if not atom.visible: continue p = atom.coords color = atom.color if atom.H_count: cosnbrs = [] hrzn = (p[0] + 1, p[1]) for nbr in mol.graph.neighbors(n): pnbr = mol.atom(nbr).coords try: cosnbrs.append(gm.dot_product(hrzn, pnbr, p) / gm.distance(p, pnbr)) except ZeroDivisionError: pass if not cosnbrs or min(cosnbrs) > 0: text = atom.formula_html(True) canvas.draw_text(p, text, color, "right") continue elif max(cosnbrs) < 0: text = atom.formula_html() canvas.draw_text(p, text, color, "left") continue text = atom.formula_html() canvas.draw_text(p, text, color, "center")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:salm2map; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:salm; 5, identifier:s; 6, identifier:lmax; 7, identifier:Ntheta; 8, identifier:Nphi; 9, block; 9, 10; 9, 32; 9, 59; 9, 64; 9, 78; 9, 106; 9, 131; 9, 231; 10, if_statement; 10, 11; 10, 18; 11, boolean_operator:or; 11, 12; 11, 15; 12, comparison_operator:<; 12, 13; 12, 14; 13, identifier:Ntheta; 14, integer:2; 15, comparison_operator:<; 15, 16; 15, 17; 16, identifier:Nphi; 17, integer:1; 18, block; 18, 19; 19, raise_statement; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:ValueError; 22, argument_list; 22, 23; 23, binary_operator:+; 23, 24; 23, 31; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, string:"Input values of Ntheta={0} and Nphi={1} "; 27, identifier:format; 28, argument_list; 28, 29; 28, 30; 29, identifier:Ntheta; 30, identifier:Nphi; 31, string:"are not allowed; they must be greater than 1 and 0, respectively."; 32, if_statement; 32, 33; 32, 36; 33, comparison_operator:<; 33, 34; 33, 35; 34, identifier:lmax; 35, integer:1; 36, block; 36, 37; 37, raise_statement; 37, 38; 38, call; 38, 39; 38, 40; 39, identifier:ValueError; 40, argument_list; 40, 41; 41, binary_operator:+; 41, 42; 41, 50; 42, binary_operator:+; 42, 43; 42, 49; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, string:"Input value of lmax={0} "; 46, identifier:format; 47, argument_list; 47, 48; 48, identifier:lmax; 49, string:"is not allowed; it must be greater than 0 and should be greater "; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, string:"than |s|={0}."; 53, identifier:format; 54, argument_list; 54, 55; 55, call; 55, 56; 55, 57; 56, identifier:abs; 57, argument_list; 57, 58; 58, identifier:s; 59, import_statement; 59, 60; 60, aliased_import; 60, 61; 60, 63; 61, dotted_name; 61, 62; 62, identifier:numpy; 63, identifier:np; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:salm; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:np; 70, identifier:ascontiguousarray; 71, argument_list; 71, 72; 71, 73; 72, identifier:salm; 73, keyword_argument; 73, 74; 73, 75; 74, identifier:dtype; 75, attribute; 75, 76; 75, 77; 76, identifier:np; 77, identifier:complex128; 78, if_statement; 78, 79; 78, 90; 79, comparison_operator:<; 79, 80; 79, 86; 80, subscript; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:salm; 83, identifier:shape; 84, unary_operator:-; 84, 85; 85, integer:1; 86, call; 86, 87; 86, 88; 87, identifier:N_lm; 88, argument_list; 88, 89; 89, identifier:lmax; 90, block; 90, 91; 91, raise_statement; 91, 92; 92, call; 92, 93; 92, 94; 93, identifier:ValueError; 94, argument_list; 94, 95; 95, binary_operator:+; 95, 96; 95, 105; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, string:"The input `salm` array of shape {0} is too small for the stated `lmax` of {1}. "; 99, identifier:format; 100, argument_list; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:salm; 103, identifier:shape; 104, identifier:lmax; 105, string:"Perhaps you forgot to include the (zero) modes with ell<|s|."; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:map; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:np; 112, identifier:empty; 113, argument_list; 113, 114; 113, 126; 114, binary_operator:+; 114, 115; 114, 123; 115, subscript; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:salm; 118, identifier:shape; 119, slice; 119, 120; 119, 121; 120, colon; 121, unary_operator:-; 121, 122; 122, integer:1; 123, tuple; 123, 124; 123, 125; 124, identifier:Ntheta; 125, identifier:Nphi; 126, keyword_argument; 126, 127; 126, 128; 127, identifier:dtype; 128, attribute; 128, 129; 128, 130; 129, identifier:np; 130, identifier:complex128; 131, if_statement; 131, 132; 131, 137; 131, 219; 132, comparison_operator:>; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:salm; 135, identifier:ndim; 136, integer:1; 137, block; 137, 138; 137, 152; 137, 209; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:s; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:np; 144, identifier:ascontiguousarray; 145, argument_list; 145, 146; 145, 147; 146, identifier:s; 147, keyword_argument; 147, 148; 147, 149; 148, identifier:dtype; 149, attribute; 149, 150; 149, 151; 150, identifier:np; 151, identifier:intc; 152, if_statement; 152, 153; 152, 185; 153, boolean_operator:or; 153, 154; 153, 163; 154, comparison_operator:!=; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:s; 157, identifier:ndim; 158, binary_operator:-; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:salm; 161, identifier:ndim; 162, integer:1; 163, comparison_operator:!=; 163, 164; 163, 172; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:np; 167, identifier:product; 168, argument_list; 168, 169; 169, attribute; 169, 170; 169, 171; 170, identifier:s; 171, identifier:shape; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:np; 175, identifier:product; 176, argument_list; 176, 177; 177, subscript; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:salm; 180, identifier:shape; 181, slice; 181, 182; 181, 183; 182, colon; 183, unary_operator:-; 183, 184; 184, integer:1; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:s; 189, binary_operator:*; 189, 190; 189, 191; 190, identifier:s; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:np; 194, identifier:ones; 195, argument_list; 195, 196; 195, 204; 196, subscript; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:salm; 199, identifier:shape; 200, slice; 200, 201; 200, 202; 201, colon; 202, unary_operator:-; 202, 203; 203, integer:1; 204, keyword_argument; 204, 205; 204, 206; 205, identifier:dtype; 206, attribute; 206, 207; 206, 208; 207, identifier:np; 208, identifier:intc; 209, expression_statement; 209, 210; 210, call; 210, 211; 210, 212; 211, identifier:_multi_salm2map; 212, argument_list; 212, 213; 212, 214; 212, 215; 212, 216; 212, 217; 212, 218; 213, identifier:salm; 214, identifier:map; 215, identifier:s; 216, identifier:lmax; 217, identifier:Ntheta; 218, identifier:Nphi; 219, else_clause; 219, 220; 220, block; 220, 221; 221, expression_statement; 221, 222; 222, call; 222, 223; 222, 224; 223, identifier:_salm2map; 224, argument_list; 224, 225; 224, 226; 224, 227; 224, 228; 224, 229; 224, 230; 225, identifier:salm; 226, identifier:map; 227, identifier:s; 228, identifier:lmax; 229, identifier:Ntheta; 230, identifier:Nphi; 231, return_statement; 231, 232; 232, identifier:map
def salm2map(salm, s, lmax, Ntheta, Nphi): if Ntheta < 2 or Nphi < 1: raise ValueError("Input values of Ntheta={0} and Nphi={1} ".format(Ntheta, Nphi) + "are not allowed; they must be greater than 1 and 0, respectively.") if lmax < 1: raise ValueError("Input value of lmax={0} ".format(lmax) + "is not allowed; it must be greater than 0 and should be greater " + "than |s|={0}.".format(abs(s))) import numpy as np salm = np.ascontiguousarray(salm, dtype=np.complex128) if salm.shape[-1] < N_lm(lmax): raise ValueError("The input `salm` array of shape {0} is too small for the stated `lmax` of {1}. ".format(salm.shape, lmax) + "Perhaps you forgot to include the (zero) modes with ell<|s|.") map = np.empty(salm.shape[:-1]+(Ntheta, Nphi), dtype=np.complex128) if salm.ndim>1: s = np.ascontiguousarray(s, dtype=np.intc) if s.ndim != salm.ndim-1 or np.product(s.shape) != np.product(salm.shape[:-1]): s = s*np.ones(salm.shape[:-1], dtype=np.intc) _multi_salm2map(salm, map, s, lmax, Ntheta, Nphi) else: _salm2map(salm, map, s, lmax, Ntheta, Nphi) return map
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:map2salm; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:map; 5, identifier:s; 6, identifier:lmax; 7, block; 7, 8; 7, 13; 7, 27; 7, 54; 7, 150; 8, import_statement; 8, 9; 9, aliased_import; 9, 10; 9, 12; 10, dotted_name; 10, 11; 11, identifier:numpy; 12, identifier:np; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:map; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:np; 19, identifier:ascontiguousarray; 20, argument_list; 20, 21; 20, 22; 21, identifier:map; 22, keyword_argument; 22, 23; 22, 24; 23, identifier:dtype; 24, attribute; 24, 25; 24, 26; 25, identifier:np; 26, identifier:complex128; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:salm; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:np; 33, identifier:empty; 34, argument_list; 34, 35; 34, 49; 35, binary_operator:+; 35, 36; 35, 44; 36, subscript; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:map; 39, identifier:shape; 40, slice; 40, 41; 40, 42; 41, colon; 42, unary_operator:-; 42, 43; 43, integer:2; 44, tuple; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:N_lm; 47, argument_list; 47, 48; 48, identifier:lmax; 49, keyword_argument; 49, 50; 49, 51; 50, identifier:dtype; 51, attribute; 51, 52; 51, 53; 52, identifier:np; 53, identifier:complex128; 54, if_statement; 54, 55; 54, 60; 54, 140; 55, comparison_operator:>; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:map; 58, identifier:ndim; 59, integer:2; 60, block; 60, 61; 60, 75; 60, 132; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:s; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:np; 67, identifier:ascontiguousarray; 68, argument_list; 68, 69; 68, 70; 69, identifier:s; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:dtype; 72, attribute; 72, 73; 72, 74; 73, identifier:np; 74, identifier:intc; 75, if_statement; 75, 76; 75, 108; 76, boolean_operator:or; 76, 77; 76, 86; 77, comparison_operator:!=; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:s; 80, identifier:ndim; 81, binary_operator:-; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:map; 84, identifier:ndim; 85, integer:2; 86, comparison_operator:!=; 86, 87; 86, 95; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:np; 90, identifier:product; 91, argument_list; 91, 92; 92, attribute; 92, 93; 92, 94; 93, identifier:s; 94, identifier:shape; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:np; 98, identifier:product; 99, argument_list; 99, 100; 100, subscript; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:map; 103, identifier:shape; 104, slice; 104, 105; 104, 106; 105, colon; 106, unary_operator:-; 106, 107; 107, integer:2; 108, block; 108, 109; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:s; 112, binary_operator:*; 112, 113; 112, 114; 113, identifier:s; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:np; 117, identifier:ones; 118, argument_list; 118, 119; 118, 127; 119, subscript; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:map; 122, identifier:shape; 123, slice; 123, 124; 123, 125; 124, colon; 125, unary_operator:-; 125, 126; 126, integer:2; 127, keyword_argument; 127, 128; 127, 129; 128, identifier:dtype; 129, attribute; 129, 130; 129, 131; 130, identifier:np; 131, identifier:intc; 132, expression_statement; 132, 133; 133, call; 133, 134; 133, 135; 134, identifier:_multi_map2salm; 135, argument_list; 135, 136; 135, 137; 135, 138; 135, 139; 136, identifier:map; 137, identifier:salm; 138, identifier:s; 139, identifier:lmax; 140, else_clause; 140, 141; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, call; 143, 144; 143, 145; 144, identifier:_map2salm; 145, argument_list; 145, 146; 145, 147; 145, 148; 145, 149; 146, identifier:map; 147, identifier:salm; 148, identifier:s; 149, identifier:lmax; 150, return_statement; 150, 151; 151, identifier:salm
def map2salm(map, s, lmax): import numpy as np map = np.ascontiguousarray(map, dtype=np.complex128) salm = np.empty(map.shape[:-2]+(N_lm(lmax),), dtype=np.complex128) if map.ndim>2: s = np.ascontiguousarray(s, dtype=np.intc) if s.ndim != map.ndim-2 or np.product(s.shape) != np.product(map.shape[:-2]): s = s*np.ones(map.shape[:-2], dtype=np.intc) _multi_map2salm(map, salm, s, lmax) else: _map2salm(map, salm, s, lmax) return salm
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:url; 6, default_parameter; 6, 7; 6, 8; 7, identifier:store_on_error; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:xpath; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:rate_limit; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:log_hits; 17, True; 18, default_parameter; 18, 19; 18, 20; 19, identifier:log_misses; 20, True; 21, block; 21, 22; 21, 334; 22, try_statement; 22, 23; 22, 75; 23, block; 23, 24; 23, 38; 23, 52; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:cached; 27, call; 27, 28; 27, 37; 28, attribute; 28, 29; 28, 36; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:_query; 33, argument_list; 33, 34; 33, 35; 34, identifier:url; 35, identifier:xpath; 36, identifier:one; 37, argument_list; 38, if_statement; 38, 39; 38, 40; 39, identifier:log_hits; 40, block; 40, 41; 41, expression_statement; 41, 42; 42, call; 42, 43; 42, 48; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:config; 46, identifier:logger; 47, identifier:info; 48, argument_list; 48, 49; 49, binary_operator:+; 49, 50; 49, 51; 50, string:"Request cache hit: "; 51, identifier:url; 52, if_statement; 52, 53; 52, 62; 53, comparison_operator:!=; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:cached; 56, identifier:status_code; 57, attribute; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:requests; 60, identifier:codes; 61, identifier:ok; 62, block; 62, 63; 63, raise_statement; 63, 64; 64, call; 64, 65; 64, 66; 65, identifier:RuntimeError; 66, argument_list; 66, 67; 67, binary_operator:+; 67, 68; 67, 69; 68, string:"Cached request returned an error, code "; 69, call; 69, 70; 69, 71; 70, identifier:str; 71, argument_list; 71, 72; 72, attribute; 72, 73; 72, 74; 73, identifier:cached; 74, identifier:status_code; 75, except_clause; 75, 76; 75, 77; 76, identifier:NoResultFound; 77, block; 77, 78; 77, 92; 77, 253; 77, 283; 77, 311; 78, if_statement; 78, 79; 78, 80; 79, identifier:log_misses; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, call; 82, 83; 82, 88; 83, attribute; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:config; 86, identifier:logger; 87, identifier:info; 88, argument_list; 88, 89; 89, binary_operator:+; 89, 90; 89, 91; 90, string:"Request cache miss: "; 91, identifier:url; 92, try_statement; 92, 93; 92, 234; 93, block; 93, 94; 93, 138; 93, 150; 93, 159; 93, 165; 93, 171; 93, 177; 94, if_statement; 94, 95; 94, 104; 95, boolean_operator:and; 95, 96; 95, 99; 96, comparison_operator:is; 96, 97; 96, 98; 97, identifier:rate_limit; 98, None; 99, comparison_operator:is; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:last_query; 103, None; 104, block; 104, 105; 104, 126; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:to_sleep; 108, binary_operator:-; 108, 109; 108, 110; 109, identifier:rate_limit; 110, call; 110, 111; 110, 125; 111, attribute; 111, 112; 111, 124; 112, parenthesized_expression; 112, 113; 113, binary_operator:-; 113, 114; 113, 121; 114, call; 114, 115; 114, 120; 115, attribute; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:datetime; 118, identifier:datetime; 119, identifier:now; 120, argument_list; 121, attribute; 121, 122; 121, 123; 122, identifier:self; 123, identifier:last_query; 124, identifier:total_seconds; 125, argument_list; 126, if_statement; 126, 127; 126, 130; 127, comparison_operator:>; 127, 128; 127, 129; 128, identifier:to_sleep; 129, integer:0; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:time; 135, identifier:sleep; 136, argument_list; 136, 137; 137, identifier:to_sleep; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:last_query; 143, call; 143, 144; 143, 149; 144, attribute; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:datetime; 147, identifier:datetime; 148, identifier:now; 149, argument_list; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:response; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:requests; 156, identifier:get; 157, argument_list; 157, 158; 158, identifier:url; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 162; 161, identifier:status_code; 162, attribute; 162, 163; 162, 164; 163, identifier:response; 164, identifier:status_code; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:content; 168, attribute; 168, 169; 168, 170; 169, identifier:response; 170, identifier:text; 171, expression_statement; 171, 172; 172, call; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:response; 175, identifier:close; 176, argument_list; 177, if_statement; 177, 178; 177, 181; 178, comparison_operator:is; 178, 179; 178, 180; 179, identifier:xpath; 180, None; 181, block; 181, 182; 181, 191; 181, 200; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:doc; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:html; 188, identifier:fromstring; 189, argument_list; 189, 190; 190, identifier:content; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:nodes; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:doc; 197, identifier:xpath; 198, argument_list; 198, 199; 199, identifier:xpath; 200, if_statement; 200, 201; 200, 207; 200, 218; 201, comparison_operator:==; 201, 202; 201, 206; 202, call; 202, 203; 202, 204; 203, identifier:len; 204, argument_list; 204, 205; 205, identifier:nodes; 206, integer:0; 207, block; 207, 208; 207, 214; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 211; 210, identifier:content; 211, binary_operator:+; 211, 212; 211, 213; 212, string:"xpath not found: "; 213, identifier:xpath; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 217; 216, identifier:status_code; 217, identifier:ERROR_XPATH_NOT_FOUND; 218, else_clause; 218, 219; 219, block; 219, 220; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 223; 222, identifier:content; 223, call; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:html; 226, identifier:tostring; 227, argument_list; 227, 228; 227, 231; 228, subscript; 228, 229; 228, 230; 229, identifier:nodes; 230, integer:0; 231, keyword_argument; 231, 232; 231, 233; 232, identifier:encoding; 233, string:'unicode'; 234, except_clause; 234, 235; 234, 241; 235, as_pattern; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:requests; 238, identifier:ConnectionError; 239, as_pattern_target; 239, 240; 240, identifier:e; 241, block; 241, 242; 241, 246; 242, expression_statement; 242, 243; 243, assignment; 243, 244; 243, 245; 244, identifier:status_code; 245, identifier:ERROR_CONNECTION_ERROR; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 249; 248, identifier:content; 249, call; 249, 250; 249, 251; 250, identifier:str; 251, argument_list; 251, 252; 252, identifier:e; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 256; 255, identifier:cached; 256, call; 256, 257; 256, 258; 257, identifier:CachedRequest; 258, argument_list; 258, 259; 258, 265; 258, 268; 258, 271; 258, 274; 259, keyword_argument; 259, 260; 259, 261; 260, identifier:url; 261, call; 261, 262; 261, 263; 262, identifier:str; 263, argument_list; 263, 264; 264, identifier:url; 265, keyword_argument; 265, 266; 265, 267; 266, identifier:content; 267, identifier:content; 268, keyword_argument; 268, 269; 268, 270; 269, identifier:status_code; 270, identifier:status_code; 271, keyword_argument; 271, 272; 271, 273; 272, identifier:xpath; 273, identifier:xpath; 274, keyword_argument; 274, 275; 274, 276; 275, identifier:queried_on; 276, call; 276, 277; 276, 282; 277, attribute; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, identifier:datetime; 280, identifier:datetime; 281, identifier:now; 282, argument_list; 283, if_statement; 283, 284; 283, 293; 284, boolean_operator:or; 284, 285; 284, 292; 285, comparison_operator:==; 285, 286; 285, 287; 286, identifier:status_code; 287, attribute; 287, 288; 287, 291; 288, attribute; 288, 289; 288, 290; 289, identifier:requests; 290, identifier:codes; 291, identifier:ok; 292, identifier:store_on_error; 293, block; 293, 294; 293, 303; 294, expression_statement; 294, 295; 295, call; 295, 296; 295, 301; 296, attribute; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:self; 299, identifier:session; 300, identifier:add; 301, argument_list; 301, 302; 302, identifier:cached; 303, expression_statement; 303, 304; 304, call; 304, 305; 304, 310; 305, attribute; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:self; 308, identifier:session; 309, identifier:commit; 310, argument_list; 311, if_statement; 311, 312; 311, 319; 312, comparison_operator:!=; 312, 313; 312, 314; 313, identifier:status_code; 314, attribute; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:requests; 317, identifier:codes; 318, identifier:ok; 319, block; 319, 320; 320, raise_statement; 320, 321; 321, call; 321, 322; 321, 323; 322, identifier:RuntimeError; 323, argument_list; 323, 324; 324, binary_operator:+; 324, 325; 324, 333; 325, binary_operator:+; 325, 326; 325, 332; 326, binary_operator:+; 326, 327; 326, 328; 327, string:"Error processing the request, "; 328, call; 328, 329; 328, 330; 329, identifier:str; 330, argument_list; 330, 331; 331, identifier:status_code; 332, string:": "; 333, identifier:content; 334, return_statement; 334, 335; 335, attribute; 335, 336; 335, 337; 336, identifier:cached; 337, identifier:content
def get(self, url, store_on_error=False, xpath=None, rate_limit=None, log_hits=True, log_misses=True): try: cached = self._query(url, xpath).one() if log_hits: config.logger.info("Request cache hit: " + url) if cached.status_code != requests.codes.ok: raise RuntimeError("Cached request returned an error, code " + str(cached.status_code)) except NoResultFound: if log_misses: config.logger.info("Request cache miss: " + url) try: if rate_limit is not None and self.last_query is not None: to_sleep = rate_limit - (datetime.datetime.now() - self.last_query).total_seconds() if to_sleep > 0: time.sleep(to_sleep) self.last_query = datetime.datetime.now() response = requests.get(url) status_code = response.status_code content = response.text response.close() if xpath is not None: doc = html.fromstring(content) nodes = doc.xpath(xpath) if len(nodes) == 0: content = "xpath not found: " + xpath status_code = ERROR_XPATH_NOT_FOUND else: content = html.tostring(nodes[0], encoding='unicode') except requests.ConnectionError as e: status_code = ERROR_CONNECTION_ERROR content = str(e) cached = CachedRequest(url=str(url), content=content, status_code=status_code, xpath=xpath, queried_on=datetime.datetime.now()) if status_code == requests.codes.ok or store_on_error: self.session.add(cached) self.session.commit() if status_code != requests.codes.ok: raise RuntimeError("Error processing the request, " + str(status_code) + ": " + content) return cached.content
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:event; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:event_data; 6, default_parameter; 6, 7; 6, 8; 7, identifier:priority; 8, string:"normal"; 9, default_parameter; 9, 10; 9, 11; 10, identifier:event_method; 11, string:"EVENT"; 12, block; 12, 13; 12, 25; 12, 33; 12, 60; 12, 75; 12, 104; 12, 144; 12, 168; 12, 187; 12, 198; 12, 219; 12, 234; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:logger; 17, identifier:debug; 18, argument_list; 18, 19; 19, binary_operator:+; 19, 20; 19, 21; 20, string:"event: "; 21, call; 21, 22; 21, 23; 22, identifier:str; 23, argument_list; 23, 24; 24, identifier:event_data; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:euuid; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:uuid; 31, identifier:uuid1; 32, argument_list; 33, expression_statement; 33, 34; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:logger; 37, identifier:debug; 38, argument_list; 38, 39; 39, binary_operator:%; 39, 40; 39, 43; 40, concatenated_string; 40, 41; 40, 42; 41, string:"<%s> <euuid:%s> Sending event data to server: "; 42, string:"%s"; 43, tuple; 43, 44; 43, 50; 43, 54; 44, call; 44, 45; 44, 46; 45, identifier:str; 46, argument_list; 46, 47; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:cuuid; 50, call; 50, 51; 50, 52; 51, identifier:str; 52, argument_list; 52, 53; 53, identifier:euuid; 54, call; 54, 55; 54, 56; 55, identifier:str; 56, argument_list; 56, 57; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:server; 60, if_statement; 60, 61; 60, 67; 61, not_operator; 61, 62; 62, attribute; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:listener; 66, identifier:listening; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:logger; 72, identifier:warning; 73, argument_list; 73, 74; 74, string:"Neteria client is not listening."; 75, if_statement; 75, 76; 75, 80; 76, not_operator; 76, 77; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:registered; 80, block; 80, 81; 80, 102; 81, expression_statement; 81, 82; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:logger; 85, identifier:warning; 86, argument_list; 86, 87; 87, binary_operator:%; 87, 88; 87, 91; 88, concatenated_string; 88, 89; 88, 90; 89, string:"<%s> <euuid:%s> Client is currently not registered. "; 90, string:"Event not sent."; 91, tuple; 91, 92; 91, 98; 92, call; 92, 93; 92, 94; 93, identifier:str; 94, argument_list; 94, 95; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:cuuid; 98, call; 98, 99; 98, 100; 99, identifier:str; 100, argument_list; 100, 101; 101, identifier:euuid; 102, return_statement; 102, 103; 103, False; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:packet; 107, dictionary; 107, 108; 107, 111; 107, 119; 107, 125; 107, 128; 107, 138; 107, 141; 108, pair; 108, 109; 108, 110; 109, string:"method"; 110, identifier:event_method; 111, pair; 111, 112; 111, 113; 112, string:"cuuid"; 113, call; 113, 114; 113, 115; 114, identifier:str; 115, argument_list; 115, 116; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:cuuid; 119, pair; 119, 120; 119, 121; 120, string:"euuid"; 121, call; 121, 122; 121, 123; 122, identifier:str; 123, argument_list; 123, 124; 124, identifier:euuid; 125, pair; 125, 126; 125, 127; 126, string:"event_data"; 127, identifier:event_data; 128, pair; 128, 129; 128, 130; 129, string:"timestamp"; 130, call; 130, 131; 130, 132; 131, identifier:str; 132, argument_list; 132, 133; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:datetime; 136, identifier:now; 137, argument_list; 138, pair; 138, 139; 138, 140; 139, string:"retry"; 140, integer:0; 141, pair; 141, 142; 141, 143; 142, string:"priority"; 143, identifier:priority; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 151; 146, attribute; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:self; 149, identifier:listener; 150, identifier:send_datagram; 151, argument_list; 151, 152; 151, 165; 152, call; 152, 153; 152, 154; 153, identifier:serialize_data; 154, argument_list; 154, 155; 154, 156; 154, 159; 154, 162; 155, identifier:packet; 156, attribute; 156, 157; 156, 158; 157, identifier:self; 158, identifier:compression; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:encryption; 162, attribute; 162, 163; 162, 164; 163, identifier:self; 164, identifier:server_key; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:server; 168, expression_statement; 168, 169; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:logger; 172, identifier:debug; 173, argument_list; 173, 174; 174, binary_operator:%; 174, 175; 174, 176; 175, string:"<%s> Sending EVENT Packet: %s"; 176, tuple; 176, 177; 176, 183; 177, call; 177, 178; 177, 179; 178, identifier:str; 179, argument_list; 179, 180; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:cuuid; 183, call; 183, 184; 183, 185; 184, identifier:pformat; 185, argument_list; 185, 186; 186, identifier:packet; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 197; 189, subscript; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:self; 192, identifier:event_uuids; 193, call; 193, 194; 193, 195; 194, identifier:str; 195, argument_list; 195, 196; 196, identifier:euuid; 197, identifier:packet; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:logger; 202, identifier:debug; 203, argument_list; 203, 204; 204, binary_operator:%; 204, 205; 204, 206; 205, string:"<%s> Scheduling retry in %s seconds"; 206, tuple; 206, 207; 206, 213; 207, call; 207, 208; 207, 209; 208, identifier:str; 209, argument_list; 209, 210; 210, attribute; 210, 211; 210, 212; 211, identifier:self; 212, identifier:cuuid; 213, call; 213, 214; 213, 215; 214, identifier:str; 215, argument_list; 215, 216; 216, attribute; 216, 217; 216, 218; 217, identifier:self; 218, identifier:timeout; 219, expression_statement; 219, 220; 220, call; 220, 221; 220, 226; 221, attribute; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:self; 224, identifier:listener; 225, identifier:call_later; 226, argument_list; 226, 227; 226, 230; 226, 233; 227, attribute; 227, 228; 227, 229; 228, identifier:self; 229, identifier:timeout; 230, attribute; 230, 231; 230, 232; 231, identifier:self; 232, identifier:retransmit; 233, identifier:packet; 234, return_statement; 234, 235; 235, identifier:euuid
def event(self, event_data, priority="normal", event_method="EVENT"): logger.debug("event: " + str(event_data)) euuid = uuid.uuid1() logger.debug("<%s> <euuid:%s> Sending event data to server: " "%s" % (str(self.cuuid), str(euuid), str(self.server))) if not self.listener.listening: logger.warning("Neteria client is not listening.") if not self.registered: logger.warning("<%s> <euuid:%s> Client is currently not registered. " "Event not sent." % (str(self.cuuid), str(euuid))) return False packet = {"method": event_method, "cuuid": str(self.cuuid), "euuid": str(euuid), "event_data": event_data, "timestamp": str(datetime.now()), "retry": 0, "priority": priority} self.listener.send_datagram( serialize_data(packet, self.compression, self.encryption, self.server_key), self.server) logger.debug("<%s> Sending EVENT Packet: %s" % (str(self.cuuid), pformat(packet))) self.event_uuids[str(euuid)] = packet logger.debug("<%s> Scheduling retry in %s seconds" % (str(self.cuuid), str(self.timeout))) self.listener.call_later(self.timeout, self.retransmit, packet) return euuid
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 11; 5, 31; 5, 53; 5, 68; 5, 78; 5, 84; 5, 90; 5, 217; 5, 221; 5, 234; 5, 346; 5, 355; 5, 363; 6, import_statement; 6, 7; 7, aliased_import; 7, 8; 7, 10; 8, dotted_name; 8, 9; 9, identifier:numpy; 10, identifier:np; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:query; 14, call; 14, 15; 14, 20; 15, attribute; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:session; 19, identifier:query; 20, argument_list; 20, 21; 20, 26; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:models; 24, identifier:NUTS2Region; 25, identifier:key; 26, attribute; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:models; 29, identifier:NUTS2Region; 30, identifier:id; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:region_ids; 34, call; 34, 35; 34, 52; 35, attribute; 35, 36; 35, 51; 36, subscript; 36, 37; 36, 50; 37, call; 37, 38; 37, 48; 38, attribute; 38, 39; 38, 47; 39, call; 39, 40; 39, 45; 40, attribute; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:client; 44, identifier:df_query; 45, argument_list; 45, 46; 46, identifier:query; 47, identifier:set_index; 48, argument_list; 48, 49; 49, string:'key'; 50, string:'id'; 51, identifier:to_dict; 52, argument_list; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:data; 56, call; 56, 57; 56, 67; 57, attribute; 57, 58; 57, 66; 58, call; 58, 59; 58, 60; 59, identifier:next; 60, argument_list; 60, 61; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:requires; 65, argument_list; 66, identifier:load; 67, argument_list; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:nuts; 71, call; 71, 72; 71, 77; 72, attribute; 72, 73; 72, 76; 73, call; 73, 74; 73, 75; 74, identifier:NUTS2GeoJSONInputFile; 75, argument_list; 76, identifier:load; 77, argument_list; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:indicator_ids; 81, call; 81, 82; 81, 83; 82, identifier:dict; 83, argument_list; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:t_data; 87, call; 87, 88; 87, 89; 88, identifier:dict; 89, argument_list; 90, for_statement; 90, 91; 90, 94; 90, 99; 91, pattern_list; 91, 92; 91, 93; 92, identifier:season; 93, identifier:suffix; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:CLIMATE_SEASON_SUFFIXES; 97, identifier:items; 98, argument_list; 99, block; 99, 100; 99, 115; 99, 124; 99, 132; 99, 140; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:indicator; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:models; 106, identifier:ClimateIndicator; 107, argument_list; 107, 108; 108, keyword_argument; 108, 109; 108, 110; 109, identifier:description; 110, binary_operator:+; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:description; 114, identifier:suffix; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 122; 117, attribute; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:self; 120, identifier:session; 121, identifier:add; 122, argument_list; 122, 123; 123, identifier:indicator; 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:self; 129, identifier:session; 130, identifier:commit; 131, argument_list; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 137; 134, subscript; 134, 135; 134, 136; 135, identifier:indicator_ids; 136, identifier:season; 137, attribute; 137, 138; 137, 139; 138, identifier:indicator; 139, identifier:id; 140, if_statement; 140, 141; 140, 144; 140, 172; 141, comparison_operator:==; 141, 142; 141, 143; 142, identifier:season; 143, string:'summer'; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:t_data; 149, identifier:season; 150, call; 150, 151; 150, 156; 151, attribute; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:np; 154, identifier:ma; 155, identifier:average; 156, argument_list; 156, 157; 156, 169; 157, subscript; 157, 158; 157, 161; 157, 165; 157, 167; 158, subscript; 158, 159; 158, 160; 159, identifier:data; 160, string:'data'; 161, slice; 161, 162; 161, 163; 161, 164; 162, integer:3; 163, colon; 164, integer:9; 165, slice; 165, 166; 166, colon; 167, slice; 167, 168; 168, colon; 169, keyword_argument; 169, 170; 169, 171; 170, identifier:axis; 171, integer:0; 172, else_clause; 172, 173; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 179; 176, subscript; 176, 177; 176, 178; 177, identifier:t_data; 178, identifier:season; 179, call; 179, 180; 179, 185; 180, attribute; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:np; 183, identifier:ma; 184, identifier:average; 185, argument_list; 185, 186; 185, 214; 186, binary_operator:*; 186, 187; 186, 188; 187, float:0.5; 188, parenthesized_expression; 188, 189; 189, binary_operator:+; 189, 190; 189, 202; 190, subscript; 190, 191; 190, 194; 190, 198; 190, 200; 191, subscript; 191, 192; 191, 193; 192, identifier:data; 193, string:'data'; 194, slice; 194, 195; 194, 196; 194, 197; 195, integer:0; 196, colon; 197, integer:3; 198, slice; 198, 199; 199, colon; 200, slice; 200, 201; 201, colon; 202, subscript; 202, 203; 202, 206; 202, 210; 202, 212; 203, subscript; 203, 204; 203, 205; 204, identifier:data; 205, string:'data'; 206, slice; 206, 207; 206, 208; 206, 209; 207, integer:9; 208, colon; 209, integer:12; 210, slice; 210, 211; 211, colon; 212, slice; 212, 213; 213, colon; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:axis; 216, integer:0; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:objects; 220, list:[]; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:current_value_id; 224, call; 224, 225; 224, 230; 225, attribute; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:models; 228, identifier:ClimateValue; 229, identifier:get_max_id; 230, argument_list; 230, 231; 231, attribute; 231, 232; 231, 233; 232, identifier:self; 233, identifier:session; 234, for_statement; 234, 235; 234, 236; 234, 237; 235, identifier:feature; 236, identifier:nuts; 237, block; 237, 238; 237, 264; 238, expression_statement; 238, 239; 239, assignment; 239, 240; 239, 241; 240, identifier:mask; 241, call; 241, 242; 241, 243; 242, identifier:geojson_polygon_to_mask; 243, argument_list; 243, 244; 243, 247; 243, 254; 243, 259; 244, keyword_argument; 244, 245; 244, 246; 245, identifier:feature; 246, identifier:feature; 247, keyword_argument; 247, 248; 247, 249; 248, identifier:shape; 249, attribute; 249, 250; 249, 253; 250, subscript; 250, 251; 250, 252; 251, identifier:t_data; 252, string:'summer'; 253, identifier:shape; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:lat_idx; 256, subscript; 256, 257; 256, 258; 257, identifier:data; 258, string:'lat_idx'; 259, keyword_argument; 259, 260; 259, 261; 260, identifier:lon_idx; 261, subscript; 261, 262; 261, 263; 262, identifier:data; 263, string:'lon_idx'; 264, for_statement; 264, 265; 264, 266; 264, 274; 265, identifier:season; 266, call; 266, 267; 266, 268; 267, identifier:list; 268, argument_list; 268, 269; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:CLIMATE_SEASON_SUFFIXES; 272, identifier:keys; 273, argument_list; 274, block; 274, 275; 274, 291; 274, 305; 274, 317; 274, 321; 275, expression_statement; 275, 276; 276, assignment; 276, 277; 276, 278; 277, identifier:value; 278, call; 278, 279; 278, 284; 279, attribute; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:np; 282, identifier:ma; 283, identifier:average; 284, argument_list; 284, 285; 284, 288; 285, subscript; 285, 286; 285, 287; 286, identifier:t_data; 287, identifier:season; 288, keyword_argument; 288, 289; 288, 290; 289, identifier:weights; 290, identifier:mask; 291, expression_statement; 291, 292; 292, assignment; 292, 293; 292, 294; 293, identifier:region_id; 294, call; 294, 295; 294, 298; 295, attribute; 295, 296; 295, 297; 296, identifier:region_ids; 297, identifier:get; 298, argument_list; 298, 299; 298, 304; 299, subscript; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:feature; 302, identifier:properties; 303, string:'NUTS_ID'; 304, None; 305, if_statement; 305, 306; 305, 309; 306, comparison_operator:is; 306, 307; 306, 308; 307, identifier:region_id; 308, None; 309, block; 309, 310; 310, expression_statement; 310, 311; 311, assignment; 311, 312; 311, 313; 312, identifier:region_id; 313, call; 313, 314; 313, 315; 314, identifier:int; 315, argument_list; 315, 316; 316, identifier:region_id; 317, expression_statement; 317, 318; 318, augmented_assignment:+=; 318, 319; 318, 320; 319, identifier:current_value_id; 320, integer:1; 321, expression_statement; 321, 322; 322, call; 322, 323; 322, 326; 323, attribute; 323, 324; 323, 325; 324, identifier:objects; 325, identifier:append; 326, argument_list; 326, 327; 327, call; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:models; 330, identifier:ClimateValue; 331, argument_list; 331, 332; 331, 335; 331, 338; 331, 341; 332, keyword_argument; 332, 333; 332, 334; 333, identifier:id; 334, identifier:current_value_id; 335, keyword_argument; 335, 336; 335, 337; 336, identifier:value; 337, identifier:value; 338, keyword_argument; 338, 339; 338, 340; 339, identifier:region_id; 340, identifier:region_id; 341, keyword_argument; 341, 342; 341, 343; 342, identifier:indicator_id; 343, subscript; 343, 344; 343, 345; 344, identifier:indicator_ids; 345, identifier:season; 346, expression_statement; 346, 347; 347, call; 347, 348; 347, 353; 348, attribute; 348, 349; 348, 352; 349, attribute; 349, 350; 349, 351; 350, identifier:self; 351, identifier:session; 352, identifier:bulk_save_objects; 353, argument_list; 353, 354; 354, identifier:objects; 355, expression_statement; 355, 356; 356, call; 356, 357; 356, 362; 357, attribute; 357, 358; 357, 361; 358, attribute; 358, 359; 358, 360; 359, identifier:self; 360, identifier:session; 361, identifier:commit; 362, argument_list; 363, expression_statement; 363, 364; 364, call; 364, 365; 364, 368; 365, attribute; 365, 366; 365, 367; 366, identifier:self; 367, identifier:done; 368, argument_list
def run(self): import numpy as np query = self.session.query(models.NUTS2Region.key, models.NUTS2Region.id) region_ids = self.client.df_query(query).set_index('key')['id'].to_dict() data = next(self.requires()).load() nuts = NUTS2GeoJSONInputFile().load() indicator_ids = dict() t_data = dict() for season, suffix in CLIMATE_SEASON_SUFFIXES.items(): indicator = models.ClimateIndicator(description=self.description + suffix) self.session.add(indicator) self.session.commit() indicator_ids[season] = indicator.id if season == 'summer': t_data[season] = np.ma.average(data['data'][3:9, :, :], axis=0) else: t_data[season] = np.ma.average(0.5 * (data['data'][0:3, :, :] + data['data'][9:12, :, :]), axis=0) objects = [] current_value_id = models.ClimateValue.get_max_id(self.session) for feature in nuts: mask = geojson_polygon_to_mask(feature=feature, shape=t_data['summer'].shape, lat_idx=data['lat_idx'], lon_idx=data['lon_idx']) for season in list(CLIMATE_SEASON_SUFFIXES.keys()): value = np.ma.average(t_data[season], weights=mask) region_id = region_ids.get(feature.properties['NUTS_ID'], None) if region_id is not None: region_id = int(region_id) current_value_id += 1 objects.append(models.ClimateValue(id=current_value_id, value=value, region_id=region_id, indicator_id=indicator_ids[season])) self.session.bulk_save_objects(objects) self.session.commit() self.done()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:dapply; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:fn; 6, default_parameter; 6, 7; 6, 8; 7, identifier:pairwise; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:symmetric; 11, True; 12, default_parameter; 12, 13; 12, 14; 13, identifier:diagonal; 14, False; 15, default_parameter; 15, 16; 15, 17; 16, identifier:block; 17, None; 18, dictionary_splat_pattern; 18, 19; 19, identifier:kwargs; 20, block; 20, 21; 20, 48; 20, 57; 20, 73; 20, 77; 20, 220; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:search_keys; 24, list_comprehension; 24, 25; 24, 26; 24, 35; 25, identifier:k; 26, for_in_clause; 26, 27; 26, 30; 27, pattern_list; 27, 28; 27, 29; 28, identifier:k; 29, identifier:v; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:kwargs; 33, identifier:items; 34, argument_list; 35, if_clause; 35, 36; 36, boolean_operator:and; 36, 37; 36, 42; 37, call; 37, 38; 37, 39; 38, identifier:isinstance; 39, argument_list; 39, 40; 39, 41; 40, identifier:v; 41, identifier:list; 42, comparison_operator:>; 42, 43; 42, 47; 43, call; 43, 44; 43, 45; 44, identifier:len; 45, argument_list; 45, 46; 46, identifier:v; 47, integer:1; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:functions; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:util; 54, identifier:make_list; 55, argument_list; 55, 56; 56, identifier:fn; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:search; 60, call; 60, 61; 60, 62; 61, identifier:list; 62, argument_list; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:product; 65, argument_list; 65, 66; 65, 67; 66, identifier:functions; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:util; 70, identifier:dict_product; 71, argument_list; 71, 72; 72, identifier:kwargs; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:results; 76, list:[]; 77, for_statement; 77, 78; 77, 81; 77, 82; 78, pattern_list; 78, 79; 78, 80; 79, identifier:fn; 80, identifier:kw; 81, identifier:search; 82, block; 82, 83; 82, 131; 82, 146; 82, 160; 82, 213; 83, if_statement; 83, 84; 83, 86; 83, 110; 84, not_operator; 84, 85; 85, identifier:pairwise; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:r; 90, call; 90, 91; 90, 100; 91, attribute; 91, 92; 91, 99; 92, call; 92, 93; 92, 98; 93, attribute; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:index; 97, identifier:to_series; 98, argument_list; 99, identifier:apply; 100, argument_list; 100, 101; 101, lambda; 101, 102; 101, 104; 102, lambda_parameters; 102, 103; 103, identifier:step; 104, call; 104, 105; 104, 106; 105, identifier:fn; 106, argument_list; 106, 107; 106, 108; 107, identifier:step; 108, dictionary_splat; 108, 109; 109, identifier:kw; 110, else_clause; 110, 111; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:r; 115, call; 115, 116; 115, 117; 116, identifier:apply_pairwise; 117, argument_list; 117, 118; 117, 119; 117, 120; 117, 123; 117, 126; 117, 129; 118, identifier:self; 119, identifier:fn; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:symmetric; 122, identifier:symmetric; 123, keyword_argument; 123, 124; 123, 125; 124, identifier:diagonal; 125, identifier:diagonal; 126, keyword_argument; 126, 127; 126, 128; 127, identifier:block; 128, identifier:block; 129, dictionary_splat; 129, 130; 130, identifier:kw; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:name; 134, conditional_expression:if; 134, 135; 134, 136; 134, 142; 135, list:[]; 136, comparison_operator:==; 136, 137; 136, 141; 137, call; 137, 138; 137, 139; 138, identifier:len; 139, argument_list; 139, 140; 140, identifier:functions; 141, integer:1; 142, list:[fn.__name__]; 142, 143; 143, attribute; 143, 144; 143, 145; 144, identifier:fn; 145, identifier:__name__; 146, expression_statement; 146, 147; 147, augmented_assignment:+=; 147, 148; 147, 149; 148, identifier:name; 149, call; 149, 150; 149, 159; 150, attribute; 150, 151; 150, 158; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:util; 154, identifier:dict_subset; 155, argument_list; 155, 156; 155, 157; 156, identifier:kw; 157, identifier:search_keys; 158, identifier:values; 159, argument_list; 160, if_statement; 160, 161; 160, 168; 160, 202; 161, call; 161, 162; 161, 163; 162, identifier:isinstance; 163, argument_list; 163, 164; 163, 165; 164, identifier:r; 165, attribute; 165, 166; 165, 167; 166, identifier:pd; 167, identifier:DataFrame; 168, block; 168, 169; 168, 196; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:columns; 172, call; 172, 173; 172, 178; 173, attribute; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:pd; 176, identifier:MultiIndex; 177, identifier:from_tuples; 178, argument_list; 178, 179; 179, list_comprehension; 179, 180; 179, 191; 180, call; 180, 181; 180, 182; 181, identifier:tuple; 182, argument_list; 182, 183; 183, binary_operator:+; 183, 184; 183, 185; 184, identifier:name; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:util; 188, identifier:make_list; 189, argument_list; 189, 190; 190, identifier:c; 191, for_in_clause; 191, 192; 191, 193; 192, identifier:c; 193, attribute; 193, 194; 193, 195; 194, identifier:r; 195, identifier:columns; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:r; 200, identifier:columns; 201, identifier:columns; 202, else_clause; 202, 203; 203, block; 203, 204; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:r; 208, identifier:name; 209, call; 209, 210; 209, 211; 210, identifier:tuple; 211, argument_list; 211, 212; 212, identifier:name; 213, expression_statement; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:results; 217, identifier:append; 218, argument_list; 218, 219; 219, identifier:r; 220, if_statement; 220, 221; 220, 227; 220, 290; 221, comparison_operator:>; 221, 222; 221, 226; 222, call; 222, 223; 222, 224; 223, identifier:len; 224, argument_list; 224, 225; 225, identifier:results; 226, integer:1; 227, block; 227, 228; 227, 240; 227, 253; 227, 257; 227, 277; 227, 285; 228, expression_statement; 228, 229; 229, assignment; 229, 230; 229, 231; 230, identifier:result; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:pd; 234, identifier:concat; 235, argument_list; 235, 236; 235, 237; 236, identifier:results; 237, keyword_argument; 237, 238; 237, 239; 238, identifier:axis; 239, integer:1; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 243; 242, identifier:column_names; 243, conditional_expression:if; 243, 244; 243, 245; 243, 251; 244, list:[]; 245, comparison_operator:==; 245, 246; 245, 250; 246, call; 246, 247; 246, 248; 247, identifier:len; 248, argument_list; 248, 249; 249, identifier:functions; 250, integer:1; 251, list:[None]; 251, 252; 252, None; 253, expression_statement; 253, 254; 254, augmented_assignment:+=; 254, 255; 254, 256; 255, identifier:column_names; 256, identifier:search_keys; 257, expression_statement; 257, 258; 258, augmented_assignment:+=; 258, 259; 258, 260; 259, identifier:column_names; 260, binary_operator:*; 260, 261; 260, 263; 261, list:[None]; 261, 262; 262, None; 263, parenthesized_expression; 263, 264; 264, binary_operator:-; 264, 265; 264, 273; 265, call; 265, 266; 265, 267; 266, identifier:len; 267, argument_list; 267, 268; 268, attribute; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:result; 271, identifier:columns; 272, identifier:names; 273, call; 273, 274; 273, 275; 274, identifier:len; 275, argument_list; 275, 276; 276, identifier:column_names; 277, expression_statement; 277, 278; 278, assignment; 278, 279; 278, 284; 279, attribute; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:result; 282, identifier:columns; 283, identifier:names; 284, identifier:column_names; 285, return_statement; 285, 286; 286, call; 286, 287; 286, 288; 287, identifier:StepFrame; 288, argument_list; 288, 289; 289, identifier:result; 290, else_clause; 290, 291; 291, block; 291, 292; 291, 298; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 295; 294, identifier:result; 295, subscript; 295, 296; 295, 297; 296, identifier:results; 297, integer:0; 298, if_statement; 298, 299; 298, 306; 298, 312; 299, call; 299, 300; 299, 301; 300, identifier:isinstance; 301, argument_list; 301, 302; 301, 303; 302, identifier:result; 303, attribute; 303, 304; 303, 305; 304, identifier:pd; 305, identifier:DataFrame; 306, block; 306, 307; 307, return_statement; 307, 308; 308, call; 308, 309; 308, 310; 309, identifier:StepFrame; 310, argument_list; 310, 311; 311, identifier:result; 312, else_clause; 312, 313; 313, block; 313, 314; 313, 324; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:result; 318, identifier:name; 319, attribute; 319, 320; 319, 323; 320, subscript; 320, 321; 320, 322; 321, identifier:functions; 322, integer:0; 323, identifier:__name__; 324, return_statement; 324, 325; 325, call; 325, 326; 325, 327; 326, identifier:StepSeries; 327, argument_list; 327, 328; 328, identifier:result
def dapply(self, fn, pairwise=False, symmetric=True, diagonal=False, block=None, **kwargs): search_keys = [k for k, v in kwargs.items() if isinstance(v, list) and len(v) > 1] functions = util.make_list(fn) search = list(product(functions, util.dict_product(kwargs))) results = [] for fn, kw in search: if not pairwise: r = self.index.to_series().apply(lambda step: fn(step, **kw)) else: r = apply_pairwise(self, fn, symmetric=symmetric, diagonal=diagonal, block=block, **kw) name = [] if len(functions) == 1 else [fn.__name__] name += util.dict_subset(kw, search_keys).values() if isinstance(r, pd.DataFrame): columns = pd.MultiIndex.from_tuples( [tuple(name + util.make_list(c)) for c in r.columns]) r.columns = columns else: r.name = tuple(name) results.append(r) if len(results) > 1: result = pd.concat(results, axis=1) column_names = [] if len(functions) == 1 else [None] column_names += search_keys column_names += [None]*(len(result.columns.names)-len(column_names)) result.columns.names = column_names return StepFrame(result) else: result = results[0] if isinstance(result, pd.DataFrame): return StepFrame(result) else: result.name = functions[0].__name__ return StepSeries(result)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_identifySuperGraph; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 28; 5, 36; 5, 45; 5, 71; 5, 77; 5, 86; 5, 95; 5, 331; 5, 341; 5, 351; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:debug; 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:sys; 16, identifier:stdout; 17, identifier:write; 18, argument_list; 18, 19; 19, string:"Condensing Graph: "; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:start; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:time; 26, identifier:clock; 27, argument_list; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:G; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:nx; 34, identifier:DiGraph; 35, argument_list; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:G; 40, identifier:add_edges_from; 41, argument_list; 41, 42; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:edges; 45, if_statement; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:short_circuit; 49, block; 49, 50; 49, 60; 49, 70; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:superNodes; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:G; 58, identifier:nodes; 59, argument_list; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:superArcs; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:G; 68, identifier:edges; 69, argument_list; 70, return_statement; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:augmentedEdges; 76, dictionary; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:N; 80, call; 80, 81; 80, 82; 81, identifier:len; 82, argument_list; 82, 83; 83, attribute; 83, 84; 83, 85; 84, identifier:self; 85, identifier:Y; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:processed; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:np; 92, identifier:zeros; 93, argument_list; 93, 94; 94, identifier:N; 95, for_statement; 95, 96; 95, 97; 95, 101; 96, identifier:node; 97, call; 97, 98; 97, 99; 98, identifier:range; 99, argument_list; 99, 100; 100, identifier:N; 101, block; 101, 102; 101, 108; 102, if_statement; 102, 103; 102, 106; 103, subscript; 103, 104; 103, 105; 104, identifier:processed; 105, identifier:node; 106, block; 106, 107; 107, continue_statement; 108, if_statement; 108, 109; 108, 126; 109, boolean_operator:and; 109, 110; 109, 118; 110, comparison_operator:==; 110, 111; 110, 117; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:G; 114, identifier:in_degree; 115, argument_list; 115, 116; 116, identifier:node; 117, integer:1; 118, comparison_operator:==; 118, 119; 118, 125; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:G; 122, identifier:out_degree; 123, argument_list; 123, 124; 124, identifier:node; 125, integer:1; 126, block; 126, 127; 126, 131; 126, 147; 126, 209; 126, 215; 126, 222; 126, 238; 126, 300; 126, 308; 126, 315; 126, 325; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:removedNodes; 130, list:[]; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:lower_link; 134, subscript; 134, 135; 134, 146; 135, subscript; 135, 136; 135, 145; 136, call; 136, 137; 136, 138; 137, identifier:list; 138, argument_list; 138, 139; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:G; 142, identifier:in_edges; 143, argument_list; 143, 144; 144, identifier:node; 145, integer:0; 146, integer:0; 147, while_statement; 147, 148; 147, 166; 148, parenthesized_expression; 148, 149; 149, boolean_operator:and; 149, 150; 149, 158; 150, comparison_operator:==; 150, 151; 150, 157; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:G; 154, identifier:in_degree; 155, argument_list; 155, 156; 156, identifier:lower_link; 157, integer:1; 158, comparison_operator:==; 158, 159; 158, 165; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:G; 162, identifier:out_degree; 163, argument_list; 163, 164; 164, identifier:lower_link; 165, integer:1; 166, block; 166, 167; 166, 183; 166, 191; 166, 198; 166, 205; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:new_lower_link; 170, subscript; 170, 171; 170, 182; 171, subscript; 171, 172; 171, 181; 172, call; 172, 173; 172, 174; 173, identifier:list; 174, argument_list; 174, 175; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:G; 178, identifier:in_edges; 179, argument_list; 179, 180; 180, identifier:lower_link; 181, integer:0; 182, integer:0; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:G; 187, identifier:add_edge; 188, argument_list; 188, 189; 188, 190; 189, identifier:new_lower_link; 190, identifier:node; 191, expression_statement; 191, 192; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:G; 195, identifier:remove_node; 196, argument_list; 196, 197; 197, identifier:lower_link; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:removedNodes; 202, identifier:append; 203, argument_list; 203, 204; 204, identifier:lower_link; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:lower_link; 208, identifier:new_lower_link; 209, expression_statement; 209, 210; 210, call; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:removedNodes; 213, identifier:reverse; 214, argument_list; 215, expression_statement; 215, 216; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:removedNodes; 219, identifier:append; 220, argument_list; 220, 221; 221, identifier:node; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:upper_link; 225, subscript; 225, 226; 225, 237; 226, subscript; 226, 227; 226, 236; 227, call; 227, 228; 227, 229; 228, identifier:list; 229, argument_list; 229, 230; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:G; 233, identifier:out_edges; 234, argument_list; 234, 235; 235, identifier:node; 236, integer:0; 237, integer:1; 238, while_statement; 238, 239; 238, 257; 239, parenthesized_expression; 239, 240; 240, boolean_operator:and; 240, 241; 240, 249; 241, comparison_operator:==; 241, 242; 241, 248; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:G; 245, identifier:in_degree; 246, argument_list; 246, 247; 247, identifier:upper_link; 248, integer:1; 249, comparison_operator:==; 249, 250; 249, 256; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:G; 253, identifier:out_degree; 254, argument_list; 254, 255; 255, identifier:upper_link; 256, integer:1; 257, block; 257, 258; 257, 274; 257, 282; 257, 289; 257, 296; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:new_upper_link; 261, subscript; 261, 262; 261, 273; 262, subscript; 262, 263; 262, 272; 263, call; 263, 264; 263, 265; 264, identifier:list; 265, argument_list; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:G; 269, identifier:out_edges; 270, argument_list; 270, 271; 271, identifier:upper_link; 272, integer:0; 273, integer:1; 274, expression_statement; 274, 275; 275, call; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:G; 278, identifier:add_edge; 279, argument_list; 279, 280; 279, 281; 280, identifier:node; 281, identifier:new_upper_link; 282, expression_statement; 282, 283; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:G; 286, identifier:remove_node; 287, argument_list; 287, 288; 288, identifier:upper_link; 289, expression_statement; 289, 290; 290, call; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:removedNodes; 293, identifier:append; 294, argument_list; 294, 295; 295, identifier:upper_link; 296, expression_statement; 296, 297; 297, assignment; 297, 298; 297, 299; 298, identifier:upper_link; 299, identifier:new_upper_link; 300, expression_statement; 300, 301; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:G; 304, identifier:add_edge; 305, argument_list; 305, 306; 305, 307; 306, identifier:lower_link; 307, identifier:upper_link; 308, expression_statement; 308, 309; 309, call; 309, 310; 309, 313; 310, attribute; 310, 311; 310, 312; 311, identifier:G; 312, identifier:remove_node; 313, argument_list; 313, 314; 314, identifier:node; 315, expression_statement; 315, 316; 316, assignment; 316, 317; 316, 324; 317, subscript; 317, 318; 317, 321; 318, attribute; 318, 319; 318, 320; 319, identifier:self; 320, identifier:augmentedEdges; 321, tuple; 321, 322; 321, 323; 322, identifier:lower_link; 323, identifier:upper_link; 324, identifier:removedNodes; 325, expression_statement; 325, 326; 326, assignment; 326, 327; 326, 330; 327, subscript; 327, 328; 327, 329; 328, identifier:processed; 329, identifier:removedNodes; 330, integer:1; 331, expression_statement; 331, 332; 332, assignment; 332, 333; 332, 336; 333, attribute; 333, 334; 333, 335; 334, identifier:self; 335, identifier:superNodes; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:G; 339, identifier:nodes; 340, argument_list; 341, expression_statement; 341, 342; 342, assignment; 342, 343; 342, 346; 343, attribute; 343, 344; 343, 345; 344, identifier:self; 345, identifier:superArcs; 346, call; 346, 347; 346, 350; 347, attribute; 347, 348; 347, 349; 348, identifier:G; 349, identifier:edges; 350, argument_list; 351, if_statement; 351, 352; 351, 355; 352, attribute; 352, 353; 352, 354; 353, identifier:self; 354, identifier:debug; 355, block; 355, 356; 355, 364; 356, expression_statement; 356, 357; 357, assignment; 357, 358; 357, 359; 358, identifier:end; 359, call; 359, 360; 359, 363; 360, attribute; 360, 361; 360, 362; 361, identifier:time; 362, identifier:clock; 363, argument_list; 364, expression_statement; 364, 365; 365, call; 365, 366; 365, 371; 366, attribute; 366, 367; 366, 370; 367, attribute; 367, 368; 367, 369; 368, identifier:sys; 369, identifier:stdout; 370, identifier:write; 371, argument_list; 371, 372; 372, binary_operator:%; 372, 373; 372, 374; 373, string:"%f s\n"; 374, parenthesized_expression; 374, 375; 375, binary_operator:-; 375, 376; 375, 377; 376, identifier:end; 377, identifier:start
def _identifySuperGraph(self): if self.debug: sys.stdout.write("Condensing Graph: ") start = time.clock() G = nx.DiGraph() G.add_edges_from(self.edges) if self.short_circuit: self.superNodes = G.nodes() self.superArcs = G.edges() return self.augmentedEdges = {} N = len(self.Y) processed = np.zeros(N) for node in range(N): if processed[node]: continue if G.in_degree(node) == 1 and G.out_degree(node) == 1: removedNodes = [] lower_link = list(G.in_edges(node))[0][0] while ( G.in_degree(lower_link) == 1 and G.out_degree(lower_link) == 1 ): new_lower_link = list(G.in_edges(lower_link))[0][0] G.add_edge(new_lower_link, node) G.remove_node(lower_link) removedNodes.append(lower_link) lower_link = new_lower_link removedNodes.reverse() removedNodes.append(node) upper_link = list(G.out_edges(node))[0][1] while ( G.in_degree(upper_link) == 1 and G.out_degree(upper_link) == 1 ): new_upper_link = list(G.out_edges(upper_link))[0][1] G.add_edge(node, new_upper_link) G.remove_node(upper_link) removedNodes.append(upper_link) upper_link = new_upper_link G.add_edge(lower_link, upper_link) G.remove_node(node) self.augmentedEdges[(lower_link, upper_link)] = removedNodes processed[removedNodes] = 1 self.superNodes = G.nodes() self.superArcs = G.edges() if self.debug: end = time.clock() sys.stdout.write("%f s\n" % (end - start))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_construct_nx_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:thisTree; 6, default_parameter; 6, 7; 6, 8; 7, identifier:thatTree; 8, None; 9, block; 9, 10; 9, 32; 9, 40; 9, 49; 9, 53; 9, 68; 9, 175; 9, 202; 10, if_statement; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:debug; 14, block; 14, 15; 14, 24; 15, expression_statement; 15, 16; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:sys; 20, identifier:stdout; 21, identifier:write; 22, argument_list; 22, 23; 23, string:"Networkx Tree construction: "; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:start; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:time; 30, identifier:clock; 31, argument_list; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:nxTree; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:nx; 38, identifier:DiGraph; 39, argument_list; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:nxTree; 44, identifier:add_edges_from; 45, argument_list; 45, 46; 46, attribute; 46, 47; 46, 48; 47, identifier:thisTree; 48, identifier:edges; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:nodesOfThatTree; 52, list:[]; 53, if_statement; 53, 54; 53, 57; 54, comparison_operator:is; 54, 55; 54, 56; 55, identifier:thatTree; 56, None; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:nodesOfThatTree; 61, call; 61, 62; 61, 67; 62, attribute; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:thatTree; 65, identifier:nodes; 66, identifier:keys; 67, argument_list; 68, for_statement; 68, 69; 68, 74; 68, 81; 69, pattern_list; 69, 70; 69, 73; 70, tuple_pattern; 70, 71; 70, 72; 71, identifier:superNode; 72, identifier:_; 73, identifier:nodes; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:thisTree; 78, identifier:augmentedEdges; 79, identifier:items; 80, argument_list; 81, block; 81, 82; 81, 94; 81, 117; 81, 125; 81, 129; 81, 137; 81, 162; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:superNodeEdge; 85, call; 85, 86; 85, 87; 86, identifier:list; 87, argument_list; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:nxTree; 91, identifier:out_edges; 92, argument_list; 92, 93; 93, identifier:superNode; 94, if_statement; 94, 95; 94, 101; 95, comparison_operator:>; 95, 96; 95, 100; 96, call; 96, 97; 96, 98; 97, identifier:len; 98, argument_list; 98, 99; 99, identifier:superNodeEdge; 100, integer:1; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:warnings; 106, identifier:warn; 107, argument_list; 107, 108; 108, call; 108, 109; 108, 115; 109, attribute; 109, 110; 109, 114; 110, concatenated_string; 110, 111; 110, 112; 110, 113; 111, string:"The supernode {} should have only a single "; 112, string:"emanating edge. Merge tree is invalidly "; 113, string:"structured"; 114, identifier:format; 115, argument_list; 115, 116; 116, identifier:superNode; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:endNode; 120, subscript; 120, 121; 120, 124; 121, subscript; 121, 122; 121, 123; 122, identifier:superNodeEdge; 123, integer:0; 124, integer:1; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 128; 127, identifier:startNode; 128, identifier:superNode; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:nxTree; 133, identifier:remove_edge; 134, argument_list; 134, 135; 134, 136; 135, identifier:startNode; 136, identifier:endNode; 137, for_statement; 137, 138; 137, 139; 137, 140; 138, identifier:node; 139, identifier:nodes; 140, block; 140, 141; 141, if_statement; 141, 142; 141, 149; 142, boolean_operator:or; 142, 143; 142, 146; 143, comparison_operator:is; 143, 144; 143, 145; 144, identifier:thatTree; 145, None; 146, comparison_operator:in; 146, 147; 146, 148; 147, identifier:node; 148, identifier:nodesOfThatTree; 149, block; 149, 150; 149, 158; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:nxTree; 154, identifier:add_edge; 155, argument_list; 155, 156; 155, 157; 156, identifier:startNode; 157, identifier:node; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:startNode; 161, identifier:node; 162, if_statement; 162, 163; 162, 166; 163, comparison_operator:!=; 163, 164; 163, 165; 164, identifier:startNode; 165, identifier:endNode; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:nxTree; 171, identifier:add_edge; 172, argument_list; 172, 173; 172, 174; 173, identifier:startNode; 174, identifier:endNode; 175, if_statement; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:self; 178, identifier:debug; 179, block; 179, 180; 179, 188; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:end; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:time; 186, identifier:clock; 187, argument_list; 188, expression_statement; 188, 189; 189, call; 189, 190; 189, 195; 190, attribute; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:sys; 193, identifier:stdout; 194, identifier:write; 195, argument_list; 195, 196; 196, binary_operator:%; 196, 197; 196, 198; 197, string:"%f s\n"; 198, parenthesized_expression; 198, 199; 199, binary_operator:-; 199, 200; 199, 201; 200, identifier:end; 201, identifier:start; 202, return_statement; 202, 203; 203, identifier:nxTree
def _construct_nx_tree(self, thisTree, thatTree=None): if self.debug: sys.stdout.write("Networkx Tree construction: ") start = time.clock() nxTree = nx.DiGraph() nxTree.add_edges_from(thisTree.edges) nodesOfThatTree = [] if thatTree is not None: nodesOfThatTree = thatTree.nodes.keys() for (superNode, _), nodes in thisTree.augmentedEdges.items(): superNodeEdge = list(nxTree.out_edges(superNode)) if len(superNodeEdge) > 1: warnings.warn( "The supernode {} should have only a single " "emanating edge. Merge tree is invalidly " "structured".format(superNode) ) endNode = superNodeEdge[0][1] startNode = superNode nxTree.remove_edge(startNode, endNode) for node in nodes: if thatTree is None or node in nodesOfThatTree: nxTree.add_edge(startNode, node) startNode = node if startNode != endNode: nxTree.add_edge(startNode, endNode) if self.debug: end = time.clock() sys.stdout.write("%f s\n" % (end - start)) return nxTree
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_process_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:thisTree; 6, identifier:thatTree; 7, block; 7, 8; 7, 30; 7, 83; 7, 359; 8, if_statement; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:debug; 12, block; 12, 13; 12, 22; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 20; 15, attribute; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:sys; 18, identifier:stdout; 19, identifier:write; 20, argument_list; 20, 21; 21, string:"Processing Tree: "; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:start; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:time; 28, identifier:clock; 29, argument_list; 30, if_statement; 30, 31; 30, 41; 30, 75; 31, comparison_operator:>; 31, 32; 31, 40; 32, call; 32, 33; 32, 34; 33, identifier:len; 34, argument_list; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:thisTree; 38, identifier:nodes; 39, argument_list; 40, integer:1; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:leaves; 45, call; 45, 46; 45, 47; 46, identifier:set; 47, argument_list; 47, 48; 48, list_comprehension; 48, 49; 48, 50; 48, 57; 49, identifier:v; 50, for_in_clause; 50, 51; 50, 52; 51, identifier:v; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:thisTree; 55, identifier:nodes; 56, argument_list; 57, if_clause; 57, 58; 58, boolean_operator:and; 58, 59; 58, 67; 59, comparison_operator:==; 59, 60; 59, 66; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:thisTree; 63, identifier:in_degree; 64, argument_list; 64, 65; 65, identifier:v; 66, integer:0; 67, comparison_operator:<; 67, 68; 67, 74; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:thatTree; 71, identifier:in_degree; 72, argument_list; 72, 73; 73, identifier:v; 74, integer:2; 75, else_clause; 75, 76; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:leaves; 80, call; 80, 81; 80, 82; 81, identifier:set; 82, argument_list; 83, while_statement; 83, 84; 83, 90; 84, comparison_operator:>; 84, 85; 84, 89; 85, call; 85, 86; 85, 87; 86, identifier:len; 87, argument_list; 87, 88; 88, identifier:leaves; 89, integer:0; 90, block; 90, 91; 90, 99; 90, 111; 90, 133; 90, 141; 90, 149; 90, 186; 90, 193; 90, 306; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:v; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:leaves; 97, identifier:pop; 98, argument_list; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:edges; 102, call; 102, 103; 102, 104; 103, identifier:list; 104, argument_list; 104, 105; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:thisTree; 108, identifier:out_edges; 109, argument_list; 109, 110; 110, identifier:v; 111, if_statement; 111, 112; 111, 118; 112, comparison_operator:!=; 112, 113; 112, 117; 113, call; 113, 114; 113, 115; 114, identifier:len; 115, argument_list; 115, 116; 116, identifier:edges; 117, integer:1; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:warnings; 123, identifier:warn; 124, argument_list; 124, 125; 125, call; 125, 126; 125, 131; 126, attribute; 126, 127; 126, 130; 127, concatenated_string; 127, 128; 127, 129; 128, string:"The node {} should have a single emanating "; 129, string:"edge.\n"; 130, identifier:format; 131, argument_list; 131, 132; 132, identifier:v; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:e1; 136, subscript; 136, 137; 136, 140; 137, subscript; 137, 138; 137, 139; 138, identifier:edges; 139, integer:0; 140, integer:0; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:e2; 144, subscript; 144, 145; 144, 148; 145, subscript; 145, 146; 145, 147; 146, identifier:edges; 147, integer:0; 148, integer:1; 149, if_statement; 149, 150; 149, 161; 149, 173; 150, comparison_operator:<; 150, 151; 150, 156; 151, subscript; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:Y; 155, identifier:e1; 156, subscript; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:self; 159, identifier:Y; 160, identifier:e2; 161, block; 161, 162; 162, expression_statement; 162, 163; 163, call; 163, 164; 163, 169; 164, attribute; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:edges; 168, identifier:append; 169, argument_list; 169, 170; 170, tuple; 170, 171; 170, 172; 171, identifier:e1; 172, identifier:e2; 173, else_clause; 173, 174; 174, block; 174, 175; 175, expression_statement; 175, 176; 176, call; 176, 177; 176, 182; 177, attribute; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:self; 180, identifier:edges; 181, identifier:append; 182, argument_list; 182, 183; 183, tuple; 183, 184; 183, 185; 184, identifier:e2; 185, identifier:e1; 186, expression_statement; 186, 187; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:thisTree; 190, identifier:remove_node; 191, argument_list; 191, 192; 192, identifier:v; 193, if_statement; 193, 194; 193, 202; 193, 210; 194, comparison_operator:==; 194, 195; 194, 201; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:thatTree; 198, identifier:out_degree; 199, argument_list; 199, 200; 200, identifier:v; 201, integer:0; 202, block; 202, 203; 203, expression_statement; 203, 204; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:thatTree; 207, identifier:remove_node; 208, argument_list; 208, 209; 209, identifier:v; 210, else_clause; 210, 211; 211, block; 211, 212; 211, 247; 211, 282; 211, 299; 212, if_statement; 212, 213; 212, 224; 212, 241; 213, comparison_operator:>; 213, 214; 213, 223; 214, call; 214, 215; 214, 216; 215, identifier:len; 216, argument_list; 216, 217; 217, call; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:thatTree; 220, identifier:in_edges; 221, argument_list; 221, 222; 222, identifier:v; 223, integer:0; 224, block; 224, 225; 225, expression_statement; 225, 226; 226, assignment; 226, 227; 226, 228; 227, identifier:startNode; 228, subscript; 228, 229; 228, 240; 229, subscript; 229, 230; 229, 239; 230, call; 230, 231; 230, 232; 231, identifier:list; 232, argument_list; 232, 233; 233, call; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:thatTree; 236, identifier:in_edges; 237, argument_list; 237, 238; 238, identifier:v; 239, integer:0; 240, integer:0; 241, else_clause; 241, 242; 242, block; 242, 243; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:startNode; 246, None; 247, if_statement; 247, 248; 247, 259; 247, 276; 248, comparison_operator:>; 248, 249; 248, 258; 249, call; 249, 250; 249, 251; 250, identifier:len; 251, argument_list; 251, 252; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:thatTree; 255, identifier:out_edges; 256, argument_list; 256, 257; 257, identifier:v; 258, integer:0; 259, block; 259, 260; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 263; 262, identifier:endNode; 263, subscript; 263, 264; 263, 275; 264, subscript; 264, 265; 264, 274; 265, call; 265, 266; 265, 267; 266, identifier:list; 267, argument_list; 267, 268; 268, call; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:thatTree; 271, identifier:out_edges; 272, argument_list; 272, 273; 273, identifier:v; 274, integer:0; 275, integer:1; 276, else_clause; 276, 277; 277, block; 277, 278; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:endNode; 281, None; 282, if_statement; 282, 283; 282, 290; 283, boolean_operator:and; 283, 284; 283, 287; 284, comparison_operator:is; 284, 285; 284, 286; 285, identifier:startNode; 286, None; 287, comparison_operator:is; 287, 288; 287, 289; 288, identifier:endNode; 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:thatTree; 295, identifier:add_edge; 296, argument_list; 296, 297; 296, 298; 297, identifier:startNode; 298, identifier:endNode; 299, expression_statement; 299, 300; 300, call; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:thatTree; 303, identifier:remove_node; 304, argument_list; 304, 305; 305, identifier:v; 306, if_statement; 306, 307; 306, 317; 306, 351; 307, comparison_operator:>; 307, 308; 307, 316; 308, call; 308, 309; 308, 310; 309, identifier:len; 310, argument_list; 310, 311; 311, call; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:thisTree; 314, identifier:nodes; 315, argument_list; 316, integer:1; 317, block; 317, 318; 318, expression_statement; 318, 319; 319, assignment; 319, 320; 319, 321; 320, identifier:leaves; 321, call; 321, 322; 321, 323; 322, identifier:set; 323, argument_list; 323, 324; 324, list_comprehension; 324, 325; 324, 326; 324, 333; 325, identifier:v; 326, for_in_clause; 326, 327; 326, 328; 327, identifier:v; 328, call; 328, 329; 328, 332; 329, attribute; 329, 330; 329, 331; 330, identifier:thisTree; 331, identifier:nodes; 332, argument_list; 333, if_clause; 333, 334; 334, boolean_operator:and; 334, 335; 334, 343; 335, comparison_operator:==; 335, 336; 335, 342; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:thisTree; 339, identifier:in_degree; 340, argument_list; 340, 341; 341, identifier:v; 342, integer:0; 343, comparison_operator:<; 343, 344; 343, 350; 344, call; 344, 345; 344, 348; 345, attribute; 345, 346; 345, 347; 346, identifier:thatTree; 347, identifier:in_degree; 348, argument_list; 348, 349; 349, identifier:v; 350, integer:2; 351, else_clause; 351, 352; 352, block; 352, 353; 353, expression_statement; 353, 354; 354, assignment; 354, 355; 354, 356; 355, identifier:leaves; 356, call; 356, 357; 356, 358; 357, identifier:set; 358, argument_list; 359, if_statement; 359, 360; 359, 363; 360, attribute; 360, 361; 360, 362; 361, identifier:self; 362, identifier:debug; 363, block; 363, 364; 363, 372; 364, expression_statement; 364, 365; 365, assignment; 365, 366; 365, 367; 366, identifier:end; 367, call; 367, 368; 367, 371; 368, attribute; 368, 369; 368, 370; 369, identifier:time; 370, identifier:clock; 371, argument_list; 372, expression_statement; 372, 373; 373, call; 373, 374; 373, 379; 374, attribute; 374, 375; 374, 378; 375, attribute; 375, 376; 375, 377; 376, identifier:sys; 377, identifier:stdout; 378, identifier:write; 379, argument_list; 379, 380; 380, binary_operator:%; 380, 381; 380, 382; 381, string:"%f s\n"; 382, parenthesized_expression; 382, 383; 383, binary_operator:-; 383, 384; 383, 385; 384, identifier:end; 385, identifier:start
def _process_tree(self, thisTree, thatTree): if self.debug: sys.stdout.write("Processing Tree: ") start = time.clock() if len(thisTree.nodes()) > 1: leaves = set( [ v for v in thisTree.nodes() if thisTree.in_degree(v) == 0 and thatTree.in_degree(v) < 2 ] ) else: leaves = set() while len(leaves) > 0: v = leaves.pop() edges = list(thisTree.out_edges(v)) if len(edges) != 1: warnings.warn( "The node {} should have a single emanating " "edge.\n".format(v) ) e1 = edges[0][0] e2 = edges[0][1] if self.Y[e1] < self.Y[e2]: self.edges.append((e1, e2)) else: self.edges.append((e2, e1)) thisTree.remove_node(v) if thatTree.out_degree(v) == 0: thatTree.remove_node(v) else: if len(thatTree.in_edges(v)) > 0: startNode = list(thatTree.in_edges(v))[0][0] else: startNode = None if len(thatTree.out_edges(v)) > 0: endNode = list(thatTree.out_edges(v))[0][1] else: endNode = None if startNode is not None and endNode is not None: thatTree.add_edge(startNode, endNode) thatTree.remove_node(v) if len(thisTree.nodes()) > 1: leaves = set( [ v for v in thisTree.nodes() if thisTree.in_degree(v) == 0 and thatTree.in_degree(v) < 2 ] ) else: leaves = set() if self.debug: end = time.clock() sys.stdout.write("%f s\n" % (end - start))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_project_content_commit_date; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:root_dir; 6, string:'.'; 7, default_parameter; 7, 8; 7, 9; 8, identifier:exclusions; 9, None; 10, block; 10, 11; 10, 20; 10, 31; 10, 35; 10, 49; 10, 61; 10, 92; 10, 109; 10, 123; 10, 127; 10, 165; 10, 174; 10, 181; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:logger; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:logging; 17, identifier:getLogger; 18, argument_list; 18, 19; 19, identifier:__name__; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:extensions; 23, tuple; 23, 24; 23, 25; 23, 26; 23, 27; 23, 28; 23, 29; 23, 30; 24, string:'rst'; 25, string:'ipynb'; 26, string:'png'; 27, string:'jpeg'; 28, string:'jpg'; 29, string:'svg'; 30, string:'gif'; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:content_paths; 34, list:[]; 35, for_statement; 35, 36; 35, 37; 35, 38; 36, identifier:extname; 37, identifier:extensions; 38, block; 38, 39; 39, expression_statement; 39, 40; 40, augmented_assignment:+=; 40, 41; 40, 42; 41, identifier:content_paths; 42, call; 42, 43; 42, 44; 43, identifier:get_filepaths_with_extension; 44, argument_list; 44, 45; 44, 46; 45, identifier:extname; 46, keyword_argument; 46, 47; 46, 48; 47, identifier:root_dir; 48, identifier:root_dir; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:exclude; 52, call; 52, 53; 52, 54; 53, identifier:Matcher; 54, argument_list; 54, 55; 55, conditional_expression:if; 55, 56; 55, 57; 55, 58; 56, identifier:exclusions; 57, identifier:exclusions; 58, list:['readme.rst', 'license.rst']; 58, 59; 58, 60; 59, string:'readme.rst'; 60, string:'license.rst'; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:content_paths; 64, list_comprehension; 64, 65; 64, 66; 64, 69; 65, identifier:p; 66, for_in_clause; 66, 67; 66, 68; 67, identifier:p; 68, identifier:content_paths; 69, if_clause; 69, 70; 70, not_operator; 70, 71; 71, parenthesized_expression; 71, 72; 72, boolean_operator:or; 72, 73; 72, 77; 73, call; 73, 74; 73, 75; 74, identifier:exclude; 75, argument_list; 75, 76; 76, identifier:p; 77, call; 77, 78; 77, 79; 78, identifier:exclude; 79, argument_list; 79, 80; 80, subscript; 80, 81; 80, 91; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:p; 84, identifier:split; 85, argument_list; 85, 86; 86, attribute; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:os; 89, identifier:path; 90, identifier:sep; 91, integer:0; 92, expression_statement; 92, 93; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:logger; 96, identifier:debug; 97, argument_list; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, string:'Found content paths: {}'; 101, identifier:format; 102, argument_list; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, string:', '; 106, identifier:join; 107, argument_list; 107, 108; 108, identifier:content_paths; 109, if_statement; 109, 110; 109, 112; 110, not_operator; 110, 111; 111, identifier:content_paths; 112, block; 112, 113; 113, raise_statement; 113, 114; 114, call; 114, 115; 114, 116; 115, identifier:RuntimeError; 116, argument_list; 116, 117; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, string:'No content files found in {}'; 120, identifier:format; 121, argument_list; 121, 122; 122, identifier:root_dir; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:commit_datetimes; 126, list:[]; 127, for_statement; 127, 128; 127, 129; 127, 130; 128, identifier:filepath; 129, identifier:content_paths; 130, block; 130, 131; 131, try_statement; 131, 132; 131, 150; 132, block; 132, 133; 132, 143; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:datetime; 136, call; 136, 137; 136, 138; 137, identifier:read_git_commit_timestamp_for_file; 138, argument_list; 138, 139; 138, 140; 139, identifier:filepath; 140, keyword_argument; 140, 141; 140, 142; 141, identifier:repo_path; 142, identifier:root_dir; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:commit_datetimes; 147, identifier:append; 148, argument_list; 148, 149; 149, identifier:datetime; 150, except_clause; 150, 151; 150, 152; 151, identifier:IOError; 152, block; 152, 153; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:logger; 157, identifier:warning; 158, argument_list; 158, 159; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, string:'Could not get commit for {}, skipping'; 162, identifier:format; 163, argument_list; 163, 164; 164, identifier:filepath; 165, if_statement; 165, 166; 165, 168; 166, not_operator; 166, 167; 167, identifier:commit_datetimes; 168, block; 168, 169; 169, raise_statement; 169, 170; 170, call; 170, 171; 170, 172; 171, identifier:RuntimeError; 172, argument_list; 172, 173; 173, string:'No content commits could be found'; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:latest_datetime; 177, call; 177, 178; 177, 179; 178, identifier:max; 179, argument_list; 179, 180; 180, identifier:commit_datetimes; 181, return_statement; 181, 182; 182, identifier:latest_datetime
def get_project_content_commit_date(root_dir='.', exclusions=None): logger = logging.getLogger(__name__) extensions = ('rst', 'ipynb', 'png', 'jpeg', 'jpg', 'svg', 'gif') content_paths = [] for extname in extensions: content_paths += get_filepaths_with_extension( extname, root_dir=root_dir) exclude = Matcher(exclusions if exclusions else ['readme.rst', 'license.rst']) content_paths = [p for p in content_paths if not (exclude(p) or exclude(p.split(os.path.sep)[0]))] logger.debug('Found content paths: {}'.format(', '.join(content_paths))) if not content_paths: raise RuntimeError('No content files found in {}'.format(root_dir)) commit_datetimes = [] for filepath in content_paths: try: datetime = read_git_commit_timestamp_for_file( filepath, repo_path=root_dir) commit_datetimes.append(datetime) except IOError: logger.warning( 'Could not get commit for {}, skipping'.format(filepath)) if not commit_datetimes: raise RuntimeError('No content commits could be found') latest_datetime = max(commit_datetimes) return latest_datetime
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_table; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:name; 6, block; 6, 7; 6, 91; 6, 151; 6, 173; 6, 198; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:name; 10, None; 11, block; 11, 12; 11, 17; 11, 25; 11, 54; 11, 86; 12, assert_statement; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:active_table; 16, string:"Can't get table without name unless an active table is set"; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:name; 20, attribute; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:active_table; 24, identifier:name; 25, if_statement; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:active_worksheet; 29, block; 29, 30; 29, 41; 29, 48; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:table; 33, call; 33, 34; 33, 39; 34, attribute; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:active_worksheet; 38, identifier:get_table; 39, argument_list; 39, 40; 40, identifier:name; 41, assert_statement; 41, 42; 41, 47; 42, comparison_operator:is; 42, 43; 42, 44; 43, identifier:table; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:active_table; 47, string:"Active table is not from the active sheet"; 48, return_statement; 48, 49; 49, expression_list; 49, 50; 49, 51; 50, identifier:table; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:active_worksheet; 54, for_statement; 54, 55; 54, 56; 54, 59; 55, identifier:ws; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:worksheets; 59, block; 59, 60; 60, try_statement; 60, 61; 60, 82; 61, block; 61, 62; 61, 71; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:table; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:ws; 68, identifier:get_table; 69, argument_list; 69, 70; 70, identifier:name; 71, if_statement; 71, 72; 71, 77; 72, comparison_operator:is; 72, 73; 72, 74; 73, identifier:table; 74, attribute; 74, 75; 74, 76; 75, identifier:self; 76, identifier:active_table; 77, block; 77, 78; 78, return_statement; 78, 79; 79, expression_list; 79, 80; 79, 81; 80, identifier:table; 81, identifier:ws; 82, except_clause; 82, 83; 82, 84; 83, identifier:KeyError; 84, block; 84, 85; 85, pass_statement; 86, raise_statement; 86, 87; 87, call; 87, 88; 87, 89; 88, identifier:RuntimeError; 89, argument_list; 89, 90; 90, string:"Active table not found in any sheet"; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:in; 92, 93; 92, 94; 93, string:"!"; 94, identifier:name; 95, block; 95, 96; 95, 120; 95, 146; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, pattern_list; 98, 99; 98, 100; 99, identifier:ws_name; 100, identifier:table_name; 101, call; 101, 102; 101, 103; 102, identifier:map; 103, argument_list; 103, 104; 103, 113; 104, lambda; 104, 105; 104, 107; 105, lambda_parameters; 105, 106; 106, identifier:x; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:x; 110, identifier:strip; 111, argument_list; 111, 112; 112, string:"'"; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:name; 116, identifier:split; 117, argument_list; 117, 118; 117, 119; 118, string:"!"; 119, integer:1; 120, for_statement; 120, 121; 120, 122; 120, 125; 121, identifier:ws; 122, attribute; 122, 123; 122, 124; 123, identifier:self; 124, identifier:worksheets; 125, block; 125, 126; 126, if_statement; 126, 127; 126, 132; 127, comparison_operator:==; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:ws; 130, identifier:name; 131, identifier:ws_name; 132, block; 132, 133; 132, 142; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:table; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:ws; 139, identifier:get_table; 140, argument_list; 140, 141; 141, identifier:table_name; 142, return_statement; 142, 143; 143, expression_list; 143, 144; 143, 145; 144, identifier:table; 145, identifier:ws; 146, raise_statement; 146, 147; 147, call; 147, 148; 147, 149; 148, identifier:KeyError; 149, argument_list; 149, 150; 150, identifier:name; 151, if_statement; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:active_worksheet; 155, block; 155, 156; 155, 167; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:table; 159, call; 159, 160; 159, 165; 160, attribute; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:active_worksheet; 164, identifier:get_table; 165, argument_list; 165, 166; 166, identifier:name; 167, return_statement; 167, 168; 168, expression_list; 168, 169; 168, 170; 169, identifier:table; 170, attribute; 170, 171; 170, 172; 171, identifier:self; 172, identifier:active_worksheet; 173, for_statement; 173, 174; 173, 175; 173, 178; 174, identifier:ws; 175, attribute; 175, 176; 175, 177; 176, identifier:self; 177, identifier:worksheets; 178, block; 178, 179; 179, try_statement; 179, 180; 179, 194; 180, block; 180, 181; 180, 190; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 184; 183, identifier:table; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:ws; 187, identifier:get_table; 188, argument_list; 188, 189; 189, identifier:name; 190, return_statement; 190, 191; 191, expression_list; 191, 192; 191, 193; 192, identifier:table; 193, identifier:ws; 194, except_clause; 194, 195; 194, 196; 195, identifier:KeyError; 196, block; 196, 197; 197, pass_statement; 198, raise_statement; 198, 199; 199, call; 199, 200; 199, 201; 200, identifier:KeyError; 201, argument_list; 201, 202; 202, identifier:name
def get_table(self, name): if name is None: assert self.active_table, "Can't get table without name unless an active table is set" name = self.active_table.name if self.active_worksheet: table = self.active_worksheet.get_table(name) assert table is self.active_table, "Active table is not from the active sheet" return table, self.active_worksheet for ws in self.worksheets: try: table = ws.get_table(name) if table is self.active_table: return table, ws except KeyError: pass raise RuntimeError("Active table not found in any sheet") if "!" in name: ws_name, table_name = map(lambda x: x.strip("'"), name.split("!", 1)) for ws in self.worksheets: if ws.name == ws_name: table = ws.get_table(table_name) return table, ws raise KeyError(name) if self.active_worksheet: table = self.active_worksheet.get_table(name) return table, self.active_worksheet for ws in self.worksheets: try: table = ws.get_table(name) return table, ws except KeyError: pass raise KeyError(name)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:assign_valence; 3, parameters; 3, 4; 4, identifier:mol; 5, block; 5, 6; 5, 139; 5, 179; 5, 273; 6, for_statement; 6, 7; 6, 11; 6, 16; 7, pattern_list; 7, 8; 7, 9; 7, 10; 8, identifier:u; 9, identifier:v; 10, identifier:bond; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:mol; 14, identifier:bonds_iter; 15, argument_list; 16, block; 16, 17; 17, if_statement; 17, 18; 17, 23; 17, 112; 18, comparison_operator:==; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:bond; 21, identifier:order; 22, integer:2; 23, block; 23, 24; 23, 35; 23, 46; 23, 79; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 34; 26, attribute; 26, 27; 26, 33; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:mol; 30, identifier:atom; 31, argument_list; 31, 32; 32, identifier:u; 33, identifier:pi; 34, integer:1; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 45; 37, attribute; 37, 38; 37, 44; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:mol; 41, identifier:atom; 42, argument_list; 42, 43; 43, identifier:v; 44, identifier:pi; 45, integer:1; 46, if_statement; 46, 47; 46, 67; 47, boolean_operator:and; 47, 48; 47, 58; 48, comparison_operator:==; 48, 49; 48, 57; 49, attribute; 49, 50; 49, 56; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:mol; 53, identifier:atom; 54, argument_list; 54, 55; 55, identifier:u; 56, identifier:symbol; 57, string:"O"; 58, not_operator; 58, 59; 59, attribute; 59, 60; 59, 66; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:mol; 63, identifier:atom; 64, argument_list; 64, 65; 65, identifier:u; 66, identifier:charge; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 78; 70, attribute; 70, 71; 70, 77; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:mol; 74, identifier:atom; 75, argument_list; 75, 76; 76, identifier:v; 77, identifier:carbonyl_C; 78, integer:1; 79, if_statement; 79, 80; 79, 100; 80, boolean_operator:and; 80, 81; 80, 91; 81, comparison_operator:==; 81, 82; 81, 90; 82, attribute; 82, 83; 82, 89; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:mol; 86, identifier:atom; 87, argument_list; 87, 88; 88, identifier:v; 89, identifier:symbol; 90, string:"O"; 91, not_operator; 91, 92; 92, attribute; 92, 93; 92, 99; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:mol; 96, identifier:atom; 97, argument_list; 97, 98; 98, identifier:v; 99, identifier:charge; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 111; 103, attribute; 103, 104; 103, 110; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:mol; 107, identifier:atom; 108, argument_list; 108, 109; 109, identifier:u; 110, identifier:carbonyl_C; 111, integer:1; 112, elif_clause; 112, 113; 112, 118; 113, comparison_operator:==; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:bond; 116, identifier:order; 117, integer:3; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 129; 121, attribute; 121, 122; 121, 128; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:mol; 125, identifier:atom; 126, argument_list; 126, 127; 127, identifier:u; 128, identifier:pi; 129, assignment; 129, 130; 129, 138; 130, attribute; 130, 131; 130, 137; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:mol; 134, identifier:atom; 135, argument_list; 135, 136; 136, identifier:v; 137, identifier:pi; 138, integer:2; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:max_nbr; 142, dictionary; 142, 143; 142, 146; 142, 149; 142, 152; 142, 155; 142, 158; 142, 161; 142, 164; 142, 167; 142, 170; 142, 173; 142, 176; 143, pair; 143, 144; 143, 145; 144, string:"C"; 145, integer:4; 146, pair; 146, 147; 146, 148; 147, string:"Si"; 148, integer:4; 149, pair; 149, 150; 149, 151; 150, string:"N"; 151, integer:3; 152, pair; 152, 153; 152, 154; 153, string:"P"; 154, integer:3; 155, pair; 155, 156; 155, 157; 156, string:"As"; 157, integer:3; 158, pair; 158, 159; 158, 160; 159, string:"O"; 160, integer:2; 161, pair; 161, 162; 161, 163; 162, string:"S"; 163, integer:2; 164, pair; 164, 165; 164, 166; 165, string:"Se"; 166, integer:2; 167, pair; 167, 168; 167, 169; 168, string:"F"; 169, integer:1; 170, pair; 170, 171; 170, 172; 171, string:"Cl"; 172, integer:1; 173, pair; 173, 174; 173, 175; 174, string:"Br"; 175, integer:1; 176, pair; 176, 177; 176, 178; 177, string:"I"; 178, integer:1; 179, for_statement; 179, 180; 179, 183; 179, 188; 180, pattern_list; 180, 181; 180, 182; 181, identifier:i; 182, identifier:nbrs; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:mol; 186, identifier:neighbors_iter; 187, argument_list; 188, block; 188, 189; 188, 198; 188, 228; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:atom; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:mol; 195, identifier:atom; 196, argument_list; 196, 197; 197, identifier:i; 198, if_statement; 198, 199; 198, 221; 199, boolean_operator:and; 199, 200; 199, 206; 200, comparison_operator:==; 200, 201; 200, 205; 201, call; 201, 202; 201, 203; 202, identifier:len; 203, argument_list; 203, 204; 204, identifier:nbrs; 205, integer:2; 206, call; 206, 207; 206, 208; 207, identifier:all; 208, generator_expression; 208, 209; 208, 214; 209, comparison_operator:==; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:bond; 212, identifier:order; 213, integer:2; 214, for_in_clause; 214, 215; 214, 216; 215, identifier:bond; 216, call; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:nbrs; 219, identifier:values; 220, argument_list; 221, block; 221, 222; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:atom; 226, identifier:pi; 227, integer:2; 228, if_statement; 228, 229; 228, 234; 229, comparison_operator:in; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:atom; 232, identifier:symbol; 233, identifier:max_nbr; 234, block; 234, 235; 234, 256; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:h_cnt; 238, binary_operator:+; 238, 239; 238, 253; 239, binary_operator:-; 239, 240; 239, 250; 240, binary_operator:-; 240, 241; 240, 246; 241, subscript; 241, 242; 241, 243; 242, identifier:max_nbr; 243, attribute; 243, 244; 243, 245; 244, identifier:atom; 245, identifier:symbol; 246, call; 246, 247; 246, 248; 247, identifier:len; 248, argument_list; 248, 249; 249, identifier:nbrs; 250, attribute; 250, 251; 250, 252; 251, identifier:atom; 252, identifier:pi; 253, attribute; 253, 254; 253, 255; 254, identifier:atom; 255, identifier:charge; 256, if_statement; 256, 257; 256, 260; 257, comparison_operator:>; 257, 258; 257, 259; 258, identifier:h_cnt; 259, integer:0; 260, block; 260, 261; 261, expression_statement; 261, 262; 262, call; 262, 263; 262, 271; 263, attribute; 263, 264; 263, 270; 264, call; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:mol; 267, identifier:atom; 268, argument_list; 268, 269; 269, identifier:i; 270, identifier:add_hydrogen; 271, argument_list; 271, 272; 272, identifier:h_cnt; 273, expression_statement; 273, 274; 274, call; 274, 275; 274, 280; 275, attribute; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:mol; 278, identifier:descriptors; 279, identifier:add; 280, argument_list; 280, 281; 281, string:"Valence"
def assign_valence(mol): for u, v, bond in mol.bonds_iter(): if bond.order == 2: mol.atom(u).pi = 1 mol.atom(v).pi = 1 if mol.atom(u).symbol == "O" and not mol.atom(u).charge: mol.atom(v).carbonyl_C = 1 if mol.atom(v).symbol == "O" and not mol.atom(v).charge: mol.atom(u).carbonyl_C = 1 elif bond.order == 3: mol.atom(u).pi = mol.atom(v).pi = 2 max_nbr = {"C": 4, "Si": 4, "N": 3, "P": 3, "As": 3, "O": 2, "S": 2, "Se": 2, "F": 1, "Cl": 1, "Br": 1, "I": 1} for i, nbrs in mol.neighbors_iter(): atom = mol.atom(i) if len(nbrs) == 2 and all(bond.order == 2 for bond in nbrs.values()): atom.pi = 2 if atom.symbol in max_nbr: h_cnt = max_nbr[atom.symbol] - len(nbrs) - atom.pi + atom.charge if h_cnt > 0: mol.atom(i).add_hydrogen(h_cnt) mol.descriptors.add("Valence")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:assign_charge; 3, parameters; 3, 4; 3, 5; 4, identifier:mol; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force_recalc; 7, False; 8, block; 8, 9; 8, 16; 8, 398; 8, 404; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:mol; 13, identifier:require; 14, argument_list; 14, 15; 15, string:"Aromatic"; 16, for_statement; 16, 17; 16, 20; 16, 25; 17, pattern_list; 17, 18; 17, 19; 18, identifier:i; 19, identifier:nbrs; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:mol; 23, identifier:neighbors_iter; 24, argument_list; 25, block; 25, 26; 25, 35; 25, 42; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:atom; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:mol; 32, identifier:atom; 33, argument_list; 33, 34; 34, identifier:i; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:nbrcnt; 38, call; 38, 39; 38, 40; 39, identifier:len; 40, argument_list; 40, 41; 41, identifier:nbrs; 42, if_statement; 42, 43; 42, 48; 42, 207; 42, 352; 43, comparison_operator:==; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:atom; 46, identifier:symbol; 47, string:"N"; 48, block; 48, 49; 49, if_statement; 49, 50; 49, 54; 49, 66; 50, not_operator; 50, 51; 51, attribute; 51, 52; 51, 53; 52, identifier:atom; 53, identifier:pi; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 65; 57, attribute; 57, 58; 57, 64; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:mol; 61, identifier:atom; 62, argument_list; 62, 63; 63, identifier:i; 64, identifier:charge_phys; 65, integer:1; 66, elif_clause; 66, 67; 66, 76; 67, boolean_operator:and; 67, 68; 67, 71; 68, comparison_operator:==; 68, 69; 68, 70; 69, identifier:nbrcnt; 70, integer:1; 71, comparison_operator:==; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:atom; 74, identifier:pi; 75, integer:2; 76, block; 76, 77; 76, 90; 76, 94; 76, 98; 76, 177; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:ni; 80, subscript; 80, 81; 80, 89; 81, call; 81, 82; 81, 83; 82, identifier:list; 83, argument_list; 83, 84; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:nbrs; 87, identifier:keys; 88, argument_list; 89, integer:0; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:conj; 93, False; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:sp2n; 97, None; 98, for_statement; 98, 99; 98, 102; 98, 112; 99, pattern_list; 99, 100; 99, 101; 100, identifier:nni; 101, identifier:nnb; 102, call; 102, 103; 102, 111; 103, attribute; 103, 104; 103, 110; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:mol; 107, identifier:neighbors; 108, argument_list; 108, 109; 109, identifier:ni; 110, identifier:items; 111, argument_list; 112, block; 112, 113; 113, if_statement; 113, 114; 113, 141; 113, 157; 114, boolean_operator:and; 114, 115; 114, 131; 114, 132; 115, boolean_operator:and; 115, 116; 115, 126; 116, comparison_operator:==; 116, 117; 116, 125; 117, attribute; 117, 118; 117, 124; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:mol; 121, identifier:atom; 122, argument_list; 122, 123; 123, identifier:nni; 124, identifier:symbol; 125, string:"N"; 126, comparison_operator:==; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:nnb; 129, identifier:order; 130, integer:2; 131, line_continuation:\; 132, not_operator; 132, 133; 133, attribute; 133, 134; 133, 140; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:mol; 137, identifier:atom; 138, argument_list; 138, 139; 139, identifier:nni; 140, identifier:aromatic; 141, block; 141, 142; 141, 153; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 152; 144, attribute; 144, 145; 144, 151; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:mol; 148, identifier:atom; 149, argument_list; 149, 150; 150, identifier:nni; 151, identifier:charge_conj; 152, integer:1; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:conj; 156, True; 157, elif_clause; 157, 158; 157, 172; 158, boolean_operator:and; 158, 159; 158, 169; 159, comparison_operator:==; 159, 160; 159, 168; 160, attribute; 160, 161; 160, 167; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:mol; 164, identifier:atom; 165, argument_list; 165, 166; 166, identifier:nni; 167, identifier:symbol; 168, string:"N"; 169, comparison_operator:!=; 169, 170; 169, 171; 170, identifier:nni; 171, identifier:i; 172, block; 172, 173; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:sp2n; 176, identifier:nni; 177, if_statement; 177, 178; 177, 179; 178, identifier:conj; 179, block; 179, 180; 179, 191; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 190; 182, attribute; 182, 183; 182, 189; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:mol; 186, identifier:atom; 187, argument_list; 187, 188; 188, identifier:i; 189, identifier:charge_phys; 190, integer:1; 191, if_statement; 191, 192; 191, 195; 192, comparison_operator:is; 192, 193; 192, 194; 193, identifier:sp2n; 194, None; 195, block; 195, 196; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 206; 198, attribute; 198, 199; 198, 205; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:mol; 202, identifier:atom; 203, argument_list; 203, 204; 204, identifier:sp2n; 205, identifier:charge_conj; 206, integer:1; 207, elif_clause; 207, 208; 207, 223; 208, boolean_operator:and; 208, 209; 208, 218; 209, boolean_operator:and; 209, 210; 209, 215; 210, comparison_operator:==; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:atom; 213, identifier:symbol; 214, string:"O"; 215, comparison_operator:==; 215, 216; 215, 217; 216, identifier:nbrcnt; 217, integer:1; 218, comparison_operator:==; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:atom; 221, identifier:pi; 222, integer:2; 223, block; 223, 224; 223, 237; 223, 241; 223, 275; 223, 337; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 227; 226, identifier:ni; 227, subscript; 227, 228; 227, 236; 228, call; 228, 229; 228, 230; 229, identifier:list; 230, argument_list; 230, 231; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:nbrs; 234, identifier:keys; 235, argument_list; 236, integer:0; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:conj; 240, False; 241, if_statement; 241, 242; 241, 252; 242, comparison_operator:==; 242, 243; 242, 251; 243, attribute; 243, 244; 243, 250; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:mol; 247, identifier:atom; 248, argument_list; 248, 249; 249, identifier:ni; 250, identifier:symbol; 251, string:"N"; 252, block; 252, 253; 252, 264; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 263; 255, attribute; 255, 256; 255, 262; 256, call; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:mol; 259, identifier:atom; 260, argument_list; 260, 261; 261, identifier:i; 262, identifier:n_oxide; 263, True; 264, expression_statement; 264, 265; 265, assignment; 265, 266; 265, 274; 266, attribute; 266, 267; 266, 273; 267, call; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:mol; 270, identifier:atom; 271, argument_list; 271, 272; 272, identifier:ni; 273, identifier:n_oxide; 274, True; 275, for_statement; 275, 276; 275, 279; 275, 289; 276, pattern_list; 276, 277; 276, 278; 277, identifier:nni; 278, identifier:nnb; 279, call; 279, 280; 279, 288; 280, attribute; 280, 281; 280, 287; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:mol; 284, identifier:neighbors; 285, argument_list; 285, 286; 286, identifier:ni; 287, identifier:items; 288, argument_list; 289, block; 289, 290; 290, if_statement; 290, 291; 290, 320; 291, boolean_operator:and; 291, 292; 291, 311; 292, boolean_operator:and; 292, 293; 292, 305; 292, 306; 293, comparison_operator:in; 293, 294; 293, 302; 294, attribute; 294, 295; 294, 301; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:mol; 298, identifier:atom; 299, argument_list; 299, 300; 300, identifier:nni; 301, identifier:symbol; 302, tuple; 302, 303; 302, 304; 303, string:"O"; 304, string:"S"; 305, line_continuation:\; 306, comparison_operator:==; 306, 307; 306, 310; 307, attribute; 307, 308; 307, 309; 308, identifier:nnb; 309, identifier:order; 310, integer:2; 311, not_operator; 311, 312; 312, attribute; 312, 313; 312, 319; 313, call; 313, 314; 313, 317; 314, attribute; 314, 315; 314, 316; 315, identifier:mol; 316, identifier:atom; 317, argument_list; 317, 318; 318, identifier:ni; 319, identifier:n_oxide; 320, block; 320, 321; 320, 333; 321, expression_statement; 321, 322; 322, assignment; 322, 323; 322, 331; 323, attribute; 323, 324; 323, 330; 324, call; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:mol; 327, identifier:atom; 328, argument_list; 328, 329; 329, identifier:nni; 330, identifier:charge_conj; 331, unary_operator:-; 331, 332; 332, integer:1; 333, expression_statement; 333, 334; 334, assignment; 334, 335; 334, 336; 335, identifier:conj; 336, True; 337, if_statement; 337, 338; 337, 339; 338, identifier:conj; 339, block; 339, 340; 340, expression_statement; 340, 341; 341, assignment; 341, 342; 341, 350; 342, attribute; 342, 343; 342, 349; 343, call; 343, 344; 343, 347; 344, attribute; 344, 345; 344, 346; 345, identifier:mol; 346, identifier:atom; 347, argument_list; 347, 348; 348, identifier:i; 349, identifier:charge_phys; 350, unary_operator:-; 350, 351; 351, integer:1; 352, elif_clause; 352, 353; 352, 362; 353, boolean_operator:and; 353, 354; 353, 359; 354, comparison_operator:==; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:atom; 357, identifier:symbol; 358, string:"S"; 359, comparison_operator:==; 359, 360; 359, 361; 360, identifier:nbrcnt; 361, integer:1; 362, block; 362, 363; 362, 376; 363, expression_statement; 363, 364; 364, assignment; 364, 365; 364, 366; 365, identifier:ni; 366, subscript; 366, 367; 366, 375; 367, call; 367, 368; 367, 369; 368, identifier:list; 369, argument_list; 369, 370; 370, call; 370, 371; 370, 374; 371, attribute; 371, 372; 371, 373; 372, identifier:nbrs; 373, identifier:keys; 374, argument_list; 375, integer:0; 376, if_statement; 376, 377; 376, 385; 377, attribute; 377, 378; 377, 384; 378, call; 378, 379; 378, 382; 379, attribute; 379, 380; 379, 381; 380, identifier:mol; 381, identifier:atom; 382, argument_list; 382, 383; 383, identifier:ni; 384, identifier:aromatic; 385, block; 385, 386; 386, expression_statement; 386, 387; 387, assignment; 387, 388; 387, 396; 388, attribute; 388, 389; 388, 395; 389, call; 389, 390; 389, 393; 390, attribute; 390, 391; 390, 392; 391, identifier:mol; 392, identifier:atom; 393, argument_list; 393, 394; 394, identifier:i; 395, identifier:charge_phys; 396, unary_operator:-; 396, 397; 397, integer:1; 398, expression_statement; 398, 399; 399, assignment; 399, 400; 399, 403; 400, attribute; 400, 401; 400, 402; 401, identifier:mol; 402, identifier:charge_assigned; 403, True; 404, expression_statement; 404, 405; 405, call; 405, 406; 405, 411; 406, attribute; 406, 407; 406, 410; 407, attribute; 407, 408; 407, 409; 408, identifier:mol; 409, identifier:descriptors; 410, identifier:add; 411, argument_list; 411, 412; 412, string:"Phys_charge"
def assign_charge(mol, force_recalc=False): mol.require("Aromatic") for i, nbrs in mol.neighbors_iter(): atom = mol.atom(i) nbrcnt = len(nbrs) if atom.symbol == "N": if not atom.pi: mol.atom(i).charge_phys = 1 elif nbrcnt == 1 and atom.pi == 2: ni = list(nbrs.keys())[0] conj = False sp2n = None for nni, nnb in mol.neighbors(ni).items(): if mol.atom(nni).symbol == "N" and nnb.order == 2 \ and not mol.atom(nni).aromatic: mol.atom(nni).charge_conj = 1 conj = True elif mol.atom(nni).symbol == "N" and nni != i: sp2n = nni if conj: mol.atom(i).charge_phys = 1 if sp2n is not None: mol.atom(sp2n).charge_conj = 1 elif atom.symbol == "O" and nbrcnt == 1 and atom.pi == 2: ni = list(nbrs.keys())[0] conj = False if mol.atom(ni).symbol == "N": mol.atom(i).n_oxide = True mol.atom(ni).n_oxide = True for nni, nnb in mol.neighbors(ni).items(): if mol.atom(nni).symbol in ("O", "S") \ and nnb.order == 2 and not mol.atom(ni).n_oxide: mol.atom(nni).charge_conj = -1 conj = True if conj: mol.atom(i).charge_phys = -1 elif atom.symbol == "S" and nbrcnt == 1: ni = list(nbrs.keys())[0] if mol.atom(ni).aromatic: mol.atom(i).charge_phys = -1 mol.charge_assigned = True mol.descriptors.add("Phys_charge")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_alphabetical_members; 3, parameters; 3, 4; 3, 5; 4, identifier:obj; 5, identifier:predicate; 6, block; 6, 7; 6, 20; 6, 31; 6, 37; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:fields; 10, call; 10, 11; 10, 12; 11, identifier:dict; 12, argument_list; 12, 13; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:inspect; 16, identifier:getmembers; 17, argument_list; 17, 18; 17, 19; 18, identifier:obj; 19, identifier:predicate; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:keys; 23, call; 23, 24; 23, 25; 24, identifier:list; 25, argument_list; 25, 26; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:fields; 29, identifier:keys; 30, argument_list; 31, expression_statement; 31, 32; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:keys; 35, identifier:sort; 36, argument_list; 37, return_statement; 37, 38; 38, dictionary_comprehension; 38, 39; 38, 44; 39, pair; 39, 40; 39, 41; 40, identifier:k; 41, subscript; 41, 42; 41, 43; 42, identifier:fields; 43, identifier:k; 44, for_in_clause; 44, 45; 44, 46; 45, identifier:k; 46, identifier:keys
def _get_alphabetical_members(obj, predicate): fields = dict(inspect.getmembers(obj, predicate)) keys = list(fields.keys()) keys.sort() return {k: fields[k] for k in keys}
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 26; 5, 32; 5, 36; 5, 346; 5, 351; 5, 367; 5, 373; 5, 379; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:request_cache; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:cache; 12, identifier:get_request_cache; 13, argument_list; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:session; 17, call; 17, 18; 17, 25; 18, attribute; 18, 19; 18, 24; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:client; 22, identifier:get_client; 23, argument_list; 24, identifier:create_session; 25, argument_list; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:mark_incomplete; 31, argument_list; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:universes; 35, list:[]; 36, with_statement; 36, 37; 36, 42; 37, with_clause; 37, 38; 38, with_item; 38, 39; 39, attribute; 39, 40; 39, 41; 40, identifier:session; 41, identifier:no_autoflush; 42, block; 42, 43; 42, 58; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:movies; 46, call; 46, 47; 46, 57; 47, attribute; 47, 48; 47, 56; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:session; 51, identifier:query; 52, argument_list; 52, 53; 53, attribute; 53, 54; 53, 55; 54, identifier:models; 55, identifier:Movie; 56, identifier:all; 57, argument_list; 58, for_statement; 58, 59; 58, 60; 58, 61; 59, identifier:movie; 60, identifier:movies; 61, block; 61, 62; 61, 81; 61, 90; 61, 101; 61, 109; 61, 113; 61, 121; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:article; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:request_cache; 68, identifier:get; 69, argument_list; 69, 70; 69, 75; 69, 78; 70, binary_operator:+; 70, 71; 70, 72; 71, string:"http://marvel.wikia.com"; 72, attribute; 72, 73; 72, 74; 73, identifier:movie; 74, identifier:url; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:xpath; 77, string:"//article[@id='WikiaMainContent']"; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:rate_limit; 80, float:0.5; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:doc; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:html; 87, identifier:fromstring; 88, argument_list; 88, 89; 89, identifier:article; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:node; 93, subscript; 93, 94; 93, 100; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:doc; 97, identifier:xpath; 98, argument_list; 98, 99; 99, string:"//span[@id='Appearances']"; 100, integer:0; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:node; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:node; 107, identifier:getparent; 108, argument_list; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:appearance_type; 112, string:"Featured Characters"; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:node; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:node; 119, identifier:getnext; 120, argument_list; 121, while_statement; 121, 122; 121, 131; 122, boolean_operator:and; 122, 123; 122, 126; 123, comparison_operator:is; 123, 124; 123, 125; 124, identifier:node; 125, None; 126, comparison_operator:!=; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:node; 129, identifier:tag; 130, string:'h2'; 131, block; 131, 132; 131, 338; 132, if_statement; 132, 133; 132, 155; 132, 305; 133, boolean_operator:and; 133, 134; 133, 139; 134, comparison_operator:==; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:node; 137, identifier:tag; 138, string:'ul'; 139, parenthesized_expression; 139, 140; 140, boolean_operator:or; 140, 141; 140, 148; 141, comparison_operator:in; 141, 142; 141, 143; 142, string:'characters'; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:appearance_type; 146, identifier:lower; 147, argument_list; 148, comparison_operator:in; 148, 149; 148, 150; 149, string:'villains'; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:appearance_type; 153, identifier:lower; 154, argument_list; 155, block; 155, 156; 156, for_statement; 156, 157; 156, 158; 156, 164; 157, identifier:li; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:node; 161, identifier:iter; 162, argument_list; 162, 163; 163, string:'li'; 164, block; 164, 165; 165, for_statement; 165, 166; 165, 167; 165, 168; 166, identifier:a; 167, identifier:li; 168, block; 168, 169; 168, 177; 168, 202; 168, 217; 168, 237; 168, 304; 169, if_statement; 169, 170; 169, 175; 170, comparison_operator:!=; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:a; 173, identifier:tag; 174, string:'a'; 175, block; 175, 176; 176, continue_statement; 177, if_statement; 177, 178; 177, 200; 178, boolean_operator:or; 178, 179; 178, 188; 179, comparison_operator:in; 179, 180; 179, 181; 180, string:"image"; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:a; 184, identifier:get; 185, argument_list; 185, 186; 185, 187; 186, string:"class"; 187, string:""; 188, not_operator; 188, 189; 189, call; 189, 190; 189, 198; 190, attribute; 190, 191; 190, 197; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:a; 194, identifier:get; 195, argument_list; 195, 196; 196, string:"href"; 197, identifier:startswith; 198, argument_list; 198, 199; 199, string:"/wiki/"; 200, block; 200, 201; 201, continue_statement; 202, expression_statement; 202, 203; 203, assignment; 203, 204; 203, 205; 204, identifier:match; 205, call; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:re; 208, identifier:search; 209, argument_list; 209, 210; 209, 211; 210, string:r'\(.*?\)'; 211, call; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:a; 214, identifier:get; 215, argument_list; 215, 216; 216, string:'href'; 217, if_statement; 217, 218; 217, 219; 218, identifier:match; 219, block; 219, 220; 220, expression_statement; 220, 221; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:universes; 224, identifier:append; 225, argument_list; 225, 226; 226, subscript; 226, 227; 226, 232; 227, call; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:match; 230, identifier:group; 231, argument_list; 232, slice; 232, 233; 232, 234; 232, 235; 233, integer:1; 234, colon; 235, unary_operator:-; 235, 236; 236, integer:1; 237, try_statement; 237, 238; 237, 300; 238, block; 238, 239; 238, 272; 238, 293; 239, expression_statement; 239, 240; 240, assignment; 240, 241; 240, 242; 241, identifier:character; 242, call; 242, 243; 242, 271; 243, attribute; 243, 244; 243, 269; 243, 270; 244, call; 244, 245; 244, 256; 245, attribute; 245, 246; 245, 254; 245, 255; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:session; 249, identifier:query; 250, argument_list; 250, 251; 251, attribute; 251, 252; 251, 253; 252, identifier:models; 253, identifier:Character; 254, line_continuation:\; 255, identifier:filter; 256, argument_list; 256, 257; 257, comparison_operator:==; 257, 258; 257, 263; 258, attribute; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:models; 261, identifier:Character; 262, identifier:url; 263, call; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:a; 266, identifier:get; 267, argument_list; 267, 268; 268, string:"href"; 269, line_continuation:\; 270, identifier:one; 271, argument_list; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:appearance; 275, call; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:models; 278, identifier:MovieAppearance; 279, argument_list; 279, 280; 279, 285; 279, 290; 280, keyword_argument; 280, 281; 280, 282; 281, identifier:movie_id; 282, attribute; 282, 283; 282, 284; 283, identifier:movie; 284, identifier:id; 285, keyword_argument; 285, 286; 285, 287; 286, identifier:character_id; 287, attribute; 287, 288; 287, 289; 288, identifier:character; 289, identifier:id; 290, keyword_argument; 290, 291; 290, 292; 291, identifier:appearance_type; 292, identifier:appearance_type; 293, expression_statement; 293, 294; 294, call; 294, 295; 294, 298; 295, attribute; 295, 296; 295, 297; 296, identifier:session; 297, identifier:add; 298, argument_list; 298, 299; 299, identifier:appearance; 300, except_clause; 300, 301; 300, 302; 301, identifier:NoResultFound; 302, block; 302, 303; 303, pass_statement; 304, break_statement; 305, elif_clause; 305, 306; 305, 311; 306, comparison_operator:==; 306, 307; 306, 310; 307, attribute; 307, 308; 307, 309; 308, identifier:node; 309, identifier:tag; 310, string:'p'; 311, block; 311, 312; 312, expression_statement; 312, 313; 313, assignment; 313, 314; 313, 315; 314, identifier:appearance_type; 315, call; 315, 316; 315, 337; 316, attribute; 316, 317; 316, 336; 317, call; 317, 318; 317, 334; 318, attribute; 318, 319; 318, 333; 319, call; 319, 320; 319, 332; 320, attribute; 320, 321; 320, 331; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, string:" "; 324, identifier:join; 325, argument_list; 325, 326; 326, call; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:node; 329, identifier:itertext; 330, argument_list; 331, identifier:strip; 332, argument_list; 333, identifier:strip; 334, argument_list; 334, 335; 335, string:':'; 336, identifier:strip; 337, argument_list; 338, expression_statement; 338, 339; 339, assignment; 339, 340; 339, 341; 340, identifier:node; 341, call; 341, 342; 341, 345; 342, attribute; 342, 343; 342, 344; 343, identifier:node; 344, identifier:getnext; 345, argument_list; 346, expression_statement; 346, 347; 347, call; 347, 348; 347, 349; 348, identifier:print; 349, argument_list; 349, 350; 350, string:"\nNumber of character appearances per universe: "; 351, expression_statement; 351, 352; 352, call; 352, 353; 352, 354; 353, identifier:print; 354, argument_list; 354, 355; 355, call; 355, 356; 355, 366; 356, attribute; 356, 357; 356, 365; 357, call; 357, 358; 357, 361; 358, attribute; 358, 359; 358, 360; 359, identifier:pd; 360, identifier:Series; 361, argument_list; 361, 362; 362, keyword_argument; 362, 363; 362, 364; 363, identifier:data; 364, identifier:universes; 365, identifier:value_counts; 366, argument_list; 367, expression_statement; 367, 368; 368, call; 368, 369; 368, 372; 369, attribute; 369, 370; 369, 371; 370, identifier:session; 371, identifier:commit; 372, argument_list; 373, expression_statement; 373, 374; 374, call; 374, 375; 374, 378; 375, attribute; 375, 376; 375, 377; 376, identifier:session; 377, identifier:close; 378, argument_list; 379, expression_statement; 379, 380; 380, call; 380, 381; 380, 384; 381, attribute; 381, 382; 381, 383; 382, identifier:self; 383, identifier:mark_complete; 384, argument_list
def run(self): request_cache = cache.get_request_cache() session = client.get_client().create_session() self.mark_incomplete() universes = [] with session.no_autoflush: movies = session.query(models.Movie).all() for movie in movies: article = request_cache.get("http://marvel.wikia.com" + movie.url, xpath="//article[@id='WikiaMainContent']", rate_limit=0.5) doc = html.fromstring(article) node = doc.xpath("//span[@id='Appearances']")[0] node = node.getparent() appearance_type = "Featured Characters" node = node.getnext() while node is not None and node.tag != 'h2': if node.tag == 'ul' and ('characters' in appearance_type.lower() or 'villains' in appearance_type.lower()): for li in node.iter('li'): for a in li: if a.tag != 'a': continue if "image" in a.get("class", "") or not a.get("href").startswith("/wiki/"): continue match = re.search(r'\(.*?\)', a.get('href')) if match: universes.append(match.group()[1:-1]) try: character = session.query(models.Character) \ .filter(models.Character.url == a.get("href")) \ .one() appearance = models.MovieAppearance(movie_id=movie.id, character_id=character.id, appearance_type=appearance_type) session.add(appearance) except NoResultFound: pass break elif node.tag == 'p': appearance_type = " ".join(node.itertext()).strip().strip(':').strip() node = node.getnext() print("\nNumber of character appearances per universe: ") print(pd.Series(data=universes).value_counts()) session.commit() session.close() self.mark_complete()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_argsort; 3, parameters; 3, 4; 3, 5; 4, identifier:y_score; 5, default_parameter; 5, 6; 5, 7; 6, identifier:k; 7, None; 8, block; 8, 9; 8, 17; 8, 27; 8, 41; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ranks; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:y_score; 15, identifier:argsort; 16, argument_list; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:argsort; 20, subscript; 20, 21; 20, 22; 21, identifier:ranks; 22, slice; 22, 23; 22, 24; 22, 25; 23, colon; 24, colon; 25, unary_operator:-; 25, 26; 26, integer:1; 27, if_statement; 27, 28; 27, 31; 28, comparison_operator:is; 28, 29; 28, 30; 29, identifier:k; 30, None; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:argsort; 35, subscript; 35, 36; 35, 37; 36, identifier:argsort; 37, slice; 37, 38; 37, 39; 37, 40; 38, integer:0; 39, colon; 40, identifier:k; 41, return_statement; 41, 42; 42, identifier:argsort
def _argsort(y_score, k=None): ranks = y_score.argsort() argsort = ranks[::-1] if k is not None: argsort = argsort[0:k] return argsort
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:formula; 3, parameters; 3, 4; 4, identifier:mol; 5, block; 5, 6; 5, 13; 5, 20; 5, 26; 5, 200; 5, 225; 5, 229; 5, 261; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:mol; 10, identifier:require; 11, argument_list; 11, 12; 12, string:"Valence"; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:mol; 17, identifier:require; 18, argument_list; 18, 19; 19, string:"Topology"; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:total_cntr; 23, call; 23, 24; 23, 25; 24, identifier:Counter; 25, argument_list; 26, for_statement; 26, 27; 26, 28; 26, 41; 27, identifier:m; 28, call; 28, 29; 28, 30; 29, identifier:sorted; 30, argument_list; 30, 31; 30, 35; 30, 38; 31, call; 31, 32; 31, 33; 32, identifier:mols_iter; 33, argument_list; 33, 34; 34, identifier:mol; 35, keyword_argument; 35, 36; 35, 37; 36, identifier:key; 37, identifier:len; 38, keyword_argument; 38, 39; 38, 40; 39, identifier:reverse; 40, True; 41, block; 41, 42; 41, 48; 41, 65; 41, 69; 41, 79; 41, 104; 41, 114; 41, 139; 41, 161; 41, 189; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:cntr; 45, call; 45, 46; 45, 47; 46, identifier:Counter; 47, argument_list; 48, for_statement; 48, 49; 48, 50; 48, 51; 49, identifier:i; 50, identifier:m; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, augmented_assignment:+=; 53, 54; 53, 55; 54, identifier:cntr; 55, call; 55, 56; 55, 64; 56, attribute; 56, 57; 56, 63; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:mol; 60, identifier:atom; 61, argument_list; 61, 62; 62, identifier:i; 63, identifier:composition; 64, argument_list; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:text; 68, list:[]; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:Cs; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:cntr; 75, identifier:pop; 76, argument_list; 76, 77; 76, 78; 77, string:"C"; 78, integer:0; 79, if_statement; 79, 80; 79, 81; 80, identifier:Cs; 81, block; 81, 82; 81, 89; 82, expression_statement; 82, 83; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:text; 86, identifier:append; 87, argument_list; 87, 88; 88, string:"C"; 89, if_statement; 89, 90; 89, 93; 90, comparison_operator:>; 90, 91; 90, 92; 91, identifier:Cs; 92, integer:1; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:text; 98, identifier:append; 99, argument_list; 99, 100; 100, call; 100, 101; 100, 102; 101, identifier:str; 102, argument_list; 102, 103; 103, identifier:Cs; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:Hs; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:cntr; 110, identifier:pop; 111, argument_list; 111, 112; 111, 113; 112, string:"H"; 113, integer:0; 114, if_statement; 114, 115; 114, 116; 115, identifier:Hs; 116, block; 116, 117; 116, 124; 117, expression_statement; 117, 118; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:text; 121, identifier:append; 122, argument_list; 122, 123; 123, string:"H"; 124, if_statement; 124, 125; 124, 128; 125, comparison_operator:>; 125, 126; 125, 127; 126, identifier:Hs; 127, integer:1; 128, block; 128, 129; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:text; 133, identifier:append; 134, argument_list; 134, 135; 135, call; 135, 136; 135, 137; 136, identifier:str; 137, argument_list; 137, 138; 138, identifier:Hs; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:heteros; 142, call; 142, 143; 142, 144; 143, identifier:sorted; 144, argument_list; 144, 145; 144, 150; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:cntr; 148, identifier:items; 149, argument_list; 150, keyword_argument; 150, 151; 150, 152; 151, identifier:key; 152, lambda; 152, 153; 152, 155; 153, lambda_parameters; 153, 154; 154, identifier:x; 155, call; 155, 156; 155, 157; 156, identifier:atom_number; 157, argument_list; 157, 158; 158, subscript; 158, 159; 158, 160; 159, identifier:x; 160, integer:0; 161, for_statement; 161, 162; 161, 165; 161, 166; 162, pattern_list; 162, 163; 162, 164; 163, identifier:k; 164, identifier:v; 165, identifier:heteros; 166, block; 166, 167; 166, 174; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:text; 171, identifier:append; 172, argument_list; 172, 173; 173, identifier:k; 174, if_statement; 174, 175; 174, 178; 175, comparison_operator:>; 175, 176; 175, 177; 176, identifier:v; 177, integer:1; 178, block; 178, 179; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:text; 183, identifier:append; 184, argument_list; 184, 185; 185, call; 185, 186; 185, 187; 186, identifier:str; 187, argument_list; 187, 188; 188, identifier:v; 189, expression_statement; 189, 190; 190, augmented_assignment:+=; 190, 191; 190, 199; 191, subscript; 191, 192; 191, 193; 192, identifier:total_cntr; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, string:""; 196, identifier:join; 197, argument_list; 197, 198; 198, identifier:text; 199, integer:1; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:total; 203, call; 203, 204; 203, 205; 204, identifier:sorted; 205, argument_list; 205, 206; 205, 211; 205, 222; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:total_cntr; 209, identifier:items; 210, argument_list; 211, keyword_argument; 211, 212; 211, 213; 212, identifier:key; 213, lambda; 213, 214; 213, 216; 214, lambda_parameters; 214, 215; 215, identifier:x; 216, call; 216, 217; 216, 218; 217, identifier:len; 218, argument_list; 218, 219; 219, subscript; 219, 220; 219, 221; 220, identifier:x; 221, integer:0; 222, keyword_argument; 222, 223; 222, 224; 223, identifier:reverse; 224, True; 225, expression_statement; 225, 226; 226, assignment; 226, 227; 226, 228; 227, identifier:total_text; 228, list:[]; 229, for_statement; 229, 230; 229, 233; 229, 234; 230, pattern_list; 230, 231; 230, 232; 231, identifier:k; 232, identifier:v; 233, identifier:total; 234, block; 234, 235; 235, if_statement; 235, 236; 235, 239; 235, 252; 236, comparison_operator:>; 236, 237; 236, 238; 237, identifier:v; 238, integer:1; 239, block; 239, 240; 240, expression_statement; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:total_text; 244, identifier:append; 245, argument_list; 245, 246; 246, binary_operator:+; 246, 247; 246, 251; 247, call; 247, 248; 247, 249; 248, identifier:str; 249, argument_list; 249, 250; 250, identifier:v; 251, identifier:k; 252, else_clause; 252, 253; 253, block; 253, 254; 254, expression_statement; 254, 255; 255, call; 255, 256; 255, 259; 256, attribute; 256, 257; 256, 258; 257, identifier:total_text; 258, identifier:append; 259, argument_list; 259, 260; 260, identifier:k; 261, return_statement; 261, 262; 262, call; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, string:"."; 265, identifier:join; 266, argument_list; 266, 267; 267, identifier:total_text
def formula(mol): mol.require("Valence") mol.require("Topology") total_cntr = Counter() for m in sorted(mols_iter(mol), key=len, reverse=True): cntr = Counter() for i in m: cntr += mol.atom(i).composition() text = [] Cs = cntr.pop("C", 0) if Cs: text.append("C") if Cs > 1: text.append(str(Cs)) Hs = cntr.pop("H", 0) if Hs: text.append("H") if Hs > 1: text.append(str(Hs)) heteros = sorted(cntr.items(), key=lambda x: atom_number(x[0])) for k, v in heteros: text.append(k) if v > 1: text.append(str(v)) total_cntr["".join(text)] += 1 total = sorted(total_cntr.items(), key=lambda x: len(x[0]), reverse=True) total_text = [] for k, v in total: if v > 1: total_text.append(str(v) + k) else: total_text.append(k) return ".".join(total_text)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_start_action_for_section; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:section; 6, block; 6, 7; 6, 13; 6, 24; 6, 34; 6, 52; 6, 56; 6, 60; 6, 71; 6, 99; 6, 114; 6, 128; 6, 137; 6, 146; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:section; 10, string:"configuration"; 11, block; 11, 12; 12, return_statement; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 20; 15, attribute; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:Global; 18, identifier:LOGGER; 19, identifier:debug; 20, argument_list; 20, 21; 21, binary_operator:+; 21, 22; 21, 23; 22, string:"starting actions for section "; 23, identifier:section; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:action_configuration; 27, subscript; 27, 28; 27, 33; 28, attribute; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:Global; 31, identifier:CONFIG_MANAGER; 32, identifier:sections; 33, identifier:section; 34, if_statement; 34, 35; 34, 41; 35, comparison_operator:==; 35, 36; 35, 40; 36, call; 36, 37; 36, 38; 37, identifier:len; 38, argument_list; 38, 39; 39, identifier:action_configuration; 40, integer:0; 41, block; 41, 42; 41, 51; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:Global; 47, identifier:LOGGER; 48, identifier:warn; 49, argument_list; 49, 50; 50, string:f"section {section} has no configuration, skipping"; 51, return_statement; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:action_type; 55, None; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:new_managed_input; 59, list:[]; 60, if_statement; 60, 61; 60, 64; 61, comparison_operator:in; 61, 62; 61, 63; 62, string:"type"; 63, identifier:action_configuration; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:action_type; 68, subscript; 68, 69; 68, 70; 69, identifier:action_configuration; 70, string:"type"; 71, if_statement; 71, 72; 71, 75; 72, comparison_operator:in; 72, 73; 72, 74; 73, string:"input"; 74, identifier:action_configuration; 75, block; 75, 76; 75, 82; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:action_input; 79, subscript; 79, 80; 79, 81; 80, identifier:action_configuration; 81, string:"input"; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:new_managed_input; 85, generator_expression; 85, 86; 85, 91; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:item; 89, identifier:strip; 90, argument_list; 91, for_in_clause; 91, 92; 91, 93; 92, identifier:item; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:action_input; 96, identifier:split; 97, argument_list; 97, 98; 98, string:","; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:my_action; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:Action; 105, identifier:create_action_for_code; 106, argument_list; 106, 107; 106, 108; 106, 109; 106, 110; 107, identifier:action_type; 108, identifier:section; 109, identifier:action_configuration; 110, call; 110, 111; 110, 112; 111, identifier:list; 112, argument_list; 112, 113; 113, identifier:new_managed_input; 114, if_statement; 114, 115; 114, 117; 115, not_operator; 115, 116; 116, identifier:my_action; 117, block; 117, 118; 117, 127; 118, expression_statement; 118, 119; 119, call; 119, 120; 119, 125; 120, attribute; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:Global; 123, identifier:LOGGER; 124, identifier:warn; 125, argument_list; 125, 126; 126, string:f"can't find a type for action {section}, the action will be skipped"; 127, return_statement; 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:actions; 134, identifier:append; 135, argument_list; 135, 136; 136, identifier:my_action; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 144; 139, attribute; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:Global; 142, identifier:LOGGER; 143, identifier:debug; 144, argument_list; 144, 145; 145, string:"updating the subscriptions table"; 146, for_statement; 146, 147; 146, 148; 146, 151; 147, identifier:my_input; 148, attribute; 148, 149; 148, 150; 149, identifier:my_action; 150, identifier:monitored_input; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, call; 153, 154; 153, 165; 154, attribute; 154, 155; 154, 164; 155, call; 155, 156; 155, 161; 156, attribute; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:self; 159, identifier:subscriptions; 160, identifier:setdefault; 161, argument_list; 161, 162; 161, 163; 162, identifier:my_input; 163, list:[]; 164, identifier:append; 165, argument_list; 165, 166; 166, identifier:my_action
def _start_action_for_section(self, section): if section == "configuration": return Global.LOGGER.debug("starting actions for section " + section) action_configuration = Global.CONFIG_MANAGER.sections[ section] if len(action_configuration) == 0: Global.LOGGER.warn(f"section {section} has no configuration, skipping") return action_type = None new_managed_input = [] if "type" in action_configuration: action_type = action_configuration["type"] if "input" in action_configuration: action_input = action_configuration["input"] new_managed_input = (item.strip() for item in action_input.split(",")) my_action = Action.create_action_for_code(action_type, section, action_configuration, list(new_managed_input)) if not my_action: Global.LOGGER.warn(f"can't find a type for action {section}, the action will be skipped") return self.actions.append(my_action) Global.LOGGER.debug("updating the subscriptions table") for my_input in my_action.monitored_input: self.subscriptions.setdefault( my_input, []).append(my_action)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:check_completion; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:task; 5, default_parameter; 5, 6; 5, 7; 6, identifier:mark_incomplete; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:clear; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, identifier:return_stats; 13, False; 14, block; 14, 15; 14, 21; 14, 47; 14, 166; 14, 180; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:to_clear; 18, call; 18, 19; 18, 20; 19, identifier:dict; 20, argument_list; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 26; 23, pattern_list; 23, 24; 23, 25; 24, identifier:is_complete; 25, identifier:stats; 26, call; 26, 27; 26, 28; 27, identifier:_check_completion; 28, argument_list; 28, 29; 28, 30; 28, 33; 28, 36; 28, 39; 28, 44; 29, identifier:task; 30, keyword_argument; 30, 31; 30, 32; 31, identifier:mark_incomplete; 32, identifier:mark_incomplete; 33, keyword_argument; 33, 34; 33, 35; 34, identifier:clear; 35, identifier:clear; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:stats; 38, dictionary; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:visited; 41, call; 41, 42; 41, 43; 42, identifier:dict; 43, argument_list; 44, keyword_argument; 44, 45; 44, 46; 45, identifier:to_clear; 46, identifier:to_clear; 47, while_statement; 47, 48; 47, 49; 48, identifier:to_clear; 49, block; 49, 50; 49, 54; 49, 157; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:found_clearable_task; 53, False; 54, for_statement; 54, 55; 54, 56; 54, 64; 55, identifier:task_id; 56, call; 56, 57; 56, 58; 57, identifier:list; 58, argument_list; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:to_clear; 62, identifier:keys; 63, argument_list; 64, block; 64, 65; 64, 71; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:v; 68, subscript; 68, 69; 68, 70; 69, identifier:to_clear; 70, identifier:task_id; 71, if_statement; 71, 72; 71, 76; 72, not_operator; 72, 73; 73, subscript; 73, 74; 73, 75; 74, identifier:v; 75, string:'required_by'; 76, block; 76, 77; 76, 81; 76, 87; 76, 136; 76, 140; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:found_clearable_task; 80, True; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:task; 84, subscript; 84, 85; 84, 86; 85, identifier:v; 86, string:'task'; 87, if_statement; 87, 88; 87, 93; 87, 123; 88, call; 88, 89; 88, 90; 89, identifier:isinstance; 90, argument_list; 90, 91; 90, 92; 91, identifier:task; 92, identifier:ORMTask; 93, block; 93, 94; 93, 100; 93, 106; 93, 112; 94, expression_statement; 94, 95; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:task; 98, identifier:mark_incomplete; 99, argument_list; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:task; 104, identifier:clear; 105, argument_list; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:_increment_stats; 109, argument_list; 109, 110; 109, 111; 110, identifier:stats; 111, string:'Cleared'; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 119; 114, attribute; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:config; 117, identifier:logger; 118, identifier:info; 119, argument_list; 119, 120; 120, binary_operator:+; 120, 121; 120, 122; 121, string:"Cleared task: "; 122, identifier:task_id; 123, else_clause; 123, 124; 124, block; 124, 125; 125, expression_statement; 125, 126; 126, call; 126, 127; 126, 132; 127, attribute; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:config; 130, identifier:logger; 131, identifier:info; 132, argument_list; 132, 133; 133, binary_operator:+; 133, 134; 133, 135; 134, string:'Cannot clear task, not an ORMTask: '; 135, identifier:task_id; 136, delete_statement; 136, 137; 137, subscript; 137, 138; 137, 139; 138, identifier:to_clear; 139, identifier:task_id; 140, for_statement; 140, 141; 140, 142; 140, 147; 141, identifier:w; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:to_clear; 145, identifier:values; 146, argument_list; 147, block; 147, 148; 148, expression_statement; 148, 149; 149, call; 149, 150; 149, 155; 150, attribute; 150, 151; 150, 154; 151, subscript; 151, 152; 151, 153; 152, identifier:w; 153, string:'required_by'; 154, identifier:discard; 155, argument_list; 155, 156; 156, identifier:task_id; 157, if_statement; 157, 158; 157, 160; 158, not_operator; 158, 159; 159, identifier:found_clearable_task; 160, block; 160, 161; 161, raise_statement; 161, 162; 162, call; 162, 163; 162, 164; 163, identifier:RuntimeError; 164, argument_list; 164, 165; 165, string:"Error in recursive task clearing, no clearable task found"; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 173; 168, attribute; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:config; 171, identifier:logger; 172, identifier:info; 173, argument_list; 173, 174; 174, binary_operator:+; 174, 175; 174, 176; 175, string:"Task completion checking, summary:\n"; 176, call; 176, 177; 176, 178; 177, identifier:str; 178, argument_list; 178, 179; 179, identifier:stats; 180, if_statement; 180, 181; 180, 182; 180, 187; 181, identifier:return_stats; 182, block; 182, 183; 183, return_statement; 183, 184; 184, expression_list; 184, 185; 184, 186; 185, identifier:is_complete; 186, identifier:stats; 187, else_clause; 187, 188; 188, block; 188, 189; 189, return_statement; 189, 190; 190, identifier:is_complete
def check_completion(task, mark_incomplete=False, clear=False, return_stats=False): to_clear = dict() is_complete, stats = _check_completion(task, mark_incomplete=mark_incomplete, clear=clear, stats={}, visited=dict(), to_clear=to_clear) while to_clear: found_clearable_task = False for task_id in list(to_clear.keys()): v = to_clear[task_id] if not v['required_by']: found_clearable_task = True task = v['task'] if isinstance(task, ORMTask): task.mark_incomplete() task.clear() _increment_stats(stats, 'Cleared') config.logger.info("Cleared task: " + task_id) else: config.logger.info('Cannot clear task, not an ORMTask: ' + task_id) del to_clear[task_id] for w in to_clear.values(): w['required_by'].discard(task_id) if not found_clearable_task: raise RuntimeError("Error in recursive task clearing, no clearable task found") config.logger.info("Task completion checking, summary:\n" + str(stats)) if return_stats: return is_complete, stats else: return is_complete
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_connection_string; 3, parameters; 3, 4; 3, 5; 4, identifier:params; 5, default_parameter; 5, 6; 5, 7; 6, identifier:hide_password; 7, True; 8, block; 8, 9; 8, 17; 8, 27; 8, 37; 8, 47; 8, 57; 8, 67; 8, 77; 8, 105; 8, 164; 8, 170; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:connection_string; 12, binary_operator:+; 12, 13; 12, 16; 13, subscript; 13, 14; 13, 15; 14, identifier:params; 15, string:'driver'; 16, string:'://'; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:user; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:params; 23, identifier:get; 24, argument_list; 24, 25; 24, 26; 25, string:'user'; 26, None; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:password; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:params; 33, identifier:get; 34, argument_list; 34, 35; 34, 36; 35, string:'password'; 36, None; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:host; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:params; 43, identifier:get; 44, argument_list; 44, 45; 44, 46; 45, string:'host'; 46, None; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:port; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:params; 53, identifier:get; 54, argument_list; 54, 55; 54, 56; 55, string:'port'; 56, None; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:database; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:params; 63, identifier:get; 64, argument_list; 64, 65; 64, 66; 65, string:'database'; 66, None; 67, if_statement; 67, 68; 67, 71; 68, comparison_operator:is; 68, 69; 68, 70; 69, identifier:database; 70, None; 71, block; 71, 72; 72, raise_statement; 72, 73; 73, call; 73, 74; 73, 75; 74, identifier:ValueError; 75, argument_list; 75, 76; 76, string:"Field 'database' of connection parameters cannot be None."; 77, if_statement; 77, 78; 77, 85; 78, boolean_operator:and; 78, 79; 78, 82; 79, comparison_operator:is; 79, 80; 79, 81; 80, identifier:password; 81, None; 82, comparison_operator:is; 82, 83; 82, 84; 83, identifier:user; 84, None; 85, block; 85, 86; 85, 95; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:password; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:Client; 92, identifier:_get_password; 93, argument_list; 93, 94; 94, identifier:params; 95, if_statement; 95, 96; 95, 99; 96, comparison_operator:is; 96, 97; 96, 98; 97, identifier:password; 98, None; 99, block; 99, 100; 100, raise_statement; 100, 101; 101, call; 101, 102; 101, 103; 102, identifier:RuntimeError; 103, argument_list; 103, 104; 104, string:"Password not defined and not available in keyring."; 105, if_statement; 105, 106; 105, 109; 106, comparison_operator:is; 106, 107; 106, 108; 107, identifier:host; 108, None; 109, block; 109, 110; 109, 146; 109, 150; 110, if_statement; 110, 111; 110, 114; 111, comparison_operator:is; 111, 112; 111, 113; 112, identifier:user; 113, None; 114, block; 114, 115; 114, 119; 114, 142; 115, expression_statement; 115, 116; 116, augmented_assignment:+=; 116, 117; 116, 118; 117, identifier:connection_string; 118, identifier:user; 119, if_statement; 119, 120; 119, 126; 120, comparison_operator:>; 120, 121; 120, 125; 121, call; 121, 122; 121, 123; 122, identifier:len; 123, argument_list; 123, 124; 124, identifier:password; 125, integer:0; 126, block; 126, 127; 127, if_statement; 127, 128; 127, 129; 127, 134; 128, identifier:hide_password; 129, block; 129, 130; 130, expression_statement; 130, 131; 131, augmented_assignment:+=; 131, 132; 131, 133; 132, identifier:connection_string; 133, string:":[password hidden]"; 134, else_clause; 134, 135; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, augmented_assignment:+=; 137, 138; 137, 139; 138, identifier:connection_string; 139, binary_operator:+; 139, 140; 139, 141; 140, string:":"; 141, identifier:password; 142, expression_statement; 142, 143; 143, augmented_assignment:+=; 143, 144; 143, 145; 144, identifier:connection_string; 145, string:"@"; 146, expression_statement; 146, 147; 147, augmented_assignment:+=; 147, 148; 147, 149; 148, identifier:connection_string; 149, identifier:host; 150, if_statement; 150, 151; 150, 154; 151, comparison_operator:is; 151, 152; 151, 153; 152, identifier:port; 153, None; 154, block; 154, 155; 155, expression_statement; 155, 156; 156, augmented_assignment:+=; 156, 157; 156, 158; 157, identifier:connection_string; 158, binary_operator:+; 158, 159; 158, 160; 159, string:':'; 160, call; 160, 161; 160, 162; 161, identifier:str; 162, argument_list; 162, 163; 163, identifier:port; 164, expression_statement; 164, 165; 165, augmented_assignment:+=; 165, 166; 165, 167; 166, identifier:connection_string; 167, binary_operator:+; 167, 168; 167, 169; 168, string:'/'; 169, identifier:database; 170, return_statement; 170, 171; 171, identifier:connection_string
def get_connection_string(params, hide_password=True): connection_string = params['driver'] + '://' user = params.get('user', None) password = params.get('password', None) host = params.get('host', None) port = params.get('port', None) database = params.get('database', None) if database is None: raise ValueError("Field 'database' of connection parameters cannot be None.") if password is None and user is not None: password = Client._get_password(params) if password is None: raise RuntimeError("Password not defined and not available in keyring.") if host is not None: if user is not None: connection_string += user if len(password) > 0: if hide_password: connection_string += ":[password hidden]" else: connection_string += ":" + password connection_string += "@" connection_string += host if port is not None: connection_string += ':' + str(port) connection_string += '/' + database return connection_string
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:movie_network; 3, parameters; 4, block; 4, 5; 4, 14; 4, 20; 4, 28; 4, 36; 4, 69; 4, 78; 4, 96; 4, 105; 4, 156; 4, 165; 4, 186; 4, 192; 4, 198; 4, 210; 4, 277; 4, 329; 4, 364; 4, 378; 4, 388; 4, 398; 4, 417; 4, 424; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:template; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:jenv; 11, identifier:get_template; 12, argument_list; 12, 13; 13, string:"movie_network.html"; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:context; 17, call; 17, 18; 17, 19; 18, identifier:dict; 19, argument_list; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:cl; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:client; 26, identifier:get_client; 27, argument_list; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:session; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:cl; 34, identifier:create_session; 35, argument_list; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:query; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:session; 42, identifier:query; 43, argument_list; 43, 44; 43, 49; 43, 54; 43, 59; 43, 64; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:models; 47, identifier:Movie; 48, identifier:id; 49, attribute; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:models; 52, identifier:Movie; 53, identifier:name; 54, attribute; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:models; 57, identifier:Movie; 58, identifier:url; 59, attribute; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:models; 62, identifier:Movie; 63, identifier:budget_inflation_adjusted; 64, attribute; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:models; 67, identifier:Movie; 68, identifier:imdb_rating; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:movies; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:cl; 75, identifier:df_query; 76, argument_list; 76, 77; 77, identifier:query; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:query; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:session; 84, identifier:query; 85, argument_list; 85, 86; 85, 91; 86, attribute; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:models; 89, identifier:MovieAppearance; 90, identifier:movie_id; 91, attribute; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:models; 94, identifier:MovieAppearance; 95, identifier:character_id; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:appearances; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:cl; 102, identifier:df_query; 103, argument_list; 103, 104; 104, identifier:query; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:query; 108, call; 108, 109; 108, 132; 109, attribute; 109, 110; 109, 130; 109, 131; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:session; 113, identifier:query; 114, argument_list; 114, 115; 114, 120; 114, 125; 115, attribute; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:models; 118, identifier:Character; 119, identifier:id; 120, attribute; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:models; 123, identifier:Character; 124, identifier:url; 125, attribute; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:models; 128, identifier:Character; 129, identifier:name; 130, line_continuation:\; 131, identifier:filter; 132, argument_list; 132, 133; 133, call; 133, 134; 133, 141; 134, attribute; 134, 135; 134, 140; 135, attribute; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:models; 138, identifier:Character; 139, identifier:id; 140, identifier:in_; 141, argument_list; 141, 142; 142, list_comprehension; 142, 143; 142, 147; 143, call; 143, 144; 143, 145; 144, identifier:int; 145, argument_list; 145, 146; 146, identifier:i; 147, for_in_clause; 147, 148; 147, 149; 148, identifier:i; 149, call; 149, 150; 149, 155; 150, attribute; 150, 151; 150, 154; 151, subscript; 151, 152; 151, 153; 152, identifier:appearances; 153, string:'character_id'; 154, identifier:unique; 155, argument_list; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:characters; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:cl; 162, identifier:df_query; 163, argument_list; 163, 164; 164, identifier:query; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:graph; 168, call; 168, 169; 168, 170; 169, identifier:dict; 170, argument_list; 170, 171; 170, 174; 170, 177; 170, 180; 170, 183; 171, keyword_argument; 171, 172; 171, 173; 172, identifier:nodes; 173, list:[]; 174, keyword_argument; 174, 175; 174, 176; 175, identifier:graph; 176, list:[]; 177, keyword_argument; 177, 178; 177, 179; 178, identifier:links; 179, list:[]; 180, keyword_argument; 180, 181; 180, 182; 181, identifier:directed; 182, False; 183, keyword_argument; 183, 184; 183, 185; 184, identifier:multigraph; 185, True; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 189; 188, identifier:movie_node_id; 189, call; 189, 190; 189, 191; 190, identifier:dict; 191, argument_list; 192, expression_statement; 192, 193; 193, assignment; 193, 194; 193, 195; 194, identifier:character_node_id; 195, call; 195, 196; 195, 197; 196, identifier:dict; 197, argument_list; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:movie_size_factor; 201, binary_operator:/; 201, 202; 201, 203; 202, float:100.; 203, call; 203, 204; 203, 209; 204, attribute; 204, 205; 204, 208; 205, subscript; 205, 206; 205, 207; 206, identifier:movies; 207, string:'budget_inflation_adjusted'; 208, identifier:max; 209, argument_list; 210, for_statement; 210, 211; 210, 214; 210, 219; 211, pattern_list; 211, 212; 211, 213; 212, identifier:_; 213, identifier:data; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:movies; 217, identifier:iterrows; 218, argument_list; 219, block; 219, 220; 219, 233; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 227; 222, subscript; 222, 223; 222, 224; 223, identifier:movie_node_id; 224, subscript; 224, 225; 224, 226; 225, identifier:data; 226, string:'id'; 227, call; 227, 228; 227, 229; 228, identifier:len; 229, argument_list; 229, 230; 230, subscript; 230, 231; 230, 232; 231, identifier:graph; 232, string:'nodes'; 233, expression_statement; 233, 234; 234, call; 234, 235; 234, 240; 235, attribute; 235, 236; 235, 239; 236, subscript; 236, 237; 236, 238; 237, identifier:graph; 238, string:'nodes'; 239, identifier:append; 240, argument_list; 240, 241; 241, call; 241, 242; 241, 243; 242, identifier:dict; 243, argument_list; 243, 244; 243, 249; 243, 260; 243, 267; 243, 270; 244, keyword_argument; 244, 245; 244, 246; 245, identifier:id; 246, subscript; 246, 247; 246, 248; 247, identifier:data; 248, string:'name'; 249, keyword_argument; 249, 250; 249, 251; 250, identifier:size; 251, call; 251, 252; 251, 253; 252, identifier:max; 253, argument_list; 253, 254; 253, 255; 254, float:5.; 255, binary_operator:*; 255, 256; 255, 259; 256, subscript; 256, 257; 256, 258; 257, identifier:data; 258, string:'budget_inflation_adjusted'; 259, identifier:movie_size_factor; 260, keyword_argument; 260, 261; 260, 262; 261, identifier:score; 262, binary_operator:/; 262, 263; 262, 266; 263, subscript; 263, 264; 263, 265; 264, identifier:data; 265, string:'imdb_rating'; 266, float:10.; 267, keyword_argument; 267, 268; 267, 269; 268, identifier:type; 269, string:'square'; 270, keyword_argument; 270, 271; 270, 272; 271, identifier:url; 272, binary_operator:+; 272, 273; 272, 274; 273, string:"http://marvel.wikia.com"; 274, subscript; 274, 275; 274, 276; 275, identifier:data; 276, string:'url'; 277, for_statement; 277, 278; 277, 281; 277, 286; 278, pattern_list; 278, 279; 278, 280; 279, identifier:_; 280, identifier:data; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:characters; 284, identifier:iterrows; 285, argument_list; 286, block; 286, 287; 286, 300; 287, expression_statement; 287, 288; 288, assignment; 288, 289; 288, 294; 289, subscript; 289, 290; 289, 291; 290, identifier:character_node_id; 291, subscript; 291, 292; 291, 293; 292, identifier:data; 293, string:'id'; 294, call; 294, 295; 294, 296; 295, identifier:len; 296, argument_list; 296, 297; 297, subscript; 297, 298; 297, 299; 298, identifier:graph; 299, string:'nodes'; 300, expression_statement; 300, 301; 301, call; 301, 302; 301, 307; 302, attribute; 302, 303; 302, 306; 303, subscript; 303, 304; 303, 305; 304, identifier:graph; 305, string:'nodes'; 306, identifier:append; 307, argument_list; 307, 308; 308, call; 308, 309; 308, 310; 309, identifier:dict; 310, argument_list; 310, 311; 310, 316; 310, 319; 310, 322; 311, keyword_argument; 311, 312; 311, 313; 312, identifier:id; 313, subscript; 313, 314; 313, 315; 314, identifier:data; 315, string:'name'; 316, keyword_argument; 316, 317; 316, 318; 317, identifier:size; 318, integer:10; 319, keyword_argument; 319, 320; 319, 321; 320, identifier:type; 321, string:'circle'; 322, keyword_argument; 322, 323; 322, 324; 323, identifier:url; 324, binary_operator:+; 324, 325; 324, 326; 325, string:"http://marvel.wikia.com"; 326, subscript; 326, 327; 326, 328; 327, identifier:data; 328, string:'url'; 329, for_statement; 329, 330; 329, 333; 329, 338; 330, pattern_list; 330, 331; 330, 332; 331, identifier:_; 332, identifier:data; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:appearances; 336, identifier:iterrows; 337, argument_list; 338, block; 338, 339; 339, expression_statement; 339, 340; 340, call; 340, 341; 340, 346; 341, attribute; 341, 342; 341, 345; 342, subscript; 342, 343; 342, 344; 343, identifier:graph; 344, string:'links'; 345, identifier:append; 346, argument_list; 346, 347; 347, call; 347, 348; 347, 349; 348, identifier:dict; 349, argument_list; 349, 350; 349, 357; 350, keyword_argument; 350, 351; 350, 352; 351, identifier:source; 352, subscript; 352, 353; 352, 354; 353, identifier:movie_node_id; 354, subscript; 354, 355; 354, 356; 355, identifier:data; 356, string:'movie_id'; 357, keyword_argument; 357, 358; 357, 359; 358, identifier:target; 359, subscript; 359, 360; 359, 361; 360, identifier:character_node_id; 361, subscript; 361, 362; 361, 363; 362, identifier:data; 363, string:'character_id'; 364, expression_statement; 364, 365; 365, assignment; 365, 366; 365, 369; 366, subscript; 366, 367; 366, 368; 367, identifier:context; 368, string:'graph'; 369, call; 369, 370; 369, 373; 370, attribute; 370, 371; 370, 372; 371, identifier:json; 372, identifier:dumps; 373, argument_list; 373, 374; 373, 375; 374, identifier:graph; 375, keyword_argument; 375, 376; 375, 377; 376, identifier:indent; 377, integer:4; 378, expression_statement; 378, 379; 379, assignment; 379, 380; 379, 381; 380, identifier:out_file; 381, call; 381, 382; 381, 385; 382, attribute; 382, 383; 382, 384; 383, identifier:path; 384, identifier:join; 385, argument_list; 385, 386; 385, 387; 386, identifier:out_dir; 387, string:"movie_network.html"; 388, expression_statement; 388, 389; 389, assignment; 389, 390; 389, 391; 390, identifier:html_content; 391, call; 391, 392; 391, 395; 392, attribute; 392, 393; 392, 394; 393, identifier:template; 394, identifier:render; 395, argument_list; 395, 396; 396, dictionary_splat; 396, 397; 397, identifier:context; 398, with_statement; 398, 399; 398, 409; 399, with_clause; 399, 400; 400, with_item; 400, 401; 401, as_pattern; 401, 402; 401, 407; 402, call; 402, 403; 402, 404; 403, identifier:open; 404, argument_list; 404, 405; 404, 406; 405, identifier:out_file; 406, string:'w'; 407, as_pattern_target; 407, 408; 408, identifier:f; 409, block; 409, 410; 410, expression_statement; 410, 411; 411, call; 411, 412; 411, 415; 412, attribute; 412, 413; 412, 414; 413, identifier:f; 414, identifier:write; 415, argument_list; 415, 416; 416, identifier:html_content; 417, expression_statement; 417, 418; 418, call; 418, 419; 418, 422; 419, attribute; 419, 420; 419, 421; 420, identifier:plt; 421, identifier:close; 422, argument_list; 422, 423; 423, string:'all'; 424, expression_statement; 424, 425; 425, call; 425, 426; 425, 429; 426, attribute; 426, 427; 426, 428; 427, identifier:session; 428, identifier:close; 429, argument_list
def movie_network(): template = jenv.get_template("movie_network.html") context = dict() cl = client.get_client() session = cl.create_session() query = session.query(models.Movie.id, models.Movie.name, models.Movie.url, models.Movie.budget_inflation_adjusted, models.Movie.imdb_rating) movies = cl.df_query(query) query = session.query(models.MovieAppearance.movie_id, models.MovieAppearance.character_id) appearances = cl.df_query(query) query = session.query(models.Character.id, models.Character.url, models.Character.name) \ .filter(models.Character.id.in_([int(i) for i in appearances['character_id'].unique()])) characters = cl.df_query(query) graph = dict(nodes=[], graph=[], links=[], directed=False, multigraph=True) movie_node_id = dict() character_node_id = dict() movie_size_factor = 100. / movies['budget_inflation_adjusted'].max() for _, data in movies.iterrows(): movie_node_id[data['id']] = len(graph['nodes']) graph['nodes'].append(dict(id=data['name'], size=max(5., data['budget_inflation_adjusted'] * movie_size_factor), score=data['imdb_rating'] / 10., type='square', url="http://marvel.wikia.com" + data['url'])) for _, data in characters.iterrows(): character_node_id[data['id']] = len(graph['nodes']) graph['nodes'].append(dict(id=data['name'], size=10, type='circle', url="http://marvel.wikia.com" + data['url'])) for _, data in appearances.iterrows(): graph['links'].append(dict(source=movie_node_id[data['movie_id']], target=character_node_id[data['character_id']])) context['graph'] = json.dumps(graph, indent=4) out_file = path.join(out_dir, "movie_network.html") html_content = template.render(**context) with open(out_file, 'w') as f: f.write(html_content) plt.close('all') session.close()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:better_exchook; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:etype; 5, identifier:value; 6, identifier:tb; 7, default_parameter; 7, 8; 7, 9; 8, identifier:debugshell; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:autodebugshell; 12, True; 13, default_parameter; 13, 14; 13, 15; 14, identifier:file; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:with_color; 18, None; 19, block; 19, 20; 19, 31; 19, 45; 19, 54; 19, 70; 19, 78; 19, 120; 19, 123; 19, 147; 19, 205; 19, 261; 19, 283; 19, 304; 20, if_statement; 20, 21; 20, 24; 21, comparison_operator:is; 21, 22; 21, 23; 22, identifier:file; 23, None; 24, block; 24, 25; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:file; 28, attribute; 28, 29; 28, 30; 29, identifier:sys; 30, identifier:stderr; 31, function_definition; 31, 32; 31, 33; 31, 35; 32, function_name:output; 33, parameters; 33, 34; 34, identifier:ln; 35, block; 35, 36; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:file; 40, identifier:write; 41, argument_list; 41, 42; 42, binary_operator:+; 42, 43; 42, 44; 43, identifier:ln; 44, string:"\n"; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:color; 48, call; 48, 49; 48, 50; 49, identifier:Color; 50, argument_list; 50, 51; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:enable; 53, identifier:with_color; 54, expression_statement; 54, 55; 55, call; 55, 56; 55, 57; 56, identifier:output; 57, argument_list; 57, 58; 58, call; 58, 59; 58, 60; 59, identifier:color; 60, argument_list; 60, 61; 60, 62; 60, 67; 61, string:"EXCEPTION"; 62, subscript; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:color; 65, identifier:fg_colors; 66, integer:1; 67, keyword_argument; 67, 68; 67, 69; 68, identifier:bold; 69, True; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 75; 72, pattern_list; 72, 73; 72, 74; 73, identifier:all_locals; 74, identifier:all_globals; 75, expression_list; 75, 76; 75, 77; 76, dictionary; 77, dictionary; 78, if_statement; 78, 79; 78, 82; 78, 105; 79, comparison_operator:is; 79, 80; 79, 81; 80, identifier:tb; 81, None; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:print_tb; 86, argument_list; 86, 87; 86, 88; 86, 91; 86, 94; 86, 97; 86, 100; 87, identifier:tb; 88, keyword_argument; 88, 89; 88, 90; 89, identifier:allLocals; 90, identifier:all_locals; 91, keyword_argument; 91, 92; 91, 93; 92, identifier:allGlobals; 93, identifier:all_globals; 94, keyword_argument; 94, 95; 94, 96; 95, identifier:file; 96, identifier:file; 97, keyword_argument; 97, 98; 97, 99; 98, identifier:withTitle; 99, True; 100, keyword_argument; 100, 101; 100, 102; 101, identifier:with_color; 102, attribute; 102, 103; 102, 104; 103, identifier:color; 104, identifier:enable; 105, else_clause; 105, 106; 106, block; 106, 107; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 110; 109, identifier:output; 110, argument_list; 110, 111; 111, call; 111, 112; 111, 113; 112, identifier:color; 113, argument_list; 113, 114; 113, 115; 114, string:"better_exchook: traceback unknown"; 115, subscript; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:color; 118, identifier:fg_colors; 119, integer:1; 120, import_statement; 120, 121; 121, dotted_name; 121, 122; 122, identifier:types; 123, function_definition; 123, 124; 123, 125; 123, 127; 124, function_name:_some_str; 125, parameters; 125, 126; 126, identifier:value; 127, block; 127, 128; 128, try_statement; 128, 129; 128, 135; 129, block; 129, 130; 130, return_statement; 130, 131; 131, call; 131, 132; 131, 133; 132, identifier:str; 133, argument_list; 133, 134; 134, identifier:value; 135, except_clause; 135, 136; 135, 137; 136, identifier:Exception; 137, block; 137, 138; 138, return_statement; 138, 139; 139, binary_operator:%; 139, 140; 139, 141; 140, string:'<unprintable %s object>'; 141, attribute; 141, 142; 141, 146; 142, call; 142, 143; 142, 144; 143, identifier:type; 144, argument_list; 144, 145; 145, identifier:value; 146, identifier:__name__; 147, function_definition; 147, 148; 147, 149; 147, 152; 148, function_name:_format_final_exc_line; 149, parameters; 149, 150; 149, 151; 150, identifier:etype; 151, identifier:value; 152, block; 152, 153; 152, 160; 152, 203; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:value_str; 156, call; 156, 157; 156, 158; 157, identifier:_some_str; 158, argument_list; 158, 159; 159, identifier:value; 160, if_statement; 160, 161; 160, 167; 160, 182; 161, boolean_operator:or; 161, 162; 161, 165; 162, comparison_operator:is; 162, 163; 162, 164; 163, identifier:value; 164, None; 165, not_operator; 165, 166; 166, identifier:value_str; 167, block; 167, 168; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:line; 171, call; 171, 172; 171, 173; 172, identifier:color; 173, argument_list; 173, 174; 173, 177; 174, binary_operator:%; 174, 175; 174, 176; 175, string:"%s"; 176, identifier:etype; 177, subscript; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:color; 180, identifier:fg_colors; 181, integer:1; 182, else_clause; 182, 183; 183, block; 183, 184; 184, expression_statement; 184, 185; 185, assignment; 185, 186; 185, 187; 186, identifier:line; 187, binary_operator:+; 187, 188; 187, 199; 188, call; 188, 189; 188, 190; 189, identifier:color; 190, argument_list; 190, 191; 190, 194; 191, binary_operator:%; 191, 192; 191, 193; 192, string:"%s"; 193, identifier:etype; 194, subscript; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:color; 197, identifier:fg_colors; 198, integer:1; 199, binary_operator:%; 199, 200; 199, 201; 200, string:": %s"; 201, tuple; 201, 202; 202, identifier:value_str; 203, return_statement; 203, 204; 204, identifier:line; 205, if_statement; 205, 206; 205, 238; 205, 248; 206, parenthesized_expression; 206, 207; 207, boolean_operator:or; 207, 208; 207, 232; 208, boolean_operator:or; 208, 209; 208, 229; 209, boolean_operator:or; 209, 210; 209, 215; 210, call; 210, 211; 210, 212; 211, identifier:isinstance; 212, argument_list; 212, 213; 212, 214; 213, identifier:etype; 214, identifier:BaseException; 215, parenthesized_expression; 215, 216; 216, boolean_operator:and; 216, 217; 216, 222; 217, call; 217, 218; 217, 219; 218, identifier:hasattr; 219, argument_list; 219, 220; 219, 221; 220, identifier:types; 221, string:"InstanceType"; 222, call; 222, 223; 222, 224; 223, identifier:isinstance; 224, argument_list; 224, 225; 224, 226; 225, identifier:etype; 226, attribute; 226, 227; 226, 228; 227, identifier:types; 228, identifier:InstanceType; 229, comparison_operator:is; 229, 230; 229, 231; 230, identifier:etype; 231, None; 232, comparison_operator:is; 232, 233; 232, 237; 233, call; 233, 234; 233, 235; 234, identifier:type; 235, argument_list; 235, 236; 236, identifier:etype; 237, identifier:str; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 242; 241, identifier:output; 242, argument_list; 242, 243; 243, call; 243, 244; 243, 245; 244, identifier:_format_final_exc_line; 245, argument_list; 245, 246; 245, 247; 246, identifier:etype; 247, identifier:value; 248, else_clause; 248, 249; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 253; 252, identifier:output; 253, argument_list; 253, 254; 254, call; 254, 255; 254, 256; 255, identifier:_format_final_exc_line; 256, argument_list; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:etype; 259, identifier:__name__; 260, identifier:value; 261, if_statement; 261, 262; 261, 263; 262, identifier:autodebugshell; 263, block; 263, 264; 264, try_statement; 264, 265; 264, 279; 265, block; 265, 266; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 269; 268, identifier:debugshell; 269, comparison_operator:!=; 269, 270; 269, 278; 270, call; 270, 271; 270, 272; 271, identifier:int; 272, argument_list; 272, 273; 273, subscript; 273, 274; 273, 277; 274, attribute; 274, 275; 274, 276; 275, identifier:os; 276, identifier:environ; 277, string:"DEBUG"; 278, integer:0; 279, except_clause; 279, 280; 279, 281; 280, identifier:Exception; 281, block; 281, 282; 282, pass_statement; 283, if_statement; 283, 284; 283, 285; 284, identifier:debugshell; 285, block; 285, 286; 285, 291; 286, expression_statement; 286, 287; 287, call; 287, 288; 287, 289; 288, identifier:output; 289, argument_list; 289, 290; 290, string:"---------- DEBUG SHELL -----------"; 291, expression_statement; 291, 292; 292, call; 292, 293; 292, 294; 293, identifier:debug_shell; 294, argument_list; 294, 295; 294, 298; 294, 301; 295, keyword_argument; 295, 296; 295, 297; 296, identifier:user_ns; 297, identifier:all_locals; 298, keyword_argument; 298, 299; 298, 300; 299, identifier:user_global_ns; 300, identifier:all_globals; 301, keyword_argument; 301, 302; 301, 303; 302, identifier:traceback; 303, identifier:tb; 304, expression_statement; 304, 305; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:file; 308, identifier:flush; 309, argument_list
def better_exchook(etype, value, tb, debugshell=False, autodebugshell=True, file=None, with_color=None): if file is None: file = sys.stderr def output(ln): file.write(ln + "\n") color = Color(enable=with_color) output(color("EXCEPTION", color.fg_colors[1], bold=True)) all_locals, all_globals = {}, {} if tb is not None: print_tb(tb, allLocals=all_locals, allGlobals=all_globals, file=file, withTitle=True, with_color=color.enable) else: output(color("better_exchook: traceback unknown", color.fg_colors[1])) import types def _some_str(value): try: return str(value) except Exception: return '<unprintable %s object>' % type(value).__name__ def _format_final_exc_line(etype, value): value_str = _some_str(value) if value is None or not value_str: line = color("%s" % etype, color.fg_colors[1]) else: line = color("%s" % etype, color.fg_colors[1]) + ": %s" % (value_str,) return line if (isinstance(etype, BaseException) or (hasattr(types, "InstanceType") and isinstance(etype, types.InstanceType)) or etype is None or type(etype) is str): output(_format_final_exc_line(etype, value)) else: output(_format_final_exc_line(etype.__name__, value)) if autodebugshell: try: debugshell = int(os.environ["DEBUG"]) != 0 except Exception: pass if debugshell: output("---------- DEBUG SHELL -----------") debug_shell(user_ns=all_locals, user_global_ns=all_globals, traceback=tb) file.flush()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:dump_all_thread_tracebacks; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:exclude_thread_ids; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:file; 9, None; 10, block; 10, 11; 10, 20; 10, 30; 10, 33; 11, if_statement; 11, 12; 11, 15; 12, comparison_operator:is; 12, 13; 12, 14; 13, identifier:exclude_thread_ids; 14, None; 15, block; 15, 16; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:exclude_thread_ids; 19, list:[]; 20, if_statement; 20, 21; 20, 23; 21, not_operator; 21, 22; 22, identifier:file; 23, block; 23, 24; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:file; 27, attribute; 27, 28; 27, 29; 28, identifier:sys; 29, identifier:stdout; 30, import_statement; 30, 31; 31, dotted_name; 31, 32; 32, identifier:threading; 33, if_statement; 33, 34; 33, 39; 33, 198; 34, call; 34, 35; 34, 36; 35, identifier:hasattr; 36, argument_list; 36, 37; 36, 38; 37, identifier:sys; 38, string:"_current_frames"; 39, block; 39, 40; 39, 48; 39, 64; 39, 190; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 43; 42, identifier:print; 43, argument_list; 43, 44; 43, 45; 44, string:""; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:file; 47, identifier:file; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:threads; 51, dictionary_comprehension; 51, 52; 51, 57; 52, pair; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:t; 55, identifier:ident; 56, identifier:t; 57, for_in_clause; 57, 58; 57, 59; 58, identifier:t; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:threading; 62, identifier:enumerate; 63, argument_list; 64, for_statement; 64, 65; 64, 68; 64, 77; 65, pattern_list; 65, 66; 65, 67; 66, identifier:tid; 67, identifier:stack; 68, call; 68, 69; 68, 76; 69, attribute; 69, 70; 69, 75; 70, call; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:sys; 73, identifier:_current_frames; 74, argument_list; 75, identifier:items; 76, argument_list; 77, block; 77, 78; 77, 84; 77, 90; 77, 94; 77, 103; 77, 159; 77, 174; 77, 182; 78, if_statement; 78, 79; 78, 82; 79, comparison_operator:in; 79, 80; 79, 81; 80, identifier:tid; 81, identifier:exclude_thread_ids; 82, block; 82, 83; 83, continue_statement; 84, if_statement; 84, 85; 84, 88; 85, comparison_operator:not; 85, 86; 85, 87; 86, identifier:tid; 87, identifier:threads; 88, block; 88, 89; 89, continue_statement; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:tags; 93, list:[]; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:thread; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:threads; 100, identifier:get; 101, argument_list; 101, 102; 102, identifier:tid; 103, if_statement; 103, 104; 103, 105; 103, 150; 104, identifier:thread; 105, block; 105, 106; 105, 114; 105, 128; 105, 142; 106, assert_statement; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:isinstance; 109, argument_list; 109, 110; 109, 111; 110, identifier:thread; 111, attribute; 111, 112; 111, 113; 112, identifier:threading; 113, identifier:Thread; 114, if_statement; 114, 115; 114, 122; 115, comparison_operator:is; 115, 116; 115, 117; 116, identifier:thread; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:threading; 120, identifier:currentThread; 121, argument_list; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, augmented_assignment:+=; 124, 125; 124, 126; 125, identifier:tags; 126, list:["current"]; 126, 127; 127, string:"current"; 128, if_statement; 128, 129; 128, 136; 129, call; 129, 130; 129, 131; 130, identifier:isinstance; 131, argument_list; 131, 132; 131, 133; 132, identifier:thread; 133, attribute; 133, 134; 133, 135; 134, identifier:threading; 135, identifier:_MainThread; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, augmented_assignment:+=; 138, 139; 138, 140; 139, identifier:tags; 140, list:["main"]; 140, 141; 141, string:"main"; 142, expression_statement; 142, 143; 143, augmented_assignment:+=; 143, 144; 143, 145; 144, identifier:tags; 145, list:[str(thread)]; 145, 146; 146, call; 146, 147; 146, 148; 147, identifier:str; 148, argument_list; 148, 149; 149, identifier:thread; 150, else_clause; 150, 151; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, augmented_assignment:+=; 153, 154; 153, 155; 154, identifier:tags; 155, list:["unknown with id %i" % tid]; 155, 156; 156, binary_operator:%; 156, 157; 156, 158; 157, string:"unknown with id %i"; 158, identifier:tid; 159, expression_statement; 159, 160; 160, call; 160, 161; 160, 162; 161, identifier:print; 162, argument_list; 162, 163; 162, 171; 163, binary_operator:%; 163, 164; 163, 165; 164, string:"Thread %s:"; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, string:", "; 168, identifier:join; 169, argument_list; 169, 170; 170, identifier:tags; 171, keyword_argument; 171, 172; 171, 173; 172, identifier:file; 173, identifier:file; 174, expression_statement; 174, 175; 175, call; 175, 176; 175, 177; 176, identifier:print_tb; 177, argument_list; 177, 178; 177, 179; 178, identifier:stack; 179, keyword_argument; 179, 180; 179, 181; 180, identifier:file; 181, identifier:file; 182, expression_statement; 182, 183; 183, call; 183, 184; 183, 185; 184, identifier:print; 185, argument_list; 185, 186; 185, 187; 186, string:""; 187, keyword_argument; 187, 188; 187, 189; 188, identifier:file; 189, identifier:file; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 193; 192, identifier:print; 193, argument_list; 193, 194; 193, 195; 194, string:"That were all threads."; 195, keyword_argument; 195, 196; 195, 197; 196, identifier:file; 197, identifier:file; 198, else_clause; 198, 199; 199, block; 199, 200; 200, expression_statement; 200, 201; 201, call; 201, 202; 201, 203; 202, identifier:print; 203, argument_list; 203, 204; 203, 205; 204, string:"Does not have sys._current_frames, cannot get thread tracebacks."; 205, keyword_argument; 205, 206; 205, 207; 206, identifier:file; 207, identifier:file
def dump_all_thread_tracebacks(exclude_thread_ids=None, file=None): if exclude_thread_ids is None: exclude_thread_ids = [] if not file: file = sys.stdout import threading if hasattr(sys, "_current_frames"): print("", file=file) threads = {t.ident: t for t in threading.enumerate()} for tid, stack in sys._current_frames().items(): if tid in exclude_thread_ids: continue if tid not in threads: continue tags = [] thread = threads.get(tid) if thread: assert isinstance(thread, threading.Thread) if thread is threading.currentThread(): tags += ["current"] if isinstance(thread, threading._MainThread): tags += ["main"] tags += [str(thread)] else: tags += ["unknown with id %i" % tid] print("Thread %s:" % ", ".join(tags), file=file) print_tb(stack, file=file) print("", file=file) print("That were all threads.", file=file) else: print("Does not have sys._current_frames, cannot get thread tracebacks.", file=file)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:_main; 3, parameters; 4, block; 4, 5; 4, 160; 4, 210; 4, 235; 4, 272; 4, 285; 4, 298; 4, 317; 4, 337; 4, 341; 5, if_statement; 5, 6; 5, 16; 5, 64; 5, 92; 5, 133; 6, comparison_operator:==; 6, 7; 6, 14; 7, subscript; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:sys; 10, identifier:argv; 11, slice; 11, 12; 11, 13; 12, integer:1; 13, colon; 14, list:["test"]; 14, 15; 15, string:"test"; 16, block; 16, 17; 16, 53; 16, 58; 17, for_statement; 17, 18; 17, 21; 17, 31; 18, pattern_list; 18, 19; 18, 20; 19, identifier:k; 20, identifier:v; 21, call; 21, 22; 21, 23; 22, identifier:sorted; 23, argument_list; 23, 24; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, call; 26, 27; 26, 28; 27, identifier:globals; 28, argument_list; 29, identifier:items; 30, argument_list; 31, block; 31, 32; 31, 42; 31, 49; 32, if_statement; 32, 33; 32, 40; 33, not_operator; 33, 34; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:k; 37, identifier:startswith; 38, argument_list; 38, 39; 39, string:"test_"; 40, block; 40, 41; 41, continue_statement; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 45; 44, identifier:print; 45, argument_list; 45, 46; 46, binary_operator:%; 46, 47; 46, 48; 47, string:"running: %s()"; 48, identifier:k; 49, expression_statement; 49, 50; 50, call; 50, 51; 50, 52; 51, identifier:v; 52, argument_list; 53, expression_statement; 53, 54; 54, call; 54, 55; 54, 56; 55, identifier:print; 56, argument_list; 56, 57; 57, string:"ok."; 58, expression_statement; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:sys; 62, identifier:exit; 63, argument_list; 64, elif_clause; 64, 65; 64, 75; 65, comparison_operator:==; 65, 66; 65, 73; 66, subscript; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:sys; 69, identifier:argv; 70, slice; 70, 71; 70, 72; 71, integer:1; 72, colon; 73, list:["debug_shell"]; 73, 74; 74, string:"debug_shell"; 75, block; 75, 76; 75, 86; 76, expression_statement; 76, 77; 77, call; 77, 78; 77, 79; 78, identifier:debug_shell; 79, argument_list; 79, 80; 79, 83; 80, call; 80, 81; 80, 82; 81, identifier:locals; 82, argument_list; 83, call; 83, 84; 83, 85; 84, identifier:globals; 85, argument_list; 86, expression_statement; 86, 87; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:sys; 90, identifier:exit; 91, argument_list; 92, elif_clause; 92, 93; 92, 103; 93, comparison_operator:==; 93, 94; 93, 101; 94, subscript; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:sys; 97, identifier:argv; 98, slice; 98, 99; 98, 100; 99, integer:1; 100, colon; 101, list:["debug_shell_exception"]; 101, 102; 102, string:"debug_shell_exception"; 103, block; 103, 104; 103, 127; 104, try_statement; 104, 105; 104, 111; 105, block; 105, 106; 106, raise_statement; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:Exception; 109, argument_list; 109, 110; 110, string:"demo exception"; 111, except_clause; 111, 112; 111, 113; 112, identifier:Exception; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:better_exchook; 117, argument_list; 117, 118; 117, 124; 118, list_splat; 118, 119; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:sys; 122, identifier:exc_info; 123, argument_list; 124, keyword_argument; 124, 125; 124, 126; 125, identifier:debugshell; 126, True; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:sys; 131, identifier:exit; 132, argument_list; 133, elif_clause; 133, 134; 133, 141; 134, subscript; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:sys; 137, identifier:argv; 138, slice; 138, 139; 138, 140; 139, integer:1; 140, colon; 141, block; 141, 142; 141, 153; 142, expression_statement; 142, 143; 143, call; 143, 144; 143, 145; 144, identifier:print; 145, argument_list; 145, 146; 146, binary_operator:%; 146, 147; 146, 148; 147, string:"Usage: %s (test|...)"; 148, subscript; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:sys; 151, identifier:argv; 152, integer:0; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:sys; 157, identifier:exit; 158, argument_list; 158, 159; 159, integer:1; 160, try_statement; 160, 161; 160, 197; 161, block; 161, 162; 161, 172; 161, 193; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 165; 164, identifier:x; 165, dictionary; 165, 166; 165, 169; 166, pair; 166, 167; 166, 168; 167, integer:1; 168, integer:2; 169, pair; 169, 170; 169, 171; 170, string:"a"; 171, string:"b"; 172, function_definition; 172, 173; 172, 174; 172, 175; 173, function_name:f; 174, parameters; 175, block; 175, 176; 175, 180; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:y; 179, string:"foo"; 180, expression_statement; 180, 181; 180, 182; 180, 183; 180, 188; 180, 191; 180, 192; 181, identifier:x; 182, integer:42; 183, attribute; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:sys; 186, identifier:stdin; 187, identifier:__class__; 188, attribute; 188, 189; 188, 190; 189, identifier:sys; 190, identifier:exc_info; 191, identifier:y; 192, identifier:z; 193, expression_statement; 193, 194; 194, call; 194, 195; 194, 196; 195, identifier:f; 196, argument_list; 197, except_clause; 197, 198; 197, 199; 198, identifier:Exception; 199, block; 199, 200; 200, expression_statement; 200, 201; 201, call; 201, 202; 201, 203; 202, identifier:better_exchook; 203, argument_list; 203, 204; 204, list_splat; 204, 205; 205, call; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:sys; 208, identifier:exc_info; 209, argument_list; 210, try_statement; 210, 211; 210, 222; 211, block; 211, 212; 212, expression_statement; 212, 213; 213, call; 213, 214; 213, 219; 214, parenthesized_expression; 214, 215; 215, lambda; 215, 216; 215, 218; 216, lambda_parameters; 216, 217; 217, identifier:_x; 218, None; 219, argument_list; 219, 220; 219, 221; 220, identifier:__name__; 221, integer:42; 222, except_clause; 222, 223; 222, 224; 223, identifier:Exception; 224, block; 224, 225; 225, expression_statement; 225, 226; 226, call; 226, 227; 226, 228; 227, identifier:better_exchook; 228, argument_list; 228, 229; 229, list_splat; 229, 230; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:sys; 233, identifier:exc_info; 234, argument_list; 235, try_statement; 235, 236; 235, 259; 236, block; 236, 237; 236, 250; 236, 256; 237, class_definition; 237, 238; 237, 239; 238, identifier:Obj; 239, block; 239, 240; 240, function_definition; 240, 241; 240, 242; 240, 244; 241, function_name:__repr__; 242, parameters; 242, 243; 243, identifier:self; 244, block; 244, 245; 245, return_statement; 245, 246; 246, parenthesized_expression; 246, 247; 247, binary_operator:+; 247, 248; 247, 249; 248, string:"<Obj multi-\n"; 249, string:" line repr>"; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:obj; 253, call; 253, 254; 253, 255; 254, identifier:Obj; 255, argument_list; 256, assert_statement; 256, 257; 257, not_operator; 257, 258; 258, identifier:obj; 259, except_clause; 259, 260; 259, 261; 260, identifier:Exception; 261, block; 261, 262; 262, expression_statement; 262, 263; 263, call; 263, 264; 263, 265; 264, identifier:better_exchook; 265, argument_list; 265, 266; 266, list_splat; 266, 267; 267, call; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:sys; 270, identifier:exc_info; 271, argument_list; 272, function_definition; 272, 273; 272, 274; 272, 276; 273, function_name:f1; 274, parameters; 274, 275; 275, identifier:a; 276, block; 276, 277; 277, expression_statement; 277, 278; 278, call; 278, 279; 278, 280; 279, identifier:f2; 280, argument_list; 280, 281; 280, 284; 281, binary_operator:+; 281, 282; 281, 283; 282, identifier:a; 283, integer:1; 284, integer:2; 285, function_definition; 285, 286; 285, 287; 285, 290; 286, function_name:f2; 287, parameters; 287, 288; 287, 289; 288, identifier:a; 289, identifier:b; 290, block; 290, 291; 291, expression_statement; 291, 292; 292, call; 292, 293; 292, 294; 293, identifier:f3; 294, argument_list; 294, 295; 295, binary_operator:+; 295, 296; 295, 297; 296, identifier:a; 297, identifier:b; 298, function_definition; 298, 299; 298, 300; 298, 302; 299, function_name:f3; 300, parameters; 300, 301; 301, identifier:a; 302, block; 302, 303; 302, 312; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 306; 305, identifier:b; 306, binary_operator:+; 306, 307; 306, 311; 307, parenthesized_expression; 307, 308; 308, binary_operator:*; 308, 309; 308, 310; 309, string:"abc"; 310, integer:100; 311, string:"-interesting"; 312, expression_statement; 312, 313; 313, call; 313, 314; 313, 315; 314, identifier:a; 315, argument_list; 315, 316; 316, identifier:b; 317, try_statement; 317, 318; 317, 324; 318, block; 318, 319; 319, expression_statement; 319, 320; 320, call; 320, 321; 320, 322; 321, identifier:f1; 322, argument_list; 322, 323; 323, integer:13; 324, except_clause; 324, 325; 324, 326; 325, identifier:Exception; 326, block; 326, 327; 327, expression_statement; 327, 328; 328, call; 328, 329; 328, 330; 329, identifier:better_exchook; 330, argument_list; 330, 331; 331, list_splat; 331, 332; 332, call; 332, 333; 332, 336; 333, attribute; 333, 334; 333, 335; 334, identifier:sys; 335, identifier:exc_info; 336, argument_list; 337, expression_statement; 337, 338; 338, call; 338, 339; 338, 340; 339, identifier:install; 340, argument_list; 341, expression_statement; 341, 342; 342, call; 342, 343; 342, 344; 343, identifier:finalfail; 344, argument_list; 344, 345; 345, identifier:sys
def _main(): if sys.argv[1:] == ["test"]: for k, v in sorted(globals().items()): if not k.startswith("test_"): continue print("running: %s()" % k) v() print("ok.") sys.exit() elif sys.argv[1:] == ["debug_shell"]: debug_shell(locals(), globals()) sys.exit() elif sys.argv[1:] == ["debug_shell_exception"]: try: raise Exception("demo exception") except Exception: better_exchook(*sys.exc_info(), debugshell=True) sys.exit() elif sys.argv[1:]: print("Usage: %s (test|...)" % sys.argv[0]) sys.exit(1) try: x = {1: 2, "a": "b"} def f(): y = "foo" x, 42, sys.stdin.__class__, sys.exc_info, y, z f() except Exception: better_exchook(*sys.exc_info()) try: (lambda _x: None)(__name__, 42) except Exception: better_exchook(*sys.exc_info()) try: class Obj: def __repr__(self): return ( "<Obj multi-\n" + " line repr>") obj = Obj() assert not obj except Exception: better_exchook(*sys.exc_info()) def f1(a): f2(a + 1, 2) def f2(a, b): f3(a + b) def f3(a): b = ("abc" * 100) + "-interesting" a(b) try: f1(13) except Exception: better_exchook(*sys.exc_info()) install() finalfail(sys)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mol_supplier; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:lines; 5, identifier:no_halt; 6, identifier:assign_descriptors; 7, block; 7, 8; 7, 111; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:sdf_block; 10, parameters; 10, 11; 11, identifier:lns; 12, block; 12, 13; 12, 17; 12, 21; 12, 25; 12, 103; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:mol; 16, list:[]; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:opt; 20, list:[]; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:is_mol; 24, True; 25, for_statement; 25, 26; 25, 27; 25, 28; 26, identifier:line; 27, identifier:lns; 28, block; 28, 29; 29, if_statement; 29, 30; 29, 36; 29, 64; 29, 76; 29, 90; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:line; 33, identifier:startswith; 34, argument_list; 34, 35; 35, string:"$$$$"; 36, block; 36, 37; 36, 48; 36, 52; 36, 58; 37, expression_statement; 37, 38; 38, yield; 38, 39; 39, expression_list; 39, 40; 39, 44; 40, subscript; 40, 41; 40, 42; 41, identifier:mol; 42, slice; 42, 43; 43, colon; 44, subscript; 44, 45; 44, 46; 45, identifier:opt; 46, slice; 46, 47; 47, colon; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:is_mol; 51, True; 52, expression_statement; 52, 53; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:mol; 56, identifier:clear; 57, argument_list; 58, expression_statement; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:opt; 62, identifier:clear; 63, argument_list; 64, elif_clause; 64, 65; 64, 71; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:line; 68, identifier:startswith; 69, argument_list; 69, 70; 70, string:"M END"; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:is_mol; 75, False; 76, elif_clause; 76, 77; 76, 78; 77, identifier:is_mol; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:mol; 83, identifier:append; 84, argument_list; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:line; 88, identifier:rstrip; 89, argument_list; 90, else_clause; 90, 91; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:opt; 96, identifier:append; 97, argument_list; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:line; 101, identifier:rstrip; 102, argument_list; 103, if_statement; 103, 104; 103, 105; 104, identifier:mol; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, yield; 107, 108; 108, expression_list; 108, 109; 108, 110; 109, identifier:mol; 110, identifier:opt; 111, for_statement; 111, 112; 111, 117; 111, 124; 112, pattern_list; 112, 113; 112, 114; 113, identifier:i; 114, tuple_pattern; 114, 115; 114, 116; 115, identifier:mol; 116, identifier:opt; 117, call; 117, 118; 117, 119; 118, identifier:enumerate; 119, argument_list; 119, 120; 120, call; 120, 121; 120, 122; 121, identifier:sdf_block; 122, argument_list; 122, 123; 123, identifier:lines; 124, block; 124, 125; 125, try_statement; 125, 126; 125, 144; 125, 186; 125, 221; 126, block; 126, 127; 126, 134; 127, expression_statement; 127, 128; 128, assignment; 128, 129; 128, 130; 129, identifier:c; 130, call; 130, 131; 130, 132; 131, identifier:molecule; 132, argument_list; 132, 133; 133, identifier:mol; 134, if_statement; 134, 135; 134, 136; 135, identifier:assign_descriptors; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:molutil; 141, identifier:assign_descriptors; 142, argument_list; 142, 143; 143, identifier:c; 144, except_clause; 144, 145; 144, 149; 145, as_pattern; 145, 146; 145, 147; 146, identifier:ValueError; 147, as_pattern_target; 147, 148; 148, identifier:err; 149, block; 149, 150; 150, if_statement; 150, 151; 150, 152; 150, 174; 151, identifier:no_halt; 152, block; 152, 153; 152, 165; 153, print_statement; 153, 154; 154, parenthesized_expression; 154, 155; 154, 158; 155, ERROR; 155, 156; 155, 157; 156, identifier:Unsupported; 157, identifier:symbol; 158, call; 158, 159; 158, 160; 159, dictionary; 160, argument_list; 160, 161; 160, 162; 161, identifier:err; 162, binary_operator:+; 162, 163; 162, 164; 163, identifier:i; 164, integer:1; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:c; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:molutil; 171, identifier:null_molecule; 172, argument_list; 172, 173; 173, identifier:assign_descriptors; 174, else_clause; 174, 175; 175, block; 175, 176; 176, raise_statement; 176, 177; 177, call; 177, 178; 177, 179; 178, identifier:ValueError; 179, argument_list; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, string:"Unsupported symbol: {}"; 183, identifier:format; 184, argument_list; 184, 185; 185, identifier:err; 186, except_clause; 186, 187; 186, 191; 187, as_pattern; 187, 188; 187, 189; 188, identifier:RuntimeError; 189, as_pattern_target; 189, 190; 190, identifier:err; 191, block; 191, 192; 192, if_statement; 192, 193; 192, 194; 192, 209; 193, identifier:no_halt; 194, block; 194, 195; 195, print_statement; 195, 196; 196, parenthesized_expression; 196, 197; 196, 202; 197, ERROR; 197, 198; 197, 199; 197, 200; 197, 201; 198, identifier:Failed; 199, identifier:to; 200, identifier:minimize; 201, identifier:ring; 202, call; 202, 203; 202, 204; 203, dictionary; 204, argument_list; 204, 205; 204, 206; 205, identifier:err; 206, binary_operator:+; 206, 207; 206, 208; 207, identifier:i; 208, integer:1; 209, else_clause; 209, 210; 210, block; 210, 211; 211, raise_statement; 211, 212; 212, call; 212, 213; 212, 214; 213, identifier:RuntimeError; 214, argument_list; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, string:"Failed to minimize ring: {}"; 218, identifier:format; 219, argument_list; 219, 220; 220, identifier:err; 221, except_clause; 221, 222; 222, block; 222, 223; 223, if_statement; 223, 224; 223, 225; 223, 272; 224, identifier:no_halt; 225, ERROR; 225, 226; 225, 228; 225, 229; 225, 230; 225, 271; 226, ERROR; 226, 227; 227, identifier:Unexpected; 228, identifier:error; 229, identifier:c; 230, ERROR; 230, 231; 230, 241; 230, 245; 230, 246; 230, 247; 230, 248; 230, 249; 230, 257; 230, 258; 230, 266; 230, 270; 231, attribute; 231, 232; 231, 238; 231, 240; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:molutil; 235, identifier:null_molecule; 236, argument_list; 236, 237; 237, identifier:assign_descriptors; 238, ERROR; 238, 239; 239, identifier:c; 240, identifier:data; 241, call; 241, 242; 241, 243; 242, identifier:optional_data; 243, argument_list; 243, 244; 244, identifier:opt; 245, identifier:yield; 246, identifier:c; 247, identifier:continue; 248, identifier:else; 249, call; 249, 250; 249, 251; 250, identifier:print; 251, argument_list; 251, 252; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:traceback; 255, identifier:format_exc; 256, argument_list; 257, identifier:raise; 258, attribute; 258, 259; 258, 263; 258, 265; 259, call; 259, 260; 259, 261; 260, identifier:Exception; 261, argument_list; 261, 262; 262, string:"Unsupported Error"; 263, ERROR; 263, 264; 264, identifier:c; 265, identifier:data; 266, call; 266, 267; 266, 268; 267, identifier:optional_data; 268, argument_list; 268, 269; 269, identifier:opt; 270, identifier:yield; 271, identifier:c; 272, block:
def mol_supplier(lines, no_halt, assign_descriptors): def sdf_block(lns): mol = [] opt = [] is_mol = True for line in lns: if line.startswith("$$$$"): yield mol[:], opt[:] is_mol = True mol.clear() opt.clear() elif line.startswith("M END"): is_mol = False elif is_mol: mol.append(line.rstrip()) else: opt.append(line.rstrip()) if mol: yield mol, opt for i, (mol, opt) in enumerate(sdf_block(lines)): try: c = molecule(mol) if assign_descriptors: molutil.assign_descriptors(c) except ValueError as err: if no_halt: print("Unsupported symbol: {} ( err, i + 1)) c = molutil.null_molecule(assign_descriptors) else: raise ValueError("Unsupported symbol: {}".format(err)) except RuntimeError as err: if no_halt: print( "Failed to minimize ring: {} ( err, i + 1) ) else: raise RuntimeError("Failed to minimize ring: {}".format(err)) except: if no_halt: print("Unexpected error ( c = molutil.null_molecule(assign_descriptors) c.data = optional_data(opt) yield c continue else: print(traceback.format_exc()) raise Exception("Unsupported Error") c.data = optional_data(opt) yield c
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:render_diagram; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:root_task; 5, identifier:out_base; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_param_len; 8, integer:20; 9, default_parameter; 9, 10; 9, 11; 10, identifier:horizontal; 11, False; 12, default_parameter; 12, 13; 12, 14; 13, identifier:colored; 14, False; 15, block; 15, 16; 15, 19; 15, 22; 15, 25; 15, 30; 15, 39; 15, 44; 15, 54; 15, 89; 15, 95; 15, 101; 15, 312; 15, 317; 15, 324; 15, 355; 15, 368; 15, 393; 16, import_statement; 16, 17; 17, dotted_name; 17, 18; 18, identifier:re; 19, import_statement; 19, 20; 20, dotted_name; 20, 21; 21, identifier:codecs; 22, import_statement; 22, 23; 23, dotted_name; 23, 24; 24, identifier:subprocess; 25, import_from_statement; 25, 26; 25, 28; 26, dotted_name; 26, 27; 27, identifier:ozelot; 28, dotted_name; 28, 29; 29, identifier:config; 30, import_from_statement; 30, 31; 30, 35; 30, 37; 31, dotted_name; 31, 32; 31, 33; 31, 34; 32, identifier:ozelot; 33, identifier:etl; 34, identifier:tasks; 35, dotted_name; 35, 36; 36, identifier:get_task_name; 37, dotted_name; 37, 38; 38, identifier:get_task_param_string; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:lines; 42, list:[u"digraph G {"]; 42, 43; 43, string:u"digraph G {"; 44, if_statement; 44, 45; 44, 46; 45, identifier:horizontal; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:lines; 51, identifier:append; 52, argument_list; 52, 53; 53, string:u"rankdir=LR;"; 54, function_definition; 54, 55; 54, 56; 54, 58; 55, function_name:get_id; 56, parameters; 56, 57; 57, identifier:task; 58, block; 58, 59; 58, 73; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:s; 62, binary_operator:+; 62, 63; 62, 69; 63, binary_operator:+; 63, 64; 63, 68; 64, call; 64, 65; 64, 66; 65, identifier:get_task_name; 66, argument_list; 66, 67; 67, identifier:task; 68, string:"_"; 69, call; 69, 70; 69, 71; 70, identifier:get_task_param_string; 71, argument_list; 71, 72; 72, identifier:task; 73, return_statement; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:re; 77, identifier:sub; 78, argument_list; 78, 79; 78, 80; 78, 81; 79, string:r'\W+'; 80, string:''; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:re; 84, identifier:sub; 85, argument_list; 85, 86; 85, 87; 85, 88; 86, string:' '; 87, string:'_'; 88, identifier:s; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:existing_nodes; 92, call; 92, 93; 92, 94; 93, identifier:set; 94, argument_list; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:existing_edges; 98, call; 98, 99; 98, 100; 99, identifier:set; 100, argument_list; 101, function_definition; 101, 102; 101, 103; 101, 108; 102, function_name:_build; 103, parameters; 103, 104; 103, 105; 104, identifier:task; 105, default_parameter; 105, 106; 105, 107; 106, identifier:parent_id; 107, None; 108, block; 108, 109; 108, 116; 108, 284; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:tid; 112, call; 112, 113; 112, 114; 113, identifier:get_id; 114, argument_list; 114, 115; 115, identifier:task; 116, if_statement; 116, 117; 116, 120; 117, comparison_operator:not; 117, 118; 117, 119; 118, identifier:tid; 119, identifier:existing_nodes; 120, block; 120, 121; 120, 129; 120, 133; 120, 176; 120, 197; 120, 206; 120, 231; 120, 261; 120, 268; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:params; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:task; 127, identifier:to_str_params; 128, argument_list; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:param_list; 132, string:""; 133, for_statement; 133, 134; 133, 137; 133, 142; 134, pattern_list; 134, 135; 134, 136; 135, identifier:k; 136, identifier:v; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:params; 140, identifier:items; 141, argument_list; 142, block; 142, 143; 142, 161; 143, if_statement; 143, 144; 143, 150; 144, comparison_operator:>; 144, 145; 144, 149; 145, call; 145, 146; 145, 147; 146, identifier:len; 147, argument_list; 147, 148; 148, identifier:v; 149, identifier:max_param_len; 150, block; 150, 151; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:v; 154, binary_operator:+; 154, 155; 154, 160; 155, subscript; 155, 156; 155, 157; 156, identifier:v; 157, slice; 157, 158; 157, 159; 158, colon; 159, identifier:max_param_len; 160, string:"..."; 161, expression_statement; 161, 162; 162, augmented_assignment:+=; 162, 163; 162, 164; 163, identifier:param_list; 164, call; 164, 165; 164, 173; 165, attribute; 165, 166; 165, 172; 166, concatenated_string; 166, 167; 166, 168; 166, 169; 166, 170; 166, 171; 167, string:"<TR><TD ALIGN=\"LEFT\">"; 168, string:"<FONT POINT-SIZE=\"10\">{:s}</FONT>"; 169, string:"</TD><TD ALIGN=\"LEFT\">"; 170, string:"<FONT POINT-SIZE=\"10\">{:s}</FONT>"; 171, string:"</TD></TR>"; 172, identifier:format; 173, argument_list; 173, 174; 173, 175; 174, identifier:k; 175, identifier:v; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:label; 179, binary_operator:+; 179, 180; 179, 196; 180, binary_operator:+; 180, 181; 180, 195; 181, call; 181, 182; 181, 190; 182, attribute; 182, 183; 182, 189; 183, concatenated_string; 183, 184; 183, 185; 183, 186; 183, 187; 183, 188; 184, string:"<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\">"; 185, string:"<TR><TD COLSPAN=\"2\" ALIGN=\"CENTER\">"; 186, string:"<FONT POINT-SIZE=\"12\">{:s}</FONT>"; 187, string:"</TD></TR>"; 188, string:""; 189, identifier:format; 190, argument_list; 190, 191; 191, call; 191, 192; 191, 193; 192, identifier:get_task_name; 193, argument_list; 193, 194; 194, identifier:task; 195, identifier:param_list; 196, string:"</TABLE>"; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:style; 200, call; 200, 201; 200, 202; 201, identifier:getattr; 202, argument_list; 202, 203; 202, 204; 202, 205; 203, identifier:task; 204, string:'diagram_style'; 205, list:[]; 206, if_statement; 206, 207; 206, 208; 206, 225; 207, identifier:colored; 208, block; 208, 209; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:color; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, string:', color="{:s}"'; 215, identifier:format; 216, argument_list; 216, 217; 217, conditional_expression:if; 217, 218; 217, 219; 217, 224; 218, string:"green"; 219, call; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:task; 222, identifier:complete; 223, argument_list; 224, string:"red"; 225, else_clause; 225, 226; 226, block; 226, 227; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:color; 230, string:''; 231, expression_statement; 231, 232; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:lines; 235, identifier:append; 236, argument_list; 236, 237; 237, call; 237, 238; 237, 243; 238, attribute; 238, 239; 238, 242; 239, concatenated_string; 239, 240; 239, 241; 240, string:u"{name:s} [label=< {label:s} >, shape=\"rect\" {color:s}, style=\"{style:s}\"];\n"; 241, string:u""; 242, identifier:format; 243, argument_list; 243, 244; 243, 247; 243, 250; 243, 253; 244, keyword_argument; 244, 245; 244, 246; 245, identifier:name; 246, identifier:tid; 247, keyword_argument; 247, 248; 247, 249; 248, identifier:label; 249, identifier:label; 250, keyword_argument; 250, 251; 250, 252; 251, identifier:color; 252, identifier:color; 253, keyword_argument; 253, 254; 253, 255; 254, identifier:style; 255, call; 255, 256; 255, 259; 256, attribute; 256, 257; 256, 258; 257, string:','; 258, identifier:join; 259, argument_list; 259, 260; 260, identifier:style; 261, expression_statement; 261, 262; 262, call; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, identifier:existing_nodes; 265, identifier:add; 266, argument_list; 266, 267; 267, identifier:tid; 268, for_statement; 268, 269; 268, 270; 268, 275; 269, identifier:req; 270, call; 270, 271; 270, 274; 271, attribute; 271, 272; 271, 273; 272, identifier:task; 273, identifier:requires; 274, argument_list; 275, block; 275, 276; 276, expression_statement; 276, 277; 277, call; 277, 278; 277, 279; 278, identifier:_build; 279, argument_list; 279, 280; 279, 281; 280, identifier:req; 281, keyword_argument; 281, 282; 281, 283; 282, identifier:parent_id; 283, identifier:tid; 284, if_statement; 284, 285; 284, 294; 285, boolean_operator:and; 285, 286; 285, 289; 286, comparison_operator:is; 286, 287; 286, 288; 287, identifier:parent_id; 288, None; 289, comparison_operator:not; 289, 290; 289, 293; 290, tuple; 290, 291; 290, 292; 291, identifier:tid; 292, identifier:parent_id; 293, identifier:existing_edges; 294, block; 294, 295; 295, expression_statement; 295, 296; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:lines; 299, identifier:append; 300, argument_list; 300, 301; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, string:u"{source:s} -> {target:s};\n"; 304, identifier:format; 305, argument_list; 305, 306; 305, 309; 306, keyword_argument; 306, 307; 306, 308; 307, identifier:source; 308, identifier:tid; 309, keyword_argument; 309, 310; 309, 311; 310, identifier:target; 311, identifier:parent_id; 312, expression_statement; 312, 313; 313, call; 313, 314; 313, 315; 314, identifier:_build; 315, argument_list; 315, 316; 316, identifier:root_task; 317, expression_statement; 317, 318; 318, call; 318, 319; 318, 322; 319, attribute; 319, 320; 319, 321; 320, identifier:lines; 321, identifier:append; 322, argument_list; 322, 323; 323, string:u"}"; 324, with_statement; 324, 325; 324, 342; 325, with_clause; 325, 326; 326, with_item; 326, 327; 327, as_pattern; 327, 328; 327, 340; 328, call; 328, 329; 328, 332; 329, attribute; 329, 330; 329, 331; 330, identifier:codecs; 331, identifier:open; 332, argument_list; 332, 333; 332, 336; 332, 337; 333, binary_operator:+; 333, 334; 333, 335; 334, identifier:out_base; 335, string:'.dot'; 336, string:'w'; 337, keyword_argument; 337, 338; 337, 339; 338, identifier:encoding; 339, string:'utf-8'; 340, as_pattern_target; 340, 341; 341, identifier:f; 342, block; 342, 343; 343, expression_statement; 343, 344; 344, call; 344, 345; 344, 348; 345, attribute; 345, 346; 345, 347; 346, identifier:f; 347, identifier:write; 348, argument_list; 348, 349; 349, call; 349, 350; 349, 353; 350, attribute; 350, 351; 350, 352; 351, string:u"\n"; 352, identifier:join; 353, argument_list; 353, 354; 354, identifier:lines; 355, if_statement; 355, 356; 355, 362; 356, not_operator; 356, 357; 357, call; 357, 358; 357, 359; 358, identifier:hasattr; 359, argument_list; 359, 360; 359, 361; 360, identifier:config; 361, string:'DOT_EXECUTABLE'; 362, block; 362, 363; 363, raise_statement; 363, 364; 364, call; 364, 365; 364, 366; 365, identifier:RuntimeError; 366, argument_list; 366, 367; 367, string:"Please configure the 'DOT_EXECUTABLE' variable in your 'project_config.py'"; 368, if_statement; 368, 369; 368, 380; 369, not_operator; 369, 370; 370, call; 370, 371; 370, 376; 371, attribute; 371, 372; 371, 375; 372, attribute; 372, 373; 372, 374; 373, identifier:os; 374, identifier:path; 375, identifier:exists; 376, argument_list; 376, 377; 377, attribute; 377, 378; 377, 379; 378, identifier:config; 379, identifier:DOT_EXECUTABLE; 380, block; 380, 381; 381, raise_statement; 381, 382; 382, call; 382, 383; 382, 384; 383, identifier:IOError; 384, argument_list; 384, 385; 385, binary_operator:+; 385, 386; 385, 387; 386, string:"Could not find file pointed to by 'DOT_EXECUTABLE': "; 387, call; 387, 388; 387, 389; 388, identifier:str; 389, argument_list; 389, 390; 390, attribute; 390, 391; 390, 392; 391, identifier:config; 392, identifier:DOT_EXECUTABLE; 393, expression_statement; 393, 394; 394, call; 394, 395; 394, 398; 395, attribute; 395, 396; 395, 397; 396, identifier:subprocess; 397, identifier:check_call; 398, argument_list; 398, 399; 399, list:[ config.DOT_EXECUTABLE, '-T', 'png', '-o', out_base + '.png', out_base + '.dot' ]; 399, 400; 399, 403; 399, 404; 399, 405; 399, 406; 399, 409; 400, attribute; 400, 401; 400, 402; 401, identifier:config; 402, identifier:DOT_EXECUTABLE; 403, string:'-T'; 404, string:'png'; 405, string:'-o'; 406, binary_operator:+; 406, 407; 406, 408; 407, identifier:out_base; 408, string:'.png'; 409, binary_operator:+; 409, 410; 409, 411; 410, identifier:out_base; 411, string:'.dot'
def render_diagram(root_task, out_base, max_param_len=20, horizontal=False, colored=False): import re import codecs import subprocess from ozelot import config from ozelot.etl.tasks import get_task_name, get_task_param_string lines = [u"digraph G {"] if horizontal: lines.append(u"rankdir=LR;") def get_id(task): s = get_task_name(task) + "_" + get_task_param_string(task) return re.sub(r'\W+', '', re.sub(' ', '_', s)) existing_nodes = set() existing_edges = set() def _build(task, parent_id=None): tid = get_id(task) if tid not in existing_nodes: params = task.to_str_params() param_list = "" for k, v in params.items(): if len(v) > max_param_len: v = v[:max_param_len] + "..." param_list += "<TR><TD ALIGN=\"LEFT\">" \ "<FONT POINT-SIZE=\"10\">{:s}</FONT>" \ "</TD><TD ALIGN=\"LEFT\">" \ "<FONT POINT-SIZE=\"10\">{:s}</FONT>" \ "</TD></TR>".format(k, v) label = "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\">" \ "<TR><TD COLSPAN=\"2\" ALIGN=\"CENTER\">" \ "<FONT POINT-SIZE=\"12\">{:s}</FONT>" \ "</TD></TR>" \ "".format(get_task_name(task)) + param_list + "</TABLE>" style = getattr(task, 'diagram_style', []) if colored: color = ', color="{:s}"'.format("green" if task.complete() else "red") else: color = '' lines.append(u"{name:s} [label=< {label:s} >, shape=\"rect\" {color:s}, style=\"{style:s}\"];\n" u"".format(name=tid, label=label, color=color, style=','.join(style))) existing_nodes.add(tid) for req in task.requires(): _build(req, parent_id=tid) if parent_id is not None and (tid, parent_id) not in existing_edges: lines.append(u"{source:s} -> {target:s};\n".format(source=tid, target=parent_id)) _build(root_task) lines.append(u"}") with codecs.open(out_base + '.dot', 'w', encoding='utf-8') as f: f.write(u"\n".join(lines)) if not hasattr(config, 'DOT_EXECUTABLE'): raise RuntimeError("Please configure the 'DOT_EXECUTABLE' variable in your 'project_config.py'") if not os.path.exists(config.DOT_EXECUTABLE): raise IOError("Could not find file pointed to by 'DOT_EXECUTABLE': " + str(config.DOT_EXECUTABLE)) subprocess.check_call([ config.DOT_EXECUTABLE, '-T', 'png', '-o', out_base + '.png', out_base + '.dot' ])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:binarize; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:df; 5, identifier:category_classes; 6, default_parameter; 6, 7; 6, 8; 7, identifier:all_classes; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:drop; 11, True; 12, default_parameter; 12, 13; 12, 14; 13, identifier:astype; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:inplace; 17, True; 18, default_parameter; 18, 19; 18, 20; 19, identifier:min_freq; 20, None; 21, block; 21, 22; 21, 63; 21, 78; 21, 164; 21, 182; 22, if_statement; 22, 23; 22, 29; 22, 53; 23, comparison_operator:is; 23, 24; 23, 28; 24, call; 24, 25; 24, 26; 25, identifier:type; 26, argument_list; 26, 27; 27, identifier:category_classes; 28, identifier:dict; 29, block; 29, 30; 29, 37; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:columns; 33, call; 33, 34; 33, 35; 34, identifier:set; 35, argument_list; 35, 36; 36, identifier:category_classes; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:category_classes; 40, dictionary_comprehension; 40, 41; 40, 50; 41, pair; 41, 42; 41, 43; 42, identifier:column; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, subscript; 45, 46; 45, 47; 46, identifier:df; 47, identifier:column; 48, identifier:unique; 49, argument_list; 50, for_in_clause; 50, 51; 50, 52; 51, identifier:column; 52, identifier:columns; 53, else_clause; 53, 54; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:columns; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:category_classes; 61, identifier:keys; 62, argument_list; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:df_new; 66, conditional_expression:if; 66, 67; 66, 68; 66, 69; 67, identifier:df; 68, identifier:inplace; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:df; 72, identifier:drop; 73, argument_list; 73, 74; 73, 75; 74, identifier:columns; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:axis; 77, integer:1; 78, for_statement; 78, 79; 78, 80; 78, 81; 79, identifier:category; 80, identifier:columns; 81, block; 81, 82; 81, 88; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:classes; 85, subscript; 85, 86; 85, 87; 86, identifier:category_classes; 87, identifier:category; 88, for_statement; 88, 89; 88, 90; 88, 106; 89, identifier:i; 90, call; 90, 91; 90, 92; 91, identifier:range; 92, argument_list; 92, 93; 93, conditional_expression:if; 93, 94; 93, 100; 93, 102; 94, binary_operator:-; 94, 95; 94, 99; 95, call; 95, 96; 95, 97; 96, identifier:len; 97, argument_list; 97, 98; 98, identifier:classes; 99, integer:1; 100, not_operator; 100, 101; 101, identifier:all_classes; 102, call; 102, 103; 102, 104; 103, identifier:len; 104, argument_list; 104, 105; 105, identifier:classes; 106, block; 106, 107; 106, 117; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:c; 110, comparison_operator:==; 110, 111; 110, 114; 111, subscript; 111, 112; 111, 113; 112, identifier:df; 113, identifier:category; 114, subscript; 114, 115; 114, 116; 115, identifier:classes; 116, identifier:i; 117, if_statement; 117, 118; 117, 128; 118, boolean_operator:or; 118, 119; 118, 121; 119, not_operator; 119, 120; 120, identifier:min_freq; 121, comparison_operator:>=; 121, 122; 121, 127; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:c; 125, identifier:sum; 126, argument_list; 127, identifier:min_freq; 128, block; 128, 129; 128, 143; 129, if_statement; 129, 130; 129, 133; 130, comparison_operator:is; 130, 131; 130, 132; 131, identifier:astype; 132, None; 133, block; 133, 134; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:c; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:c; 140, identifier:astype; 141, argument_list; 141, 142; 142, identifier:astype; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 163; 145, subscript; 145, 146; 145, 147; 146, identifier:df_new; 147, binary_operator:%; 147, 148; 147, 149; 148, string:'%s_%s'; 149, tuple; 149, 150; 149, 151; 150, identifier:category; 151, call; 151, 152; 151, 160; 152, attribute; 152, 153; 152, 159; 153, call; 153, 154; 153, 155; 154, identifier:str; 155, argument_list; 155, 156; 156, subscript; 156, 157; 156, 158; 157, identifier:classes; 158, identifier:i; 159, identifier:replace; 160, argument_list; 160, 161; 160, 162; 161, string:' '; 162, string:'_'; 163, identifier:c; 164, if_statement; 164, 165; 164, 168; 165, boolean_operator:and; 165, 166; 165, 167; 166, identifier:drop; 167, identifier:inplace; 168, block; 168, 169; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:df_new; 173, identifier:drop; 174, argument_list; 174, 175; 174, 176; 174, 179; 175, identifier:columns; 176, keyword_argument; 176, 177; 176, 178; 177, identifier:axis; 178, integer:1; 179, keyword_argument; 179, 180; 179, 181; 180, identifier:inplace; 181, True; 182, return_statement; 182, 183; 183, identifier:df_new
def binarize(df, category_classes, all_classes=True, drop=True, astype=None, inplace=True, min_freq=None): if type(category_classes) is not dict: columns = set(category_classes) category_classes = {column: df[column].unique() for column in columns} else: columns = category_classes.keys() df_new = df if inplace else df.drop(columns, axis=1) for category in columns: classes = category_classes[category] for i in range(len(classes)-1 if not all_classes else len(classes)): c = df[category] == classes[i] if not min_freq or c.sum() >= min_freq: if astype is not None: c = c.astype(astype) df_new['%s_%s' % (category, str(classes[i]).replace(' ', '_'))] = c if drop and inplace: df_new.drop(columns, axis=1, inplace=True) return df_new
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_package_docs; 3, parameters; 3, 4; 3, 5; 4, identifier:package_dir; 5, default_parameter; 5, 6; 5, 7; 6, identifier:skippedNames; 7, None; 8, block; 8, 9; 8, 18; 8, 27; 8, 39; 8, 51; 8, 72; 8, 92; 8, 96; 8, 100; 8, 104; 8, 191; 8, 261; 8, 350; 8, 361; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:logger; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:logging; 15, identifier:getLogger; 16, argument_list; 16, 17; 17, identifier:__name__; 18, if_statement; 18, 19; 18, 22; 19, comparison_operator:is; 19, 20; 19, 21; 20, identifier:skippedNames; 21, None; 22, block; 22, 23; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:skippedNames; 26, list:[]; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:doc_dir; 30, call; 30, 31; 30, 36; 31, attribute; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:os; 34, identifier:path; 35, identifier:join; 36, argument_list; 36, 37; 36, 38; 37, identifier:package_dir; 38, string:'doc'; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:modules_yaml_path; 42, call; 42, 43; 42, 48; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:os; 46, identifier:path; 47, identifier:join; 48, argument_list; 48, 49; 48, 50; 49, identifier:doc_dir; 50, string:'manifest.yaml'; 51, if_statement; 51, 52; 51, 61; 52, not_operator; 52, 53; 53, call; 53, 54; 53, 59; 54, attribute; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:os; 57, identifier:path; 58, identifier:exists; 59, argument_list; 59, 60; 60, identifier:modules_yaml_path; 61, block; 61, 62; 62, raise_statement; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:NoPackageDocs; 65, argument_list; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, string:'Manifest YAML not found: {0}'; 69, identifier:format; 70, argument_list; 70, 71; 71, identifier:modules_yaml_path; 72, with_statement; 72, 73; 72, 82; 73, with_clause; 73, 74; 74, with_item; 74, 75; 75, as_pattern; 75, 76; 75, 80; 76, call; 76, 77; 76, 78; 77, identifier:open; 78, argument_list; 78, 79; 79, identifier:modules_yaml_path; 80, as_pattern_target; 80, 81; 81, identifier:f; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:manifest_data; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:yaml; 89, identifier:safe_load; 90, argument_list; 90, 91; 91, identifier:f; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:module_dirs; 95, dictionary; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:package_dirs; 99, dictionary; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:static_dirs; 103, dictionary; 104, if_statement; 104, 105; 104, 108; 105, comparison_operator:in; 105, 106; 105, 107; 106, string:'modules'; 107, identifier:manifest_data; 108, block; 108, 109; 109, for_statement; 109, 110; 109, 111; 109, 114; 110, identifier:module_name; 111, subscript; 111, 112; 111, 113; 112, identifier:manifest_data; 113, string:'modules'; 114, block; 114, 115; 114, 133; 114, 145; 114, 173; 114, 179; 115, if_statement; 115, 116; 115, 119; 116, comparison_operator:in; 116, 117; 116, 118; 117, identifier:module_name; 118, identifier:skippedNames; 119, block; 119, 120; 119, 132; 120, expression_statement; 120, 121; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:logger; 124, identifier:debug; 125, argument_list; 125, 126; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, string:'Skipping module {0}'; 129, identifier:format; 130, argument_list; 130, 131; 131, identifier:module_name; 132, continue_statement; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:module_dir; 136, call; 136, 137; 136, 142; 137, attribute; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:os; 140, identifier:path; 141, identifier:join; 142, argument_list; 142, 143; 142, 144; 143, identifier:doc_dir; 144, identifier:module_name; 145, if_statement; 145, 146; 145, 155; 146, not_operator; 146, 147; 147, call; 147, 148; 147, 153; 148, attribute; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:os; 151, identifier:path; 152, identifier:isdir; 153, argument_list; 153, 154; 154, identifier:module_dir; 155, block; 155, 156; 155, 165; 155, 172; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:message; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, string:'module doc dir not found: {0}'; 162, identifier:format; 163, argument_list; 163, 164; 164, identifier:module_dir; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:logger; 169, identifier:warning; 170, argument_list; 170, 171; 171, identifier:message; 172, continue_statement; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 178; 175, subscript; 175, 176; 175, 177; 176, identifier:module_dirs; 177, identifier:module_name; 178, identifier:module_dir; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:logger; 183, identifier:debug; 184, argument_list; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, string:'Found module doc dir {0}'; 188, identifier:format; 189, argument_list; 189, 190; 190, identifier:module_dir; 191, if_statement; 191, 192; 191, 195; 192, comparison_operator:in; 192, 193; 192, 194; 193, string:'package'; 194, identifier:manifest_data; 195, block; 195, 196; 195, 202; 195, 214; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 199; 198, identifier:package_name; 199, subscript; 199, 200; 199, 201; 200, identifier:manifest_data; 201, string:'package'; 202, expression_statement; 202, 203; 203, assignment; 203, 204; 203, 205; 204, identifier:full_package_dir; 205, call; 205, 206; 205, 211; 206, attribute; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:os; 209, identifier:path; 210, identifier:join; 211, argument_list; 211, 212; 211, 213; 212, identifier:doc_dir; 213, identifier:package_name; 214, if_statement; 214, 215; 214, 228; 214, 247; 215, boolean_operator:and; 215, 216; 215, 224; 215, 225; 216, call; 216, 217; 216, 222; 217, attribute; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:os; 220, identifier:path; 221, identifier:isdir; 222, argument_list; 222, 223; 223, identifier:full_package_dir; 224, line_continuation:\; 225, comparison_operator:not; 225, 226; 225, 227; 226, identifier:package_name; 227, identifier:skippedNames; 228, block; 228, 229; 228, 235; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 234; 231, subscript; 231, 232; 231, 233; 232, identifier:package_dirs; 233, identifier:package_name; 234, identifier:full_package_dir; 235, expression_statement; 235, 236; 236, call; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:logger; 239, identifier:debug; 240, argument_list; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, string:'Found package doc dir {0}'; 244, identifier:format; 245, argument_list; 245, 246; 246, identifier:full_package_dir; 247, else_clause; 247, 248; 248, block; 248, 249; 249, expression_statement; 249, 250; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:logger; 253, identifier:warning; 254, argument_list; 254, 255; 255, call; 255, 256; 255, 259; 256, attribute; 256, 257; 256, 258; 257, string:'package doc dir excluded or not found: {0}'; 258, identifier:format; 259, argument_list; 259, 260; 260, identifier:full_package_dir; 261, if_statement; 261, 262; 261, 265; 262, comparison_operator:in; 262, 263; 262, 264; 263, string:'statics'; 264, identifier:manifest_data; 265, block; 265, 266; 266, for_statement; 266, 267; 266, 268; 266, 271; 267, identifier:static_dirname; 268, subscript; 268, 269; 268, 270; 269, identifier:manifest_data; 270, string:'statics'; 271, block; 271, 272; 271, 284; 271, 312; 271, 332; 271, 338; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:full_static_dir; 275, call; 275, 276; 275, 281; 276, attribute; 276, 277; 276, 280; 277, attribute; 277, 278; 277, 279; 278, identifier:os; 279, identifier:path; 280, identifier:join; 281, argument_list; 281, 282; 281, 283; 282, identifier:doc_dir; 283, identifier:static_dirname; 284, if_statement; 284, 285; 284, 294; 285, not_operator; 285, 286; 286, call; 286, 287; 286, 292; 287, attribute; 287, 288; 287, 291; 288, attribute; 288, 289; 288, 290; 289, identifier:os; 290, identifier:path; 291, identifier:isdir; 292, argument_list; 292, 293; 293, identifier:full_static_dir; 294, block; 294, 295; 294, 304; 294, 311; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:message; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, string:'_static doc dir not found: {0}'; 301, identifier:format; 302, argument_list; 302, 303; 303, identifier:full_static_dir; 304, expression_statement; 304, 305; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:logger; 308, identifier:warning; 309, argument_list; 309, 310; 310, identifier:message; 311, continue_statement; 312, expression_statement; 312, 313; 313, assignment; 313, 314; 313, 315; 314, identifier:relative_static_dir; 315, call; 315, 316; 315, 321; 316, attribute; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:os; 319, identifier:path; 320, identifier:relpath; 321, argument_list; 321, 322; 321, 323; 322, identifier:full_static_dir; 323, call; 323, 324; 323, 329; 324, attribute; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:os; 327, identifier:path; 328, identifier:join; 329, argument_list; 329, 330; 329, 331; 330, identifier:doc_dir; 331, string:'_static'; 332, expression_statement; 332, 333; 333, assignment; 333, 334; 333, 337; 334, subscript; 334, 335; 334, 336; 335, identifier:static_dirs; 336, identifier:relative_static_dir; 337, identifier:full_static_dir; 338, expression_statement; 338, 339; 339, call; 339, 340; 339, 343; 340, attribute; 340, 341; 340, 342; 341, identifier:logger; 342, identifier:debug; 343, argument_list; 343, 344; 344, call; 344, 345; 344, 348; 345, attribute; 345, 346; 345, 347; 346, string:'Found _static doc dir: {0}'; 347, identifier:format; 348, argument_list; 348, 349; 349, identifier:full_static_dir; 350, expression_statement; 350, 351; 351, assignment; 351, 352; 351, 353; 352, identifier:Dirs; 353, call; 353, 354; 353, 355; 354, identifier:namedtuple; 355, argument_list; 355, 356; 355, 357; 356, string:'Dirs'; 357, list:['module_dirs', 'package_dirs', 'static_dirs']; 357, 358; 357, 359; 357, 360; 358, string:'module_dirs'; 359, string:'package_dirs'; 360, string:'static_dirs'; 361, return_statement; 361, 362; 362, call; 362, 363; 362, 364; 363, identifier:Dirs; 364, argument_list; 364, 365; 364, 368; 364, 371; 365, keyword_argument; 365, 366; 365, 367; 366, identifier:module_dirs; 367, identifier:module_dirs; 368, keyword_argument; 368, 369; 368, 370; 369, identifier:package_dirs; 370, identifier:package_dirs; 371, keyword_argument; 371, 372; 371, 373; 372, identifier:static_dirs; 373, identifier:static_dirs
def find_package_docs(package_dir, skippedNames=None): logger = logging.getLogger(__name__) if skippedNames is None: skippedNames = [] doc_dir = os.path.join(package_dir, 'doc') modules_yaml_path = os.path.join(doc_dir, 'manifest.yaml') if not os.path.exists(modules_yaml_path): raise NoPackageDocs( 'Manifest YAML not found: {0}'.format(modules_yaml_path)) with open(modules_yaml_path) as f: manifest_data = yaml.safe_load(f) module_dirs = {} package_dirs = {} static_dirs = {} if 'modules' in manifest_data: for module_name in manifest_data['modules']: if module_name in skippedNames: logger.debug('Skipping module {0}'.format(module_name)) continue module_dir = os.path.join(doc_dir, module_name) if not os.path.isdir(module_dir): message = 'module doc dir not found: {0}'.format(module_dir) logger.warning(message) continue module_dirs[module_name] = module_dir logger.debug('Found module doc dir {0}'.format(module_dir)) if 'package' in manifest_data: package_name = manifest_data['package'] full_package_dir = os.path.join(doc_dir, package_name) if os.path.isdir(full_package_dir) \ and package_name not in skippedNames: package_dirs[package_name] = full_package_dir logger.debug('Found package doc dir {0}'.format(full_package_dir)) else: logger.warning('package doc dir excluded or not found: {0}'.format( full_package_dir)) if 'statics' in manifest_data: for static_dirname in manifest_data['statics']: full_static_dir = os.path.join(doc_dir, static_dirname) if not os.path.isdir(full_static_dir): message = '_static doc dir not found: {0}'.format( full_static_dir) logger.warning(message) continue relative_static_dir = os.path.relpath( full_static_dir, os.path.join(doc_dir, '_static')) static_dirs[relative_static_dir] = full_static_dir logger.debug('Found _static doc dir: {0}'.format(full_static_dir)) Dirs = namedtuple('Dirs', ['module_dirs', 'package_dirs', 'static_dirs']) return Dirs(module_dirs=module_dirs, package_dirs=package_dirs, static_dirs=static_dirs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_max_id; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:session; 6, block; 6, 7; 6, 11; 6, 56; 6, 70; 6, 90; 6, 99; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:id_base; 10, None; 11, for_statement; 11, 12; 11, 13; 11, 22; 12, identifier:c; 13, binary_operator:+; 13, 14; 13, 16; 14, list:[cls]; 14, 15; 15, identifier:cls; 16, call; 16, 17; 16, 18; 17, identifier:list; 18, argument_list; 18, 19; 19, attribute; 19, 20; 19, 21; 20, identifier:cls; 21, identifier:__bases__; 22, block; 22, 23; 23, for_statement; 23, 24; 23, 25; 23, 28; 24, identifier:base_class; 25, attribute; 25, 26; 25, 27; 26, identifier:c; 27, identifier:__bases__; 28, block; 28, 29; 29, if_statement; 29, 30; 29, 35; 30, comparison_operator:==; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:base_class; 33, identifier:__name__; 34, string:'Base'; 35, block; 35, 36; 36, if_statement; 36, 37; 36, 40; 36, 45; 37, comparison_operator:is; 37, 38; 37, 39; 38, identifier:id_base; 39, None; 40, block; 40, 41; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:id_base; 44, identifier:c; 45, else_clause; 45, 46; 46, block; 46, 47; 47, raise_statement; 47, 48; 48, call; 48, 49; 48, 50; 49, identifier:RuntimeError; 50, argument_list; 50, 51; 51, binary_operator:+; 51, 52; 51, 53; 52, string:"Multiple base object classes for class "; 53, attribute; 53, 54; 53, 55; 54, identifier:cls; 55, identifier:__name__; 56, if_statement; 56, 57; 56, 60; 57, comparison_operator:is; 57, 58; 57, 59; 58, identifier:id_base; 59, None; 60, block; 60, 61; 61, raise_statement; 61, 62; 62, call; 62, 63; 62, 64; 63, identifier:RuntimeError; 64, argument_list; 64, 65; 65, binary_operator:+; 65, 66; 65, 67; 66, string:"Error searching for base class of "; 67, attribute; 67, 68; 67, 69; 68, identifier:cls; 69, identifier:__name__; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:max_id; 73, call; 73, 74; 73, 89; 74, attribute; 74, 75; 74, 88; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:session; 78, identifier:query; 79, argument_list; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:func; 83, identifier:max; 84, argument_list; 84, 85; 85, attribute; 85, 86; 85, 87; 86, identifier:id_base; 87, identifier:id; 88, identifier:scalar; 89, argument_list; 90, if_statement; 90, 91; 90, 94; 91, comparison_operator:is; 91, 92; 91, 93; 92, identifier:max_id; 93, None; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:max_id; 98, integer:0; 99, return_statement; 99, 100; 100, identifier:max_id
def get_max_id(cls, session): id_base = None for c in [cls] + list(cls.__bases__): for base_class in c.__bases__: if base_class.__name__ == 'Base': if id_base is None: id_base = c else: raise RuntimeError("Multiple base object classes for class " + cls.__name__) if id_base is None: raise RuntimeError("Error searching for base class of " + cls.__name__) max_id = session.query(func.max(id_base.id)).scalar() if max_id is None: max_id = 0 return max_id
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_insert_automodapi_configs; 3, parameters; 3, 4; 4, identifier:c; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 30; 5, 36; 5, 42; 5, 50; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, subscript; 8, 9; 8, 10; 9, identifier:c; 10, string:'numpydoc_show_class_members'; 11, False; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 17; 14, subscript; 14, 15; 14, 16; 15, identifier:c; 16, string:'autosummary_generate'; 17, True; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 23; 20, subscript; 20, 21; 20, 22; 21, identifier:c; 22, string:'automodapi_toctreedirnm'; 23, string:'py-api'; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 29; 26, subscript; 26, 27; 26, 28; 27, identifier:c; 28, string:'automodsumm_inherited_members'; 29, True; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 35; 32, subscript; 32, 33; 32, 34; 33, identifier:c; 34, string:'autodoc_inherit_docstrings'; 35, True; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 41; 38, subscript; 38, 39; 38, 40; 39, identifier:c; 40, string:'autoclass_content'; 41, string:"class"; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 47; 44, subscript; 44, 45; 44, 46; 45, identifier:c; 46, string:'autodoc_default_flags'; 47, list:['show-inheritance', 'special-members']; 47, 48; 47, 49; 48, string:'show-inheritance'; 49, string:'special-members'; 50, return_statement; 50, 51; 51, identifier:c
def _insert_automodapi_configs(c): c['numpydoc_show_class_members'] = False c['autosummary_generate'] = True c['automodapi_toctreedirnm'] = 'py-api' c['automodsumm_inherited_members'] = True c['autodoc_inherit_docstrings'] = True c['autoclass_content'] = "class" c['autodoc_default_flags'] = ['show-inheritance', 'special-members'] return c
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:build_pipelines_lsst_io_configs; 3, parameters; 3, 4; 3, 5; 3, 6; 4, keyword_separator; 5, identifier:project_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:copyright; 8, None; 9, block; 9, 10; 9, 17; 9, 21; 9, 31; 9, 44; 9, 51; 9, 58; 9, 65; 9, 72; 9, 79; 9, 86; 9, 96; 9, 107; 9, 122; 9, 128; 9, 142; 9, 149; 9, 156; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:sys; 14, identifier:setrecursionlimit; 15, argument_list; 15, 16; 16, integer:2000; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:c; 20, dictionary; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:c; 24, call; 24, 25; 24, 26; 25, identifier:_insert_common_sphinx_configs; 26, argument_list; 26, 27; 26, 28; 27, identifier:c; 28, keyword_argument; 28, 29; 28, 30; 29, identifier:project_name; 30, identifier:project_name; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:c; 34, call; 34, 35; 34, 36; 35, identifier:_insert_html_configs; 36, argument_list; 36, 37; 36, 38; 36, 41; 37, identifier:c; 38, keyword_argument; 38, 39; 38, 40; 39, identifier:project_name; 40, identifier:project_name; 41, keyword_argument; 41, 42; 41, 43; 42, identifier:short_project_name; 43, identifier:project_name; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:c; 47, call; 47, 48; 47, 49; 48, identifier:_insert_extensions; 49, argument_list; 49, 50; 50, identifier:c; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:c; 54, call; 54, 55; 54, 56; 55, identifier:_insert_intersphinx_mapping; 56, argument_list; 56, 57; 57, identifier:c; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:c; 61, call; 61, 62; 61, 63; 62, identifier:_insert_automodapi_configs; 63, argument_list; 63, 64; 64, identifier:c; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:c; 68, call; 68, 69; 68, 70; 69, identifier:_insert_matplotlib_configs; 70, argument_list; 70, 71; 71, identifier:c; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:c; 75, call; 75, 76; 75, 77; 76, identifier:_insert_graphviz_configs; 77, argument_list; 77, 78; 78, identifier:c; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:c; 82, call; 82, 83; 82, 84; 83, identifier:_insert_eups_version; 84, argument_list; 84, 85; 85, identifier:c; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:date; 89, call; 89, 90; 89, 95; 90, attribute; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:datetime; 93, identifier:datetime; 94, identifier:now; 95, argument_list; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, subscript; 98, 99; 98, 100; 99, identifier:c; 100, string:'today'; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:date; 104, identifier:strftime; 105, argument_list; 105, 106; 106, string:'%Y-%m-%d'; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 112; 109, subscript; 109, 110; 109, 111; 110, identifier:c; 111, string:'copyright'; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, string:'2015-{year} LSST contributors'; 115, identifier:format; 116, argument_list; 116, 117; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:year; 119, attribute; 119, 120; 119, 121; 120, identifier:date; 121, identifier:year; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 127; 124, subscript; 124, 125; 124, 126; 125, identifier:c; 126, string:'todo_include_todos'; 127, False; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 133; 130, subscript; 130, 131; 130, 132; 131, identifier:c; 132, string:'exclude_patterns'; 133, list:[ 'README.rst', '_build', 'releases/note-source/*.rst', 'releases/tickets-source/*.rst', 'ups', '.pyvenv', '.github', 'home', ]; 133, 134; 133, 135; 133, 136; 133, 137; 133, 138; 133, 139; 133, 140; 133, 141; 134, string:'README.rst'; 135, string:'_build'; 136, string:'releases/note-source/*.rst'; 137, string:'releases/tickets-source/*.rst'; 138, string:'ups'; 139, string:'.pyvenv'; 140, string:'.github'; 141, string:'home'; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:c; 145, call; 145, 146; 145, 147; 146, identifier:_insert_rst_epilog; 147, argument_list; 147, 148; 148, identifier:c; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:c; 152, call; 152, 153; 152, 154; 153, identifier:_insert_jinja_configuration; 154, argument_list; 154, 155; 155, identifier:c; 156, return_statement; 156, 157; 157, identifier:c
def build_pipelines_lsst_io_configs(*, project_name, copyright=None): sys.setrecursionlimit(2000) c = {} c = _insert_common_sphinx_configs( c, project_name=project_name) c = _insert_html_configs( c, project_name=project_name, short_project_name=project_name) c = _insert_extensions(c) c = _insert_intersphinx_mapping(c) c = _insert_automodapi_configs(c) c = _insert_matplotlib_configs(c) c = _insert_graphviz_configs(c) c = _insert_eups_version(c) date = datetime.datetime.now() c['today'] = date.strftime('%Y-%m-%d') c['copyright'] = '2015-{year} LSST contributors'.format( year=date.year) c['todo_include_todos'] = False c['exclude_patterns'] = [ 'README.rst', '_build', 'releases/note-source/*.rst', 'releases/tickets-source/*.rst', 'ups', '.pyvenv', '.github', 'home', ] c = _insert_rst_epilog(c) c = _insert_jinja_configuration(c) return c
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:event; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:cuuid; 6, identifier:host; 7, identifier:euuid; 8, identifier:event_data; 9, identifier:timestamp; 10, identifier:priority; 11, block; 11, 12; 11, 16; 11, 53; 11, 59; 11, 65; 11, 106; 11, 126; 11, 134; 11, 153; 11, 164; 11, 179; 11, 292; 11, 316; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:response; 15, None; 16, if_statement; 16, 17; 16, 22; 16, 40; 17, comparison_operator:in; 17, 18; 17, 19; 18, identifier:host; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:encrypted_hosts; 22, block; 22, 23; 22, 30; 23, expression_statement; 23, 24; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:logger; 27, identifier:debug; 28, argument_list; 28, 29; 29, string:"Encrypted!"; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:client_key; 33, subscript; 33, 34; 33, 39; 34, subscript; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:registry; 38, identifier:cuuid; 39, string:"encryption"; 40, else_clause; 40, 41; 41, block; 41, 42; 41, 49; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:logger; 46, identifier:debug; 47, argument_list; 47, 48; 48, string:"Not encrypted :<"; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:client_key; 52, None; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:port; 56, subscript; 56, 57; 56, 58; 57, identifier:host; 58, integer:1; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:host; 62, subscript; 62, 63; 62, 64; 63, identifier:host; 64, integer:0; 65, if_statement; 65, 66; 65, 74; 66, not_operator; 66, 67; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:is_registered; 71, argument_list; 71, 72; 71, 73; 72, identifier:cuuid; 73, identifier:host; 74, block; 74, 75; 74, 84; 74, 104; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:logger; 79, identifier:warning; 80, argument_list; 80, 81; 81, binary_operator:%; 81, 82; 81, 83; 82, string:"<%s> Sending BYE EVENT: Client not registered."; 83, identifier:cuuid; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:response; 87, call; 87, 88; 87, 89; 88, identifier:serialize_data; 89, argument_list; 89, 90; 89, 97; 89, 100; 89, 103; 90, dictionary; 90, 91; 90, 94; 91, pair; 91, 92; 91, 93; 92, string:"method"; 93, string:"BYE EVENT"; 94, pair; 94, 95; 94, 96; 95, string:"data"; 96, string:"Not registered"; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:compression; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:encryption; 103, identifier:client_key; 104, return_statement; 104, 105; 105, identifier:response; 106, if_statement; 106, 107; 106, 112; 107, comparison_operator:in; 107, 108; 107, 109; 108, identifier:euuid; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:event_uuids; 112, block; 112, 113; 112, 124; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:logger; 117, identifier:warning; 118, argument_list; 118, 119; 119, binary_operator:%; 119, 120; 119, 121; 120, string:"<%s> Event ID is already being processed: %s"; 121, tuple; 121, 122; 121, 123; 122, identifier:cuuid; 123, identifier:euuid; 124, return_statement; 124, 125; 125, identifier:response; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 133; 128, subscript; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:self; 131, identifier:event_uuids; 132, identifier:euuid; 133, integer:0; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:logger; 138, identifier:debug; 139, argument_list; 139, 140; 140, binary_operator:%; 140, 141; 140, 144; 141, concatenated_string; 141, 142; 141, 143; 142, string:"<%s> <euuid:%s> Currently processing events: "; 143, string:"%s"; 144, tuple; 144, 145; 144, 146; 144, 147; 145, identifier:cuuid; 146, identifier:euuid; 147, call; 147, 148; 147, 149; 148, identifier:str; 149, argument_list; 149, 150; 150, attribute; 150, 151; 150, 152; 151, identifier:self; 152, identifier:event_uuids; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:logger; 157, identifier:debug; 158, argument_list; 158, 159; 159, binary_operator:%; 159, 160; 159, 161; 160, string:"<%s> <euuid:%s> New event being processed"; 161, tuple; 161, 162; 161, 163; 162, identifier:cuuid; 163, identifier:euuid; 164, expression_statement; 164, 165; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:logger; 168, identifier:debug; 169, argument_list; 169, 170; 170, binary_operator:%; 170, 171; 170, 172; 171, string:"<%s> <euuid:%s> Event Data: %s"; 172, tuple; 172, 173; 172, 174; 172, 175; 173, identifier:cuuid; 174, identifier:euuid; 175, call; 175, 176; 175, 177; 176, identifier:pformat; 177, argument_list; 177, 178; 178, identifier:event_data; 179, if_statement; 179, 180; 179, 190; 179, 254; 180, call; 180, 181; 180, 186; 181, attribute; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:self; 184, identifier:middleware; 185, identifier:event_legal; 186, argument_list; 186, 187; 186, 188; 186, 189; 187, identifier:cuuid; 188, identifier:euuid; 189, identifier:event_data; 190, block; 190, 191; 190, 204; 190, 227; 190, 248; 191, expression_statement; 191, 192; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:logger; 195, identifier:debug; 196, argument_list; 196, 197; 197, binary_operator:%; 197, 198; 197, 201; 198, concatenated_string; 198, 199; 198, 200; 199, string:"<%s> <euuid:%s> Event LEGAL. Sending judgement "; 200, string:"to client."; 201, tuple; 201, 202; 201, 203; 202, identifier:cuuid; 203, identifier:euuid; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 207; 206, identifier:response; 207, call; 207, 208; 207, 209; 208, identifier:serialize_data; 209, argument_list; 209, 210; 209, 220; 209, 223; 209, 226; 210, dictionary; 210, 211; 210, 214; 210, 217; 211, pair; 211, 212; 211, 213; 212, string:"method"; 213, string:"LEGAL"; 214, pair; 214, 215; 214, 216; 215, string:"euuid"; 216, identifier:euuid; 217, pair; 217, 218; 217, 219; 218, string:"priority"; 219, identifier:priority; 220, attribute; 220, 221; 220, 222; 221, identifier:self; 222, identifier:compression; 223, attribute; 223, 224; 223, 225; 224, identifier:self; 225, identifier:encryption; 226, identifier:client_key; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:thread; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:threading; 233, identifier:Thread; 234, argument_list; 234, 235; 234, 242; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:target; 237, attribute; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:self; 240, identifier:middleware; 241, identifier:event_execute; 242, keyword_argument; 242, 243; 242, 244; 243, identifier:args; 244, tuple; 244, 245; 244, 246; 244, 247; 245, identifier:cuuid; 246, identifier:euuid; 247, identifier:event_data; 248, expression_statement; 248, 249; 249, call; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:thread; 252, identifier:start; 253, argument_list; 254, else_clause; 254, 255; 255, block; 255, 256; 255, 269; 256, expression_statement; 256, 257; 257, call; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:logger; 260, identifier:debug; 261, argument_list; 261, 262; 262, binary_operator:%; 262, 263; 262, 266; 263, concatenated_string; 263, 264; 263, 265; 264, string:"<%s> <euuid:%s> Event ILLEGAL. Sending judgement "; 265, string:"to client."; 266, tuple; 266, 267; 266, 268; 267, identifier:cuuid; 268, identifier:euuid; 269, expression_statement; 269, 270; 270, assignment; 270, 271; 270, 272; 271, identifier:response; 272, call; 272, 273; 272, 274; 273, identifier:serialize_data; 274, argument_list; 274, 275; 274, 285; 274, 288; 274, 291; 275, dictionary; 275, 276; 275, 279; 275, 282; 276, pair; 276, 277; 276, 278; 277, string:"method"; 278, string:"ILLEGAL"; 279, pair; 279, 280; 279, 281; 280, string:"euuid"; 281, identifier:euuid; 282, pair; 282, 283; 282, 284; 283, string:"priority"; 284, identifier:priority; 285, attribute; 285, 286; 285, 287; 286, identifier:self; 287, identifier:compression; 288, attribute; 288, 289; 288, 290; 289, identifier:self; 290, identifier:encryption; 291, identifier:client_key; 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:listener; 298, identifier:call_later; 299, argument_list; 299, 300; 299, 303; 299, 306; 300, attribute; 300, 301; 300, 302; 301, identifier:self; 302, identifier:timeout; 303, attribute; 303, 304; 303, 305; 304, identifier:self; 305, identifier:retransmit; 306, dictionary; 306, 307; 306, 310; 306, 313; 307, pair; 307, 308; 307, 309; 308, string:"euuid"; 309, identifier:euuid; 310, pair; 310, 311; 310, 312; 311, string:"response"; 312, identifier:response; 313, pair; 313, 314; 313, 315; 314, string:"cuuid"; 315, identifier:cuuid; 316, return_statement; 316, 317; 317, identifier:response
def event(self, cuuid, host, euuid, event_data, timestamp, priority): response = None if host in self.encrypted_hosts: logger.debug("Encrypted!") client_key = self.registry[cuuid]["encryption"] else: logger.debug("Not encrypted :<") client_key = None port = host[1] host = host[0] if not self.is_registered(cuuid, host): logger.warning("<%s> Sending BYE EVENT: Client not registered." % cuuid) response = serialize_data({"method": "BYE EVENT", "data": "Not registered"}, self.compression, self.encryption, client_key) return response if euuid in self.event_uuids: logger.warning("<%s> Event ID is already being processed: %s" % (cuuid, euuid)) return response self.event_uuids[euuid] = 0 logger.debug("<%s> <euuid:%s> Currently processing events: " "%s" % (cuuid, euuid, str(self.event_uuids))) logger.debug("<%s> <euuid:%s> New event being processed" % (cuuid, euuid)) logger.debug("<%s> <euuid:%s> Event Data: %s" % (cuuid, euuid, pformat(event_data))) if self.middleware.event_legal(cuuid, euuid, event_data): logger.debug("<%s> <euuid:%s> Event LEGAL. Sending judgement " "to client." % (cuuid, euuid)) response = serialize_data({"method": "LEGAL", "euuid": euuid, "priority": priority}, self.compression, self.encryption, client_key) thread = threading.Thread(target=self.middleware.event_execute, args=(cuuid, euuid, event_data) ) thread.start() else: logger.debug("<%s> <euuid:%s> Event ILLEGAL. Sending judgement " "to client." % (cuuid, euuid)) response = serialize_data({"method": "ILLEGAL", "euuid": euuid, "priority": priority}, self.compression, self.encryption, client_key) self.listener.call_later(self.timeout, self.retransmit, {"euuid": euuid, "response": response, "cuuid": cuuid}) return response