# Path: ethronsoft/gcspypi/exceptions/repository_errors.py
# class RepositoryError(Exception):
#     pass
# 
# Path: ethronsoft/gcspypi/exceptions/boundary_errors.py
# class NotFound(Exception):
#     pass
# 
# Path: ethronsoft/gcspypi/repository/object_metadata.py
# class ObjectMetadata(object):
#     """ObjectMetadata represents the metadata associated with a repository Object
#     """
# 
#     def __init__(self, mime, md5_hash, time_created):
#         """ObjectMetadata constructor
#         
#         Arguments:
#             mime {str} -- MIME type of object
#             md5_hash {str} -- Hash representing the object. Can be used to determine content equality
#             time_created {datetime} -- Timestamp for the object creation
#         """
# 
#         self.mime = mime
#         self.md5 = md5_hash
#         self.time_created = time_created


from google.cloud import storage
from ethronsoft.gcspypi.exceptions import RepositoryError, NotFound
from .object_metadata import ObjectMetadata
import six
import sys
import warnings

        Arguments:
            object_name {str} -- Name of object to download

        Raises:
            cpm.exceptions.NotFound -- If the object_name does not exist

        Returns:
            str -- Content as string
        """
        blob = self.bucket.blob(object_name)
        try:
            return blob.download_as_string()
        except Exception as e:
            six.raise_from(RepositoryError(str(e)), e)

    def download_file(self, object_name, file_obj):
        """Download the object_name to a file `file_name`

        Arguments:
            object_name {str} -- Name of object to download
            file_obj {file} -- File object to write into

        Raises:
            cpm.exceptions.NotFound -- If the object_name does not exist    
        """
        blob = self.bucket.blob(object_name)
        try:
            return blob.download_to_file(file_obj)
        except Exception as e:

# Path: ethronsoft/gcspypi/exceptions/repository_errors.py
# class RepositoryError(Exception):
#     pass
# 
# Path: ethronsoft/gcspypi/exceptions/boundary_errors.py
# class NotFound(Exception):
#     pass
# 
# Path: ethronsoft/gcspypi/repository/object_metadata.py
# class ObjectMetadata(object):
#     """ObjectMetadata represents the metadata associated with a repository Object
#     """
# 
#     def __init__(self, mime, md5_hash, time_created):
#         """ObjectMetadata constructor
#         
#         Arguments:
#             mime {str} -- MIME type of object
#             md5_hash {str} -- Hash representing the object. Can be used to determine content equality
#             time_created {datetime} -- Timestamp for the object creation
#         """
# 
#         self.mime = mime
#         self.md5 = md5_hash
#         self.time_created = time_created


# Path: ethronsoft/gcspypi/repository/gcloud_remote.py
from google.cloud import storage
from ethronsoft.gcspypi.exceptions import RepositoryError, NotFound
from .object_metadata import ObjectMetadata
import six
import sys
import warnings


        Arguments:
            object_name {str} -- Name of object to download

        Raises:
            cpm.exceptions.NotFound -- If the object_name does not exist

        Returns:
            str -- Content as string
        """
        blob = self.bucket.blob(object_name)
        try:
            return blob.download_as_string()
        except Exception as e:
            six.raise_from(RepositoryError(str(e)), e)

    def download_file(self, object_name, file_obj):
        """Download the object_name to a file `file_name`

        Arguments:
            object_name {str} -- Name of object to download
            file_obj {file} -- File object to write into

        Raises:
            cpm.exceptions.NotFound -- If the object_name does not exist    
        """
        blob = self.bucket.blob(object_name)
        try:
            return blob.download_to_file(file_obj)
        except Exception as e:

            six.raise_from(NotFound(str(e)), e)