X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=python%2Fxmltemplate.py;h=434868703e1d014c36525b0feaab72ae087dea7f;hb=cba8eef965a5c243cd8bf51059f3bdd98793a22c;hp=182b8e4a3712953d48a572d4183791ef4c3946ea;hpb=92404d2f2d49f6c5b1ccee0bfbc77c86051077f9;p=xml-template diff --git a/python/xmltemplate.py b/python/xmltemplate.py index 182b8e4..4348687 100644 --- a/python/xmltemplate.py +++ b/python/xmltemplate.py @@ -1,14 +1,21 @@ #! /usr/bin/python import re +import sys import xml.dom.minidom +if sys.version_info[0] > 2: + string = str +else: + string = basestring + + def process_file(filename, obj, clean = True): doc = xml.dom.minidom.parse(filename) process(doc, obj, clean) return doc def process(node, obj, clean = True): - if isinstance(obj, basestring): # overwrite + if isinstance(obj, string): # overwrite while not node.firstChild is None: node.removeChild(node.firstChild) doc = _get_document_element(node)