# Path: easy_karabiner/fucking_string.py
# def ensure_utf8(s):
#     # convert from any object to `unicode`
#     if not isinstance(s, basestring):
#         s = unicode(s)
# 
#     if isinstance(s, unicode):
#         s = s.encode('utf-8')
#     return unicode(s, encoding='utf-8')


import lxml.etree as etree
import xml.dom.minidom as minidom
import xml.sax.saxutils as saxutils
from . import exception
from .fucking_string import ensure_utf8
            })

    @classmethod
    def parse(cls, filepath):
        return etree.parse(filepath).getroot()

    @classmethod
    def parse_string(cls, xml_str):
        return etree.fromstring(xml_str, cls.xml_parser)

    @classmethod
    def get_class_name(cls):
        return cls.__name__

    @classmethod
    def is_cdata_text(cls, text):
        return text.startswith('<![CDATA[') and text.endswith(']]>')

    @classmethod
    def remove_cdata_mark(cls, text):
        return text[len('<![CDATA['):-len(']]>')]

    @classmethod
    def create_cdata_text(cls, text):
        # do NOT use `etree.CDATA`
        return '<![CDATA[%s]]>' % text

    @classmethod
    def assign_text_attribute(cls, etree_element, text):
        if text is not None:

# Path: easy_karabiner/fucking_string.py
# def ensure_utf8(s):
#     # convert from any object to `unicode`
#     if not isinstance(s, basestring):
#         s = unicode(s)
# 
#     if isinstance(s, unicode):
#         s = s.encode('utf-8')
#     return unicode(s, encoding='utf-8')


# Path: easy_karabiner/basexml.py
import lxml.etree as etree
import xml.dom.minidom as minidom
import xml.sax.saxutils as saxutils
from . import exception
from .fucking_string import ensure_utf8

            })

    @classmethod
    def parse(cls, filepath):
        return etree.parse(filepath).getroot()

    @classmethod
    def parse_string(cls, xml_str):
        return etree.fromstring(xml_str, cls.xml_parser)

    @classmethod
    def get_class_name(cls):
        return cls.__name__

    @classmethod
    def is_cdata_text(cls, text):
        return text.startswith('<![CDATA[') and text.endswith(']]>')

    @classmethod
    def remove_cdata_mark(cls, text):
        return text[len('<![CDATA['):-len(']]>')]

    @classmethod
    def create_cdata_text(cls, text):
        # do NOT use `etree.CDATA`
        return '<![CDATA[%s]]>' % text

    @classmethod
    def assign_text_attribute(cls, etree_element, text):
        if text is not None:

            etree_element.text = ensure_utf8(text)