# -*- coding: utf-8 -*-
import re

_CAMEL_CASE_RE = re.compile(r'[A-Z]')
_LOWER_UNDERSCORE_CASE_RE = re.compile(r'_([a-z])')
_LOWER_DASH_CASE_RE = re.compile(r'-([a-z])')


def camel_to_lower_separated(s, sep):
    """
    Convert camel case representation into lower separated case ie:

      backgroundColor -> background_color

    Note any separator at the start or end is stripped.

    """
    def repl(match_obj):
        return sep + match_obj.group(0).lower()
    return _CAMEL_CASE_RE.sub(repl, s).strip(sep)


def camel_to_lower_underscore(s):
    """
    Convert camel case to lower underscore case.

        backgroundColor -> background_color
    """
    return camel_to_lower_separated(s, '_')


def camel_to_lower_dash(s):
    """
    Convert camel case to lower dash case.

      backgroundColor -> background-color
    """
    return camel_to_lower_separated(s, '-')


def lower_underscore_to_camel(value):
    """
    Convert lower underscore case to camel case

      background_color -> backgroundColor
    """
    def repl(match_obj):
        return match_obj.group(1).upper()
    return _LOWER_UNDERSCORE_CASE_RE.sub(repl, value.lower())


def lower_dash_to_camel(value):
    """
    Convert lower dash case to camel case

      background-color -> backgroundColor
    """
    def repl(match_obj):
        return match_obj.group(1).upper()
    return _LOWER_DASH_CASE_RE.sub(repl, value.lower())


class cached_property(object):
    """
    Acts like a standard class `property` except return values cached.
    """
    def __init__(self, func):
        self.func = func
        self.__doc__ = func.__doc__
        self.__name__ = func.__name__
        self.__module__ = func.__module__

    def __get__(self, instance, owner):
        try:
            value = instance._cache[self.__name__]
        except (KeyError, AttributeError):
            value = self.func(instance)
            try:
                cache = instance._cache
            except AttributeError:
                cache = instance._cache = {}
            cache[self.__name__] = value
        return value

@@ -397,111 +397,68 @@
     
-def repl(match_obj):%0A        return sep + match_obj.group(0).lower()%0A    return _CAMEL_CASE_RE.sub(repl
+return _CAMEL_CASE_RE.sub(lambda m: sep + m.group(0).lower()
 , s)
@@ -990,117 +990,91 @@
     
-def repl(match_obj):%0A        return match_obj.group(1).upper()%0A    return _LOWER_UNDERSCORE_CASE_RE.sub(repl,
+return _LOWER_UNDERSCORE_CASE_RE.sub(%0A        lambda m: m.group(1).upper(),%0A       
  val
@@ -1079,24 +1079,29 @@
 alue.lower()
+%0A    
 )%0A%0A%0Adef lowe
@@ -1233,53 +1233,59 @@
     
-def repl(match_obj):%0A        return match_obj
+return _LOWER_DASH_CASE_RE.sub(%0A        lambda m: m
 .gro
@@ -1301,49 +1301,17 @@
 er()
+,
 %0A    
-return _LOWER_DASH_CASE_RE.sub(repl,
+   
  val
@@ -1320,16 +1320,21 @@
 .lower()
+%0A    
 )%0A%0A%0Aclas

Simplify methods and use lamba expressions