Read the contents of a file

    :param file_path:                   Path of the file to be read

    :return:                            Contents of the file
186660
def read_file(file_path, mode = 'rt'):
    
    contents = ''
    with open(file_path, mode) as f:
        contents = f.read()
    return contents
932838
def read(*paths):
    """"""
    basedir = os.path.dirname(__file__)
    fullpath = os.path.join(basedir, *paths)
    contents = io.open(fullpath, encoding='utf-8').read().strip()
    return contents
1219591
def read(path, saltenv='base'):
    '''
    
    '''
    # Return a dict of paths + content
    ret = []
    files = find(path, saltenv)
    for fn_ in files:
        full = next(six.iterkeys(fn_))
        form = fn_[full]
        if form == 'txt':
            with salt.utils.files.fopen(full, 'rb') as fp_:
                ret.append(
                    {full: salt.utils.stringutils.to_unicode(fp_.read())}
                )
    return ret
244557
def _read_file(path):
    '''
    
    '''
    try:
        with salt.utils.files.flopen(path, 'rb') as contents:
            return [salt.utils.stringutils.to_str(line) for line in contents.readlines()]
    except (OSError, IOError):
        return ''
516970
def load_data(cls, relpath):
        
        filepath = os.path.join(cls.data_path, relpath)
        with open(filepath) as fp:
            content = fp.read()

        return content
728094
def read_filepath(filepath, encoding='utf-8'):
    """"""
    with codecs.open(filepath, 'r', encoding=encoding) as fo:
        return fo.read()
296857
def get_file(self, file_path, mode="r"):
        
        return open(self.p(file_path), mode=mode)
1244282
def load_json_file_contents(path: str) -> str:
    
    assert isinstance(path, str)
    content = None

    file_path = os.path.abspath(path)
    content = fileutils.read_text_from_file(file_path)
    json_object = json.loads(content)
    content = json.dumps(json_object, sort_keys=True, indent=4)

    return content
321152
def read_file(file_path, default_content=''):
    
    if not os.path.exists(file_path):
        write_file(file_path, default_content)

    handler = open(file_path, 'r')
    content = handler.read()
    handler.close()
    return content or default_content
144165
def read_file(path):
    """"""
    file_path = os.path.join(here, *path)
    with open(file_path, encoding="utf-8") as f:
        return f.read()
510631
def read_file(cls, filepath):
        
        with open(filepath, mode='rb') as f:
            contents = f.read()
        return cls.decode(contents)
87356
def file_contents(self, filename, binary=False):
        
        if binary:
            mode = 'rb'
        else:
            mode = 'r'
        try:
            with open(filename, mode) as f:
                return f.read()
        except (OSError, IOError) as e:
            raise FileReadError(str(e))
292444
def read_txt_file(filepath):
    
    if sys.version > '3':
        with open(filepath,'r',encoding='utf-8') as txt_file:
            return txt_file.readlines()
    else:
        with open(filepath) as txt_file:
            return txt_file.readlines()
1349779
def get_file(self, file_path):
    

    try:
      resp = self._conn.get_object(
        Bucket=self._path.bucket,
        Key=self.get_path_to_file(file_path),
      )

      encoding = ''
      if 'ContentEncoding' in resp:
        encoding = resp['ContentEncoding']

      return resp['Body'].read(), encoding
    except botocore.exceptions.ClientError as err: 
      if err.response['Error']['Code'] == 'NoSuchKey':
        return None, None
      else:
        raise
871803
def str_from_file(path):
    
    with open(path) as f:
        s = f.read().strip()
    return s
1075774
def get_email_content(file_path):
    
    with open(file_path, "r") as in_file:
        text = str(in_file.read())
        return text.replace("\n\n", "<br>")
871844
def load(self, file_path):
        '''  '''
        self.clear()
        self.__config = self.read_file(file_path)