original_docstring: 
          Load the metric variables for a check from a metric check variables file
  
          :param metric_vars_file: the path and filename to the metric variables files
          :type metric_vars_file: str
          :return: the metric_vars list or ``False``
          :rtype: list
  
          
docstring: Load the metric variables for a check from a metric check variables file
docstring_tokens: Load the metric variables for a check from a metric check variables file
code: def new_load_metric_vars(self, metric_vars_file):
          """
          Load the metric variables for a check from a metric check variables file
  
          :param metric_vars_file: the path and filename to the metric variables files
          :type metric_vars_file: str
          :return: the metric_vars list or ``False``
          :rtype: list
  
          """
          if os.path.isfile(metric_vars_file):
              logger.info(
                  'loading metric variables from metric_check_file - %s' % (
                      str(metric_vars_file)))
          else:
              logger.error(
                  'error :: loading metric variables from metric_check_file - file not found - %s' % (
                      str(metric_vars_file)))
              return False
  
          metric_vars = []
          with open(metric_vars_file) as f:
              for line in f:
                  no_new_line = line.replace('\n', '')
                  no_equal_line = no_new_line.replace(' = ', ',')
                  array = str(no_equal_line.split(',', 1))
                  add_line = literal_eval(array)
                  metric_vars.append(add_line)
  
          string_keys = ['metric', 'anomaly_dir', 'added_by', 'app', 'source']
          float_keys = ['value']
          # @modified 20170127 - Feature #1886: Ionosphere learn - child like parent with evolutionary maturity
          # Added ionosphere_parent_id, always zero from Analyzer and Mirage
          int_keys = [
              'from_timestamp', 'metric_timestamp', 'added_at', 'full_duration',
              'ionosphere_parent_id']
          # @added 20201001 - Task #3748: POC SNAB
          # Added algorithms_run required to determine the anomalyScore
          # so this needs to be sent to Ionosphere so Ionosphere
          # can send it back on an alert.
          array_keys = ['triggered_algorithms', 'algorithms', 'algorithms_run']
          boolean_keys = ['graphite_metric', 'run_crucible_tests']
  
          metric_vars_array = []
          for var_array in metric_vars:
              key = None
              value = None
              if var_array[0] in string_keys:
                  key = var_array[0]
                  value_str = str(var_array[1]).replace("'", '')
                  value = str(value_str)
                  if var_array[0] == 'metric':
                      metric = value
              if var_array[0] in float_keys:
                  key = var_array[0]
                  value_str = str(var_array[1]).replace("'", '')
                  value = float(value_str)
              if var_array[0] in int_keys:
                  key = var_array[0]
                  value_str = str(var_array[1]).replace("'", '')
                  value = int(value_str)
              if var_array[0] in array_keys:
                  key = var_array[0]
                  value = literal_eval(str(var_array[1]))
              if var_array[0] in boolean_keys:
                  key = var_array[0]
                  if str(var_array[1]) == 'True':
                      value = True
                  else:
                      value = False
              if key:
                  metric_vars_array.append([key, value])
  
              if len(metric_vars_array) == 0:
                  logger.error(
                      'error :: loading metric variables - none found' % (
                          str(metric_vars_file)))
                  return False
  
          logger.info('debug :: metric_vars for %s' % str(metric))
          logger.info('debug :: %s' % str(metric_vars_array))
  
          return metric_vars_array
code_tokens: def new_load_metric_vars ( self , metric_vars_file ) : if os . path . isfile ( metric_vars_file ) : logger . info ( 'loading metric variables from metric_check_file - %s' % ( str ( metric_vars_file ) ) ) else : logger . error ( 'error :: loading metric variables from metric_check_file - file not found - %s' % ( str ( metric_vars_file ) ) ) return False metric_vars = [ ] with open ( metric_vars_file ) as f : for line in f : no_new_line = line . replace ( '\n' , '' ) no_equal_line = no_new_line . replace ( ' = ' , ',' ) array = str ( no_equal_line . split ( ',' , 1 ) ) add_line = literal_eval ( array ) metric_vars . append ( add_line ) string_keys = [ 'metric' , 'anomaly_dir' , 'added_by' , 'app' , 'source' ] float_keys = [ 'value' ] int_keys = [ 'from_timestamp' , 'metric_timestamp' , 'added_at' , 'full_duration' , 'ionosphere_parent_id' ] array_keys = [ 'triggered_algorithms' , 'algorithms' , 'algorithms_run' ] boolean_keys = [ 'graphite_metric' , 'run_crucible_tests' ] metric_vars_array = [ ] for var_array in metric_vars : key = None value = None if var_array [ 0 ] in string_keys : key = var_array [ 0 ] value_str = str ( var_array [ 1 ] ) . replace ( "'" , '' ) value = str ( value_str ) if var_array [ 0 ] == 'metric' : metric = value if var_array [ 0 ] in float_keys : key = var_array [ 0 ] value_str = str ( var_array [ 1 ] ) . replace ( "'" , '' ) value = float ( value_str ) if var_array [ 0 ] in int_keys : key = var_array [ 0 ] value_str = str ( var_array [ 1 ] ) . replace ( "'" , '' ) value = int ( value_str ) if var_array [ 0 ] in array_keys : key = var_array [ 0 ] value = literal_eval ( str ( var_array [ 1 ] ) ) if var_array [ 0 ] in boolean_keys : key = var_array [ 0 ] if str ( var_array [ 1 ] ) == 'True' : value = True else : value = False if key : metric_vars_array . append ( [ key , value ] ) if len ( metric_vars_array ) == 0 : logger . error ( 'error :: loading metric variables - none found' % ( str ( metric_vars_file ) ) ) return False logger . info ( 'debug :: metric_vars for %s' % str ( metric ) ) logger . info ( 'debug :: %s' % str ( metric_vars_array ) ) return metric_vars_array
short_docstring: Load the metric variables for a check from a metric check variables file
short_docstring_tokens: Load the metric variables for a check from a metric check variables file
comment: """
          Load the metric variables for a check from a metric check variables file
  
          :param metric_vars_file: the path and filename to the metric variables files
          :type metric_vars_file: str
          :return: the metric_vars list or ``False``
          :rtype: list
  
          """$SEP$# @modified 20170127 - Feature #1886: Ionosphere learn - child like parent with evolutionary maturity$SEP$# Added ionosphere_parent_id, always zero from Analyzer and Mirage$SEP$# @added 20201001 - Task #3748: POC SNAB$SEP$# Added algorithms_run required to determine the anomalyScore$SEP$# so this needs to be sent to Ionosphere so Ionosphere$SEP$# can send it back on an alert.