def get_local_facts_from_file(filename):
 local_facts = dict()
 try:
  ini_facts = configparser.SafeConfigParser()
  ini_facts.read(filename)
  for section in ini_facts.sections():
   local_facts[section] = dict()
   for (key, value) in ini_facts.items(section):
    local_facts[section][key] = value
 except (configparser.MissingSectionHeaderError, configparser.ParsingError):
  try:
   with open(filename, 'r') as facts_file:
    local_facts = json.load(facts_file)
  except (ValueError, IOError):
   pass
 return local_facts

def get_local_facts_from_file ( filename ) : local_facts = dict ( ) try : ini_facts = configparser . SafeConfigParser ( ) ini_facts . read ( filename ) for section in ini_facts . sections ( ) : local_facts [ section ] = dict ( ) for ( key , value ) in ini_facts . items ( section ) : local_facts [ section ] [ key ] = value except ( configparser . MissingSectionHeaderError , configparser . ParsingError ) : try : with open ( filename , 'r' ) as facts_file : local_facts = json . load ( facts_file ) except ( ValueError , IOError ) : pass return local_facts
retrieve local facts from fact file args: filename : local facts file returns: dict: the retrieved facts .