# 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
        else:  # assume http
            self._load_dataretriever(obj, uri)

        # Set display name if not already in initial attributes
        if ATTR_DISPLAY_NAME not in obj:
            obj[ATTR_DISPLAY_NAME] = str(obj) + '\0'

    def _load_blobcache(self, obj, signature):
        # Load the object data
        try:
            obj[ATTR_DATA] = self._blob_cache[signature]
        except KeyError:
            raise ObjectLoadError('Object not in cache')

    def _load_dataretriever(self, obj, url):
        headers, body = self._http.get(url)
        # Load the object data
        obj[ATTR_DATA] = body
        # Process loose initial attributes
        for key, value in headers.items():
            if key.lower().startswith(ATTR_HEADER_PREFIX):
                key = key[ATTR_HEADER_PREFIX_LEN:]
                obj[key] = value + '\0'
        # Fetch additional initial attributes if specified
        if ATTR_HEADER_URL in headers:
            attr_url = urljoin(url, headers[ATTR_HEADER_URL])
            self._load_attributes(obj, attr_url)

    def _load_localfile(self, obj, path):
        with open(path, 'rb') as f:

# 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

        else:  # assume http
            self._load_dataretriever(obj, uri)

        # Set display name if not already in initial attributes
        if ATTR_DISPLAY_NAME not in obj:
            obj[ATTR_DISPLAY_NAME] = str(obj) + '\0'

    def _load_blobcache(self, obj, signature):
        # Load the object data
        try:
            obj[ATTR_DATA] = self._blob_cache[signature]
        except KeyError:
            raise ObjectLoadError('Object not in cache')

    def _load_dataretriever(self, obj, url):
        headers, body = self._http.get(url)
        # Load the object data
        obj[ATTR_DATA] = body
        # Process loose initial attributes
        for key, value in headers.items():
            if key.lower().startswith(ATTR_HEADER_PREFIX):
                key = key[ATTR_HEADER_PREFIX_LEN:]
                obj[key] = value + '\0'
        # Fetch additional initial attributes if specified
        if ATTR_HEADER_URL in headers:
            attr_url = urljoin(url, headers[ATTR_HEADER_URL])
            self._load_attributes(obj, attr_url)

    def _load_localfile(self, obj, path):
        with open(path, 'rb') as f:

            obj[ATTR_DATA] = f.read()