webdav-client-python icon indicating copy to clipboard operation
webdav-client-python copied to clipboard

lxml is not needed

Open althonos opened this issue 8 years ago • 0 comments

Hi there, the current package seem to require lxml, yet this module only uses the etree interface, which has a builtin C and Python implementation (xml.etree.cElementTree and xml.etree.ElementTree). As such, you could make lxml an optional dependency, which would make the webdav module way easier to setup on machines without compilers as well as Python implementations other than CPython.

The fix is straightforward: in webdav/client.py, replace

import lxml.etree as etree

with

try:
    from lxml import etree
except ImportError:
    try:
        from xml.etree import cElementTree as etree
    except ImportError:
        from xml.etree import ElementTree as etree

this way, the lxml implementation is used if available; otherwise, the C implementation is used; if it's not available, the plain Python implementation is used. Then, you could remove lxml from the hard dependencies !

althonos avatar Aug 31 '17 21:08 althonos