pep8
This commit is contained in:
parent
6ad5d4e6cb
commit
63808cbbb2
@ -5,11 +5,12 @@ import sys
|
|||||||
import os
|
import os
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
COMMENT_DIR='comments'
|
COMMENT_DIR = 'comments'
|
||||||
|
|
||||||
|
|
||||||
def wp2comments(xml):
|
def wp2comments(xml):
|
||||||
|
|
||||||
#xmlfile = open(xml, encoding='utf-8', mode='r').read()
|
# xmlfile = open(xml, encoding='utf-8', mode='r').read()
|
||||||
tree = etree.parse(xml)
|
tree = etree.parse(xml)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
items = root.findall('.//item')
|
items = root.findall('.//item')
|
||||||
@ -24,7 +25,8 @@ def wp2comments(xml):
|
|||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
title = item.find('title')
|
title = item.find('title')
|
||||||
if title is None: continue
|
if title is None:
|
||||||
|
continue
|
||||||
|
|
||||||
# Only fetch comments from published posts.
|
# Only fetch comments from published posts.
|
||||||
status = item.find('wp:status', namespaces=root.nsmap)
|
status = item.find('wp:status', namespaces=root.nsmap)
|
||||||
@ -69,9 +71,10 @@ def wp2comments(xml):
|
|||||||
f.write(u'Date: %s\n' % (date, ))
|
f.write(u'Date: %s\n' % (date, ))
|
||||||
f.write(u'Author_Email: %s\n' % (email, ))
|
f.write(u'Author_Email: %s\n' % (email, ))
|
||||||
f.write(u'Author_IP: %s\n' % (ip, ))
|
f.write(u'Author_IP: %s\n' % (ip, ))
|
||||||
|
f.write(u'Web: %s\n' % (url, ))
|
||||||
f.write(u'\n%s\n' % (content, ))
|
f.write(u'\n%s\n' % (content, ))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
wp2comments(sys.argv[1])
|
wp2comments(sys.argv[1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user