# 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
        """Uploads the content to the repository, targetting object `object`

        Arguments:
            content {str} -- The Content as a string
            object_name {str} -- The name of the object to create/replace in the repository
            content_type {str} -- The MIME Type for the Content (defaults to 'text/plain')

        Raises:
            cpm.exceptions.RepositoryError -- If the was an error during the upload
        """
        try:
            blob = self.bucket.blob(object_name)
            blob.upload_from_string(content, content_type)
        except Exception as e:
            six.raise_from(RepositoryError(str(e)), e)

    def upload_file(self, object_name, file_obj):
        """Uploads the file to the repository, targetting object `object`

        Arguments:
            file_obj {file} -- The file to upload
            object_name {str} -- The name of the object to create/replace in the repository

        Raises:
            cpm.exceptions.RepositoryError -- If the was an error during the upload
        """
        try:
            blob = self.bucket.blob(object_name)
            blob.upload_from_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

        """Uploads the content to the repository, targetting object `object`

        Arguments:
            content {str} -- The Content as a string
            object_name {str} -- The name of the object to create/replace in the repository
            content_type {str} -- The MIME Type for the Content (defaults to 'text/plain')

        Raises:
            cpm.exceptions.RepositoryError -- If the was an error during the upload
        """
        try:
            blob = self.bucket.blob(object_name)
            blob.upload_from_string(content, content_type)
        except Exception as e:
            six.raise_from(RepositoryError(str(e)), e)

    def upload_file(self, object_name, file_obj):
        """Uploads the file to the repository, targetting object `object`

        Arguments:
            file_obj {file} -- The file to upload
            object_name {str} -- The name of the object to create/replace in the repository

        Raises:
            cpm.exceptions.RepositoryError -- If the was an error during the upload
        """
        try:
            blob = self.bucket.blob(object_name)
            blob.upload_from_file(file_obj)
        except Exception as e:

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