@@ -1955,11 +1955,11 @@ def value_is_valid(value):
19551955 return not math .isinf (value ) and not math .isnan (value )
19561956 return True
19571957
1958- if self .analysis_status == "OK" and \
1959- 'descriptors_map' in settings . ANALYZERS_CONFIGURATION . get ( self . analyzer , {}) :
1958+ analysis_configuration = settings . ANALYZERS_CONFIGURATION . get ( self .analyzer , {})
1959+ if self . analysis_status == "OK" and 'descriptors_map' in analysis_configuration :
19601960 analysis_results = self .get_analysis_data_from_file ()
19611961 if analysis_results :
1962- descriptors_map = settings . ANALYZERS_CONFIGURATION [ self . analyzer ] ['descriptors_map' ]
1962+ descriptors_map = analysis_configuration ['descriptors_map' ]
19631963 analysis_data_for_db = {}
19641964 for file_descriptor_key_path , db_descriptor_key , _ in descriptors_map :
19651965 # TODO: here we could implement support for nested keys in the analysis file, maybe by accessing
@@ -1976,18 +1976,16 @@ def value_is_valid(value):
19761976 def get_analysis_data_from_file (self ):
19771977 """Returns the analysis data as stored in file or returns empty dict if no file exists. It tries
19781978 extensions .json and .yaml as these are the supported formats for analysis results"""
1979- if os .path .exists (self .analysis_filepath_base + '.json' ):
1980- try :
1981- with open (self .analysis_filepath_base + '.json' ) as f :
1982- return json .load (f )
1983- except Exception :
1984- pass
1985- if os .path .exists (self .analysis_filepath_base + '.yaml' ):
1986- try :
1987- with open (self .analysis_filepath_base + '.yaml' ) as f :
1988- return yaml .load (f , Loader = yaml .cyaml .CSafeLoader )
1989- except Exception :
1990- pass
1979+ try :
1980+ with open (self .analysis_filepath_base + '.json' ) as f :
1981+ return json .load (f )
1982+ except Exception :
1983+ pass
1984+ try :
1985+ with open (self .analysis_filepath_base + '.yaml' ) as f :
1986+ return yaml .load (f , Loader = yaml .cyaml .CSafeLoader )
1987+ except Exception :
1988+ pass
19911989 return {}
19921990
19931991 def get_analysis_data (self ):
0 commit comments