Add a debug-splice option
This commit is contained in:
parent
4e5cc4f502
commit
ea7c9f2319
17
planet.py
17
planet.py
@ -22,6 +22,7 @@ if __name__ == "__main__":
|
||||
verbose = 0
|
||||
only_if_new = 0
|
||||
expunge = 0
|
||||
debug_splice = 0
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
if arg == "-h" or arg == "--help":
|
||||
@ -43,6 +44,8 @@ if __name__ == "__main__":
|
||||
only_if_new = 1
|
||||
elif arg == "-x" or arg == "--expunge":
|
||||
expunge = 1
|
||||
elif arg == "-d" or arg == "--debug-splice":
|
||||
debug_splice = 1
|
||||
elif arg.startswith("-"):
|
||||
print >>sys.stderr, "Unknown option:", arg
|
||||
sys.exit(1)
|
||||
@ -65,6 +68,20 @@ if __name__ == "__main__":
|
||||
|
||||
from planet import splice
|
||||
doc = splice.splice()
|
||||
|
||||
if debug_splice:
|
||||
from planet import logger
|
||||
logger.info('writing debug.atom')
|
||||
debug=open('debug.atom','w')
|
||||
try:
|
||||
from lxml import etree
|
||||
from StringIO import StringIO
|
||||
tree = etree.tostring(etree.parse(StringIO(doc.toxml())))
|
||||
debug.write(etree.tostring(tree, pretty_print=True))
|
||||
except:
|
||||
debug.write(doc.toprettyxml(indent=' ', encoding='utf-8'))
|
||||
debug.close
|
||||
|
||||
splice.apply(doc.toxml('utf-8'))
|
||||
|
||||
if expunge:
|
||||
|
Loading…
x
Reference in New Issue
Block a user