'Loads data from a file, which can contain either JSON or YAML.'

def load_from_file(self, file_name, cache=True, unsafe=False):

    file_name = self.path_dwim(file_name)
    display.debug(('Loading    data    from    %s' % file_name))
    if (cache and (file_name in self._FILE_CACHE)):
        parsed_data = self._FILE_CACHE[file_name]
    else:
        (b_file_data, show_content) = self._get_file_contents(file_name)
        file_data = to_text(b_file_data, errors='surrogate_or_strict')
        parsed_data = self.load(data=file_data, file_name=file_name, show_content=show_content)
        self._FILE_CACHE[file_name] = parsed_data
    if unsafe:
        return parsed_data
    else:
        return copy.deepcopy(parsed_data)
