joestump / kissxml

A simplistic take on SimpleXML for Python
39 stars 5 forks source link

kissxml breaks when it does not find lxml #5

Closed jaysonsantos closed 11 years ago

jaysonsantos commented 11 years ago

Correct file bellow

from . import XMLTree

try:
    import cElementTree as ET
except ImportError:
    try:
        import lxml.etree as ET
    except ImportError:
        try:
            import elementtree.ElementTree as ET
        except ImportError:
            import xml
            import xml.etree.ElementTree as ET  # Python 2.5

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

def parse_file(file):
    tree = ET.parse(file)
    return XMLTree(tree.getroot())
parse = parse_file

def parse_string(s):
    return parse(StringIO(s))
parsestring = parse_string
joestump commented 11 years ago

Hey Jason, thanks for filing this issue. Any chance I could get this in the form of a pull request? Thanks!

jaysonsantos commented 11 years ago

I didn't do it because my fork is with a lot of stuff, i will merge with yours and do pull request, I think you will like the changes.