aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/etree_loader.py31
-rw-r--r--markdown/util.py15
2 files changed, 13 insertions, 33 deletions
diff --git a/markdown/etree_loader.py b/markdown/etree_loader.py
deleted file mode 100644
index f605aa2..0000000
--- a/markdown/etree_loader.py
+++ /dev/null
@@ -1,31 +0,0 @@
-
-## Import
-def importETree():
- """Import the best implementation of ElementTree, return a module object."""
- etree_in_c = None
- try: # Is it Python 2.5+ with C implemenation of ElementTree installed?
- import xml.etree.cElementTree as etree_in_c
- from xml.etree.ElementTree import Comment
- except ImportError:
- try: # Is it Python 2.5+ with Python implementation of ElementTree?
- import xml.etree.ElementTree as etree
- except ImportError:
- try: # An earlier version of Python with cElementTree installed?
- import cElementTree as etree_in_c
- from elementtree.ElementTree import Comment
- except ImportError:
- try: # An earlier version of Python with Python ElementTree?
- import elementtree.ElementTree as etree
- except ImportError:
- raise ImportError("Failed to import ElementTree")
- if etree_in_c:
- if etree_in_c.VERSION < "1.0.5":
- raise RuntimeError("cElementTree version 1.0.5 or higher is required.")
- # Third party serializers (including ours) test with non-c Comment
- etree_in_c.test_comment = Comment
- return etree_in_c
- elif etree.VERSION < "1.1":
- raise RuntimeError("ElementTree version 1.1 or higher is required")
- else:
- return etree
-
diff --git a/markdown/util.py b/markdown/util.py
index 12dcbd5..34333f0 100644
--- a/markdown/util.py
+++ b/markdown/util.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import re
-import etree_loader
"""
@@ -42,7 +41,19 @@ RTL_BIDI_RANGES = ( (u'\u0590', u'\u07FF'),
# Extensions should use "markdown.util.etree" instead of "etree" (or do `from
# markdown.util import etree`). Do not import it by yourself.
-etree = etree_loader.importETree()
+try: # Is the C implemenation of ElementTree available?
+ import xml.etree.cElementTree as etree
+ from xml.etree.ElementTree import Comment
+ # Serializers (including ours) test with non-c Comment
+ etree.test_comment = Comment
+ if etree.VERSION < "1.0.5":
+ raise RuntimeError("cElementTree version 1.0.5 or higher is required.")
+except (ImportError, RuntimeError):
+ # Use the Python implementation of ElementTree?
+ import xml.etree.ElementTree as etree
+ if etree.VERSION < "1.1":
+ raise RuntimeError("ElementTree version 1.1 or higher is required")
+
"""
AUXILIARY GLOBAL FUNCTIONS