Faster xml cleaning

master
pictuga 2013-03-01 14:26:51 +01:00
parent e305f387ab
commit 6f6c5fbaad
1 changed files with 3 additions and 5 deletions

8
morss
View File

@ -3,6 +3,7 @@ import sys
import os import os
from os.path import expanduser from os.path import expanduser
from lxml import etree from lxml import etree
import string
import urllib2 import urllib2
import urllib import urllib
from cookielib import CookieJar from cookielib import CookieJar
@ -12,11 +13,8 @@ def log(txt):
print txt print txt
def xmlclean(xml): def xmlclean(xml):
xml = list(xml) table = string.maketrans('', '')
for pos in range(0,len(xml)): return xml.translate(table, table[:32])
if ord(xml[pos]) < 32:
xml[pos] = None
return ''.join([c for c in xml if c])
node = sys.argv[1] if len(sys.argv) > 1 else "//h1/.." node = sys.argv[1] if len(sys.argv) > 1 else "//h1/.."