# Path: oioswift/common/middleware/versioned_writes.py
# DELETE_MARKER_CONTENT_TYPE = vw.DELETE_MARKER_CONTENT_TYPE
# 
# Path: oioswift/utils.py
# def handle_oio_no_such_container(fnc):
#     """Catch NoSuchContainer errors and return '404 Not Found'"""
#     @wraps(fnc)
#     def _oio_no_such_container_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except NoSuchContainer:
#             return HTTPNotFound(request=req)
#     return _oio_no_such_container_wrapper
# 
# def handle_oio_timeout(fnc):
#     """
#     Catch DeadlineReached and OioTimeout errors
#     and return '503 Service Unavailable'.
#     """
#     @wraps(fnc)
#     def _oio_timeout_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (DeadlineReached, OioTimeout) as exc:
#             headers = dict()
#             # TODO(FVE): choose the value according to the timeout
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=str(exc))
#     return _oio_timeout_wrapper
# 
# def handle_service_busy(fnc):
#     @wraps(fnc)
#     def _service_busy_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (ServiceBusy, ServiceUnavailable) as err:
#             headers = dict()
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=err.message)
#     return _service_busy_wrapper
# 
# REQID_HEADER = 'x-oio-req-id'
# 
# BUCKET_NAME_PROP = "sys.m2.bucket.name"
# 
# MULTIUPLOAD_SUFFIX = '+segments'


import json
from xml.etree.cElementTree import Element, SubElement, tostring
from swift.common.utils import public, Timestamp, \
    override_bytes_from_content_type
from swift.common.constraints import check_metadata
from swift.common import constraints
    from swift.common.middleware.listing_formats import \
        get_listing_content_type
    from swift.common.request_helpers import get_listing_content_type
from oioswift.common.middleware.versioned_writes import \
    DELETE_MARKER_CONTENT_TYPE
from swift.common.swob import Response, HTTPBadRequest, HTTPNotFound, \
    HTTPNoContent, HTTPConflict, HTTPPreconditionFailed, HTTPForbidden, \
    HTTPCreated
from swift.common.http import is_success, HTTP_ACCEPTED
from swift.common.request_helpers import is_sys_or_user_meta, get_param
from swift.proxy.controllers.container import ContainerController \
        as SwiftContainerController
from swift.proxy.controllers.base import clear_info_cache, \
    delay_denial, cors_validation, set_info_cache
from oio.common import exceptions
from oioswift.utils import \
    handle_oio_no_such_container, handle_oio_timeout, \
    handle_service_busy, REQID_HEADER, BUCKET_NAME_PROP, MULTIUPLOAD_SUFFIX
        else:
            if not container_list:
                return HTTPNoContent(request=req, headers=resp_headers)
            ret.body = '\n'.join(rec['name'] for rec in container_list) + '\n'

        return ret

    def update_data_record(self, record, versions=False, slo=False):
        if 'subdir' in record:
            return {'subdir': record['name']}

        props = record.get('properties', {})
        # This metadata is added by encryption middleware.
        if 'x-object-sysmeta-container-update-override-etag' in props:
            hash_ = props['x-object-sysmeta-container-update-override-etag']
        else:
            hash_ = record.get('hash')
            if hash_ is not None:
                hash_ = hash_.lower()

        response = {'name': record['name'],
                    'bytes': record['size'],
                    'last_modified': Timestamp(record['mtime']).isoformat,
                    'content_type': record.get(
                        'mime_type', 'application/octet-stream')}
        if hash_:
            response['hash'] = hash_
        else:
            response['hash'] = ''
        if record.get('deleted', False):

# Path: oioswift/common/middleware/versioned_writes.py
# DELETE_MARKER_CONTENT_TYPE = vw.DELETE_MARKER_CONTENT_TYPE
# 
# Path: oioswift/utils.py
# def handle_oio_no_such_container(fnc):
#     """Catch NoSuchContainer errors and return '404 Not Found'"""
#     @wraps(fnc)
#     def _oio_no_such_container_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except NoSuchContainer:
#             return HTTPNotFound(request=req)
#     return _oio_no_such_container_wrapper
# 
# def handle_oio_timeout(fnc):
#     """
#     Catch DeadlineReached and OioTimeout errors
#     and return '503 Service Unavailable'.
#     """
#     @wraps(fnc)
#     def _oio_timeout_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (DeadlineReached, OioTimeout) as exc:
#             headers = dict()
#             # TODO(FVE): choose the value according to the timeout
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=str(exc))
#     return _oio_timeout_wrapper
# 
# def handle_service_busy(fnc):
#     @wraps(fnc)
#     def _service_busy_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (ServiceBusy, ServiceUnavailable) as err:
#             headers = dict()
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=err.message)
#     return _service_busy_wrapper
# 
# REQID_HEADER = 'x-oio-req-id'
# 
# BUCKET_NAME_PROP = "sys.m2.bucket.name"
# 
# MULTIUPLOAD_SUFFIX = '+segments'


# Path: oioswift/proxy/controllers/container.py
import json
from xml.etree.cElementTree import Element, SubElement, tostring
from swift.common.utils import public, Timestamp, \
    override_bytes_from_content_type
from swift.common.constraints import check_metadata
from swift.common import constraints
    from swift.common.middleware.listing_formats import \
        get_listing_content_type
    from swift.common.request_helpers import get_listing_content_type
from oioswift.common.middleware.versioned_writes import \
    DELETE_MARKER_CONTENT_TYPE
from swift.common.swob import Response, HTTPBadRequest, HTTPNotFound, \
    HTTPNoContent, HTTPConflict, HTTPPreconditionFailed, HTTPForbidden, \
    HTTPCreated
from swift.common.http import is_success, HTTP_ACCEPTED
from swift.common.request_helpers import is_sys_or_user_meta, get_param
from swift.proxy.controllers.container import ContainerController \
        as SwiftContainerController
from swift.proxy.controllers.base import clear_info_cache, \
    delay_denial, cors_validation, set_info_cache
from oio.common import exceptions
from oioswift.utils import \
    handle_oio_no_such_container, handle_oio_timeout, \
    handle_service_busy, REQID_HEADER, BUCKET_NAME_PROP, MULTIUPLOAD_SUFFIX

        else:
            if not container_list:
                return HTTPNoContent(request=req, headers=resp_headers)
            ret.body = '\n'.join(rec['name'] for rec in container_list) + '\n'

        return ret

    def update_data_record(self, record, versions=False, slo=False):
        if 'subdir' in record:
            return {'subdir': record['name']}

        props = record.get('properties', {})
        # This metadata is added by encryption middleware.
        if 'x-object-sysmeta-container-update-override-etag' in props:
            hash_ = props['x-object-sysmeta-container-update-override-etag']
        else:
            hash_ = record.get('hash')
            if hash_ is not None:
                hash_ = hash_.lower()

        response = {'name': record['name'],
                    'bytes': record['size'],
                    'last_modified': Timestamp(record['mtime']).isoformat,
                    'content_type': record.get(
                        'mime_type', 'application/octet-stream')}
        if hash_:
            response['hash'] = hash_
        else:
            response['hash'] = ''
        if record.get('deleted', False):

            response['content_type'] = DELETE_MARKER_CONTENT_TYPE