@@ -86,12 +86,15 @@ def parse():
8686 printOutput (p , document , opts )
8787
8888def printOutput (parser , document , opts ):
89- if opts .xml :
90- sys .stdout .write (document .toxml ("utf-8" ))
91- elif opts .hilite :
92- sys .stdout .write (document .hilite ("utf-8" ))
93- else :
94- sys .stdout .write (parser .tree .testSerializer (document ).encode ("utf-8" ))
89+ if opts .encoding :
90+ print "Encoding:" , parser .tokenizer .stream .charEncoding
91+ if not opts .no_tree :
92+ if opts .xml :
93+ sys .stdout .write (document .toxml ("utf-8" ))
94+ elif opts .hilite :
95+ sys .stdout .write (document .hilite ("utf-8" ))
96+ else :
97+ sys .stdout .write (parser .tree .testSerializer (document ).encode ("utf-8" ))
9598 if opts .error :
9699 errList = []
97100 for pos , message in parser .errors :
@@ -104,11 +107,14 @@ def getOptParser():
104107 parser .add_option ("-p" , "--profile" , action = "store_true" , default = False ,
105108 dest = "profile" , help = "Use the hotshot profiler to "
106109 "produce a detailed log of the run" )
107-
110+
108111 parser .add_option ("-t" , "--time" ,
109112 action = "store_true" , default = False , dest = "time" ,
110113 help = "Time the run using time.time (may not be accurate on all platforms, especially for short runs)" )
111-
114+
115+ parser .add_option ("" , "--no-tree" , action = "store_true" , default = False ,
116+ dest = "no_tree" , help = "Do not print output tree" )
117+
112118 parser .add_option ("-b" , "--treebuilder" , action = "store" , type = "string" ,
113119 dest = "treebuilder" )
114120
@@ -120,7 +126,9 @@ def getOptParser():
120126
121127 parser .add_option ("" , "--hilite" , action = "store_true" , default = False ,
122128 dest = "hilite" , help = "Output as formatted highlighted code." )
123-
129+
130+ parser .add_option ("-c" , "--encoding" , action = "store_true" , default = False ,
131+ dest = "encoding" , help = "Print character encoding used" )
124132 return parser
125133
126134if __name__ == "__main__" :
0 commit comments