# Path: soco/exceptions.py
# class DIDLMetadataError(CannotCreateDIDLMetadata):
# 
#     """Raised if a data container class cannot create the DIDL metadata due to
#     missing information.
# 
#     For backward compatibility, this is currently a subclass of
#     `CannotCreateDIDLMetadata`. In a future version, it will likely become
#     a direct subclass of `SoCoException`.
#     """
# 
# Path: soco/utils.py
# def really_unicode(in_string):
#     """Make a string unicode. Really.
# 
#     Ensure ``in_string`` is returned as unicode through a series of
#     progressively relaxed decodings.
# 
#     Args:
#         in_string (str): The string to convert.
# 
#     Returns:
#         str: Unicode.
# 
#     Raises:
#         ValueError
#     """
#     if isinstance(in_string, bytes):
#         for args in (("utf-8",), ("latin-1",), ("ascii", "replace")):
#             try:
#                 # pylint: disable=star-args
#                 in_string = in_string.decode(*args)
#                 break
#             except UnicodeDecodeError:
#                 continue
#     if not isinstance(in_string, str):
#         raise ValueError("%s is not a string at all." % in_string)
#     return in_string
# 
# def first_cap(string):
#     """Return upper cased first character"""
#     return string[0].upper() + string[1:]


import textwrap
import warnings
from .exceptions import DIDLMetadataError
from .utils import really_unicode, first_cap
from .xml import XML, ns_tag
from .data_structure_quirks import apply_resource_quirks
            from . import data_structures_entry
            )
        # Optional
        content["import_uri"] = element.get("importUri")
        content["size"] = _int_helper("size")
        content["duration"] = element.get("duration")
        content["bitrate"] = _int_helper("bitrate")
        content["sample_frequency"] = _int_helper("sampleFrequency")
        content["bits_per_sample"] = _int_helper("bitsPerSample")
        content["nr_audio_channels"] = _int_helper("nrAudioChannels")
        content["resolution"] = element.get("resolution")
        content["color_depth"] = _int_helper("colorDepth")
        content["protection"] = element.get("protection")
        content["uri"] = element.text
        return cls(**content)

    def __repr__(self):
        return "<{} '{}' at {}>".format(
            self.__class__.__name__, self.uri, hex(id(self))
        )

    def __str__(self):
        return self.__repr__()

    def to_element(self):
        """Return an ElementTree Element based on this resource.

        Returns:
            ~xml.etree.ElementTree.Element: an Element.
        """
        if not self.protocol_info:

# Path: soco/exceptions.py
# class DIDLMetadataError(CannotCreateDIDLMetadata):
# 
#     """Raised if a data container class cannot create the DIDL metadata due to
#     missing information.
# 
#     For backward compatibility, this is currently a subclass of
#     `CannotCreateDIDLMetadata`. In a future version, it will likely become
#     a direct subclass of `SoCoException`.
#     """
# 
# Path: soco/utils.py
# def really_unicode(in_string):
#     """Make a string unicode. Really.
# 
#     Ensure ``in_string`` is returned as unicode through a series of
#     progressively relaxed decodings.
# 
#     Args:
#         in_string (str): The string to convert.
# 
#     Returns:
#         str: Unicode.
# 
#     Raises:
#         ValueError
#     """
#     if isinstance(in_string, bytes):
#         for args in (("utf-8",), ("latin-1",), ("ascii", "replace")):
#             try:
#                 # pylint: disable=star-args
#                 in_string = in_string.decode(*args)
#                 break
#             except UnicodeDecodeError:
#                 continue
#     if not isinstance(in_string, str):
#         raise ValueError("%s is not a string at all." % in_string)
#     return in_string
# 
# def first_cap(string):
#     """Return upper cased first character"""
#     return string[0].upper() + string[1:]


# Path: soco/data_structures.py
import textwrap
import warnings
from .exceptions import DIDLMetadataError
from .utils import really_unicode, first_cap
from .xml import XML, ns_tag
from .data_structure_quirks import apply_resource_quirks
            from . import data_structures_entry

            )
        # Optional
        content["import_uri"] = element.get("importUri")
        content["size"] = _int_helper("size")
        content["duration"] = element.get("duration")
        content["bitrate"] = _int_helper("bitrate")
        content["sample_frequency"] = _int_helper("sampleFrequency")
        content["bits_per_sample"] = _int_helper("bitsPerSample")
        content["nr_audio_channels"] = _int_helper("nrAudioChannels")
        content["resolution"] = element.get("resolution")
        content["color_depth"] = _int_helper("colorDepth")
        content["protection"] = element.get("protection")
        content["uri"] = element.text
        return cls(**content)

    def __repr__(self):
        return "<{} '{}' at {}>".format(
            self.__class__.__name__, self.uri, hex(id(self))
        )

    def __str__(self):
        return self.__repr__()

    def to_element(self):
        """Return an ElementTree Element based on this resource.

        Returns:
            ~xml.etree.ElementTree.Element: an Element.
        """
        if not self.protocol_info:

            raise DIDLMetadataError(