# Path: openprovider/util.py
# def camel_to_snake(string):
#     """
#     Converts a camelCaseString to a snake_case_string.
# 
#     >>> camel_to_snake("fooBarBaz")
#     'foo_bar_baz'
#     """
#     return re.sub('([A-Z]+)', r'_\1', string).lower()
# 
# def snake_to_camel(value):
#     """
#     Converts a snake_case_string to a camelCaseString.
# 
#     >>> snake_to_camel("foo_bar_baz")
#     'fooBarBaz'
#     """
#     camel = "".join(word.title() for word in value.split("_"))
#     return value[:1].lower() + camel[1:]


import datetime
import lxml.etree
from openprovider.util import camel_to_snake, snake_to_camel
        lxml.etree.dump(self._obj, *args, **kwargs)

    def __repr__(self):
        args = ', '.join('%s=%r' % (attr, getattr(self, attr)) for attr in dir(self))
        return "<%s.%s(%s)>" % (type(self).__module__, type(self).__name__, args)

    def __str__(self):
        return str(lxml.etree.tostring(self._obj)) if self._obj is not None else 'Empty model'


def submodel(klass, key):
    """Shortcut for defining a submodel (has-a relation)."""
    def getter(self):
        return klass(getattr(self._obj, key))
    return property(getter)


def textattribute(attr):
    # TODO: Lots of duplication with __getattr__
    def getter(self):
        try:
            return self._attrs[attr]
        except KeyError:
            if self.get_elem() is not None:
                try:
                    return self.get_elem()[attr].text
                except (AttributeError, KeyError):
                    pass

        raise AttributeError("Model has no attribute '%s' (tried %r)"

# Path: openprovider/util.py
# def camel_to_snake(string):
#     """
#     Converts a camelCaseString to a snake_case_string.
# 
#     >>> camel_to_snake("fooBarBaz")
#     'foo_bar_baz'
#     """
#     return re.sub('([A-Z]+)', r'_\1', string).lower()
# 
# def snake_to_camel(value):
#     """
#     Converts a snake_case_string to a camelCaseString.
# 
#     >>> snake_to_camel("foo_bar_baz")
#     'fooBarBaz'
#     """
#     camel = "".join(word.title() for word in value.split("_"))
#     return value[:1].lower() + camel[1:]


# Path: openprovider/models.py
import datetime
import lxml.etree
from openprovider.util import camel_to_snake, snake_to_camel

        lxml.etree.dump(self._obj, *args, **kwargs)

    def __repr__(self):
        args = ', '.join('%s=%r' % (attr, getattr(self, attr)) for attr in dir(self))
        return "<%s.%s(%s)>" % (type(self).__module__, type(self).__name__, args)

    def __str__(self):
        return str(lxml.etree.tostring(self._obj)) if self._obj is not None else 'Empty model'


def submodel(klass, key):
    """Shortcut for defining a submodel (has-a relation)."""
    def getter(self):
        return klass(getattr(self._obj, key))
    return property(getter)


def textattribute(attr):
    # TODO: Lots of duplication with __getattr__
    def getter(self):
        try:
            return self._attrs[attr]
        except KeyError:
            if self.get_elem() is not None:
                try:
                    return self.get_elem()[attr].text
                except (AttributeError, KeyError):
                    pass

        raise AttributeError("Model has no attribute '%s' (tried %r)"

                             % (camel_to_snake(attr), dir(self)))