# Path: opendiamond/helpers.py
# def murmur(data):
#     '''Return a lower-case hex string representing the MurmurHash3-x64-128
#     hash of the specified data using the seed 0xbb40e64d (the first 10
#     digits of pi, in hex).'''
#     return mmh3.hash_bytes(data, 314159).hex()
# 
# def split_scheme(url):
#     if sys.version_info[0:3] == (2, 7, 1) and url.startswith('sha256:'):
#         return url.split(':')
# 
#     parts = urlparse(url)
#     return (parts.scheme, parts.path)
# 
# Path: opendiamond/protocol.py
# class XDR_attribute(XDRStruct):
#     '''An object attribute'''
#     members = (
#         'name', XDR.string(),
#         'value', XDR.opaque(),
#     )
# 
# class XDR_object(XDRStruct):
#     '''Blast channel object data'''
#     members = (
#         'attrs', XDR.array(XDR.struct(XDR_attribute)),
#     )


from future import standard_library
from builtins import str
from builtins import object
from io import BytesIO
from urllib.parse import urljoin
from opendiamond.helpers import murmur, split_scheme
from opendiamond.protocol import XDR_attribute, XDR_object
import logging
import simplejson as json
import pycurl as curl
import xmltodict
    the object itself. (happen only when retrieving from data retriever)
    - HTTP header ATTR_HEADER_URL='x-attributes', when retrieving the object itself.
    (happen only when retrieving from data retriever)
    """

    def __init__(self, config, blob_cache):
        self._http = _HttpLoader(config)
        self._blob_cache = blob_cache

    def source_available(self, obj):
        '''Examine the Object and return whether we think we will be able
        to load it, without actually doing so.  This can be used during
        reexecution to determine whether we should return
        DiamondRPCFCacheMiss to the client.'''
        scheme, path = split_scheme(str(obj))
        if scheme == 'sha256':
            return path in self._blob_cache
        # Assume we can always load other types of URLs
        return True

    def load(self, obj):
        '''Retrieve the Object and update it with the information we
        receive.'''

        # 0. Load src URI if not exist (mainly used for re-execution)
        self._load_src_maybe_meta(obj)

        # 1. Load object metadata from meta URI
        if hasattr(obj, 'meta'):
            uri = str(obj.meta)

# Path: opendiamond/helpers.py
# def murmur(data):
#     '''Return a lower-case hex string representing the MurmurHash3-x64-128
#     hash of the specified data using the seed 0xbb40e64d (the first 10
#     digits of pi, in hex).'''
#     return mmh3.hash_bytes(data, 314159).hex()
# 
# def split_scheme(url):
#     if sys.version_info[0:3] == (2, 7, 1) and url.startswith('sha256:'):
#         return url.split(':')
# 
#     parts = urlparse(url)
#     return (parts.scheme, parts.path)
# 
# Path: opendiamond/protocol.py
# class XDR_attribute(XDRStruct):
#     '''An object attribute'''
#     members = (
#         'name', XDR.string(),
#         'value', XDR.opaque(),
#     )
# 
# class XDR_object(XDRStruct):
#     '''Blast channel object data'''
#     members = (
#         'attrs', XDR.array(XDR.struct(XDR_attribute)),
#     )


# Path: opendiamond/server/object_.py
from future import standard_library
from builtins import str
from builtins import object
from io import BytesIO
from urllib.parse import urljoin
from opendiamond.helpers import murmur, split_scheme
from opendiamond.protocol import XDR_attribute, XDR_object
import logging
import simplejson as json
import pycurl as curl
import xmltodict

    the object itself. (happen only when retrieving from data retriever)
    - HTTP header ATTR_HEADER_URL='x-attributes', when retrieving the object itself.
    (happen only when retrieving from data retriever)
    """

    def __init__(self, config, blob_cache):
        self._http = _HttpLoader(config)
        self._blob_cache = blob_cache

    def source_available(self, obj):
        '''Examine the Object and return whether we think we will be able
        to load it, without actually doing so.  This can be used during
        reexecution to determine whether we should return
        DiamondRPCFCacheMiss to the client.'''
        scheme, path = split_scheme(str(obj))
        if scheme == 'sha256':
            return path in self._blob_cache
        # Assume we can always load other types of URLs
        return True

    def load(self, obj):
        '''Retrieve the Object and update it with the information we
        receive.'''

        # 0. Load src URI if not exist (mainly used for re-execution)
        self._load_src_maybe_meta(obj)

        # 1. Load object metadata from meta URI
        if hasattr(obj, 'meta'):
            uri = str(obj.meta)

            scheme, path = split_scheme(uri)