aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/util.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2013-02-26 11:49:18 -0500
committerWaylan Limberg <waylan@gmail.com>2013-02-26 11:49:18 -0500
commitb37ab16ba56ac6fe4e64f87521996bad323058f2 (patch)
tree2bf4432483408411e9210a3ad48fdabb4bc52c9f /markdown/util.py
parent7f75a936f340600ad599a24c548ebcea2171dc25 (diff)
downloadmarkdown-b37ab16ba56ac6fe4e64f87521996bad323058f2.tar.gz
markdown-b37ab16ba56ac6fe4e64f87521996bad323058f2.tar.bz2
markdown-b37ab16ba56ac6fe4e64f87521996bad323058f2.zip
Simlify importing ElementTree
As we no longer support older python versions, importing ElementTree is much simpler. The documented way for extensions to use etree still remains the same.
Diffstat (limited to 'markdown/util.py')
-rw-r--r--markdown/util.py15
1 files changed, 13 insertions, 2 deletions
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