sample_metadata/parser/generic_parser.py
def file_contents(self, filename) -> Optional[str]:
        """Get contents of file (decoded as utf8)"""
        path = self.file_path(filename)
        if path.startswith('gs://'):
            blob = self.get_blob(path)
            try:
                retval = blob.download_as_string()
                if isinstance(retval, bytes):
                    retval = retval.decode()
                return retval
            except Forbidden:
                logger.warning(f"FORBIDDEN: Can't download {filename}")
                return None

        with open(filename, encoding='utf-8') as f:
            return f.read()
Get contents of file (decoded as utf8)
Get contents of file (decoded as utf8)
Get contents of file ( decoded as utf8 )
def file_contents(self, filename) -> Optional[str]:
        path = self.file_path(filename)
        if path.startswith('gs://'):
            blob = self.get_blob(path)
            try:
                retval = blob.download_as_string()
                if isinstance(retval, bytes):
                    retval = retval.decode()
                return retval
            except Forbidden:
                logger.warning(f"FORBIDDEN: Can't download {filename}")
                return None
        with open(filename, encoding='utf-8') as f:
            return f.read()
def file_contents ( self , filename ) -> Optional [ str ] : path = self . file_path ( filename ) if path . startswith ( 'gs://' ) : blob = self . get_blob ( path ) try : retval = blob . download_as_string ( ) if isinstance ( retval , bytes ) : retval = retval . decode ( ) return retval except Forbidden : logger . warning ( f"FORBIDDEN: Can't download {filename}" ) return None with open ( filename , encoding = 'utf-8' ) as f : return f . read ( )
Get contents of file (decoded as utf8)
Get contents of file ( decoded as utf8 )
"""Get contents of file (decoded as utf8)"""
self
filename