From fccd9926e2f91d7222e7c7a28ad9da92ef081232 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Sat, 17 Apr 2010 17:02:58 +0200 Subject: [PATCH 1/1] Require LXML (maybe I'll fix this later). --- provider/cas_provider/etree.py | 38 ++++++++++------------------------ requirements.txt | 5 ++--- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/provider/cas_provider/etree.py b/provider/cas_provider/etree.py index 3f95751..9f992b8 100644 --- a/provider/cas_provider/etree.py +++ b/provider/cas_provider/etree.py @@ -1,32 +1,16 @@ -# Import etree from anywhere -try: - # lxml http://codespeak.net/lxml/ - from lxml import etree - - # Define register_namespace function and ElementRoot for proper serialization - NSMAP = {} - def register_namespace(prefix, uri): - NSMAP[prefix] = uri - - def ElementRoot(*args, **kwargs): - kwargs['nsmap'] = NSMAP - return etree.Element(*args, **kwargs) +# lxml http://codespeak.net/lxml/ +from lxml import etree -except ImportError: - try: - # normal cElementTree install - import cElementTree as etree - except ImportError: - # normal ElementTree install - import elementtree.ElementTree as etree +# Define register_namespace function and ElementRoot for proper serialization +NSMAP = {} - try: - register_namespace = etree.register_namespace - except AttributeError: - def register_namespace(prefix, uri): - etree._namespace_map[uri] = prefix - def ElementRoot(*args, **kwargs): - return etree.Element(*args, **kwargs) +def register_namespace(prefix, uri): + NSMAP[prefix] = uri + + +def ElementRoot(*args, **kwargs): + kwargs['nsmap'] = NSMAP + return etree.Element(*args, **kwargs) __all__ = ('etree', 'register_namespace', 'ElementRoot') diff --git a/requirements.txt b/requirements.txt index 9322f5e..bdf2ef8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ ---find-links=http://stigma.nowoczesnapolska.org.pl/pypi/ - -Django>=1.1.1,<1.2 \ No newline at end of file +Django>=1.1.1,<1.2 +lxml>=2.2 \ No newline at end of file -- 2.20.1