# Path: eulfedora/util.py
# def force_bytes(s, encoding='utf-8'):
#     if isinstance(s, bytes):
#         if encoding == 'utf-8':
#             return s
#         else:
#             return s.decode('utf-8').encode(encoding)
# 
#     if not isinstance(s, six.string_types):
#         if six.PY3:
#             return six.text_type(s).encode(encoding)
#         else:
#             return bytes(s)
#     else:
#         return s.encode(encoding)
# 
# def force_text(s, encoding='utf-8'):
#     if six.PY3:
#         if isinstance(s, bytes):
#             s = six.text_type(s, encoding)
#         else:
#             s = six.text_type(s)
#     else:
#         s = six.text_type(bytes(s), encoding)
# 
#     return s


import binascii
import hashlib
import io
import logging
import math
import re
import six
    import progressbar
from six.moves.urllib.parse import urlparse
from eulfedora.util import force_bytes, force_text
                    except ValueError:
                        # if dsid doesn't include a .# (for versioning),
                        # use the id as is.
                        dsid = dsinfo['id']

                    if self.url_credentials:
                        # if url credentials are set, parse the base fedora api
                        # url so they can be inserted at the right place
                        parsed_url = urlparse(self.obj.api.base_url)
                        # reassemble base url, adding in credentials
                        base_url = ''.join([parsed_url.scheme, '://',
                            self.url_credentials, parsed_url.netloc,
                            parsed_url.path])
                    else:
                        base_url = self.obj.api.base_url

                    # versioned datastream dissemination url
                    content_location = '%sobjects/%s/datastreams/%s/content?asOfDateTime=%s' % \
                        (base_url, self.obj.pid, dsid, dsinfo['created'])
                else:
                    upload_args = {}
                    if self.progress_bar:
                        def upload_callback(monitor):
                            self.progress_bar.upload = monitor.bytes_read
                        upload_args = {'callback': upload_callback}

                    # use upload id as content location
                    content_location = self.dest_repo.api.upload(self.encoded_datastream(),
                        size=int(dsinfo['size']), **upload_args)


# Path: eulfedora/util.py
# def force_bytes(s, encoding='utf-8'):
#     if isinstance(s, bytes):
#         if encoding == 'utf-8':
#             return s
#         else:
#             return s.decode('utf-8').encode(encoding)
# 
#     if not isinstance(s, six.string_types):
#         if six.PY3:
#             return six.text_type(s).encode(encoding)
#         else:
#             return bytes(s)
#     else:
#         return s.encode(encoding)
# 
# def force_text(s, encoding='utf-8'):
#     if six.PY3:
#         if isinstance(s, bytes):
#             s = six.text_type(s, encoding)
#         else:
#             s = six.text_type(s)
#     else:
#         s = six.text_type(bytes(s), encoding)
# 
#     return s


# Path: eulfedora/syncutil.py
import binascii
import hashlib
import io
import logging
import math
import re
import six
    import progressbar
from six.moves.urllib.parse import urlparse
from eulfedora.util import force_bytes, force_text

                    except ValueError:
                        # if dsid doesn't include a .# (for versioning),
                        # use the id as is.
                        dsid = dsinfo['id']

                    if self.url_credentials:
                        # if url credentials are set, parse the base fedora api
                        # url so they can be inserted at the right place
                        parsed_url = urlparse(self.obj.api.base_url)
                        # reassemble base url, adding in credentials
                        base_url = ''.join([parsed_url.scheme, '://',
                            self.url_credentials, parsed_url.netloc,
                            parsed_url.path])
                    else:
                        base_url = self.obj.api.base_url

                    # versioned datastream dissemination url
                    content_location = '%sobjects/%s/datastreams/%s/content?asOfDateTime=%s' % \
                        (base_url, self.obj.pid, dsid, dsinfo['created'])
                else:
                    upload_args = {}
                    if self.progress_bar:
                        def upload_callback(monitor):
                            self.progress_bar.upload = monitor.bytes_read
                        upload_args = {'callback': upload_callback}

                    # use upload id as content location
                    content_location = self.dest_repo.api.upload(self.encoded_datastream(),
                        size=int(dsinfo['size']), **upload_args)


                self.foxml_buffer.write(force_bytes('<foxml:contentLocation REF="%s" TYPE="URL"/>' \