Permalink
Browse files

Add a debug-splice option

  • Loading branch information...
1 parent 4e5cc4f commit ea7c9f2319ed4270169fd0ffc9f4662f41d449ea @rubys committed May 20, 2010
Showing with 17 additions and 0 deletions.
  1. +17 −0 planet.py
View
17 planet.py
@@ -22,6 +22,7 @@
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 @@
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 @@
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:

0 comments on commit ea7c9f2

Please sign in to comment.