@@ -26,6 +26,12 @@ def __init__(self, args, env, callback, query=None, encoding='utf-8',
2626 self .silenceErrors = silenceErrors
2727 self .process = None
2828
29+ if 'show_query' not in self .options :
30+ self .options ['show_query' ] = False
31+ elif self .options ['show_query' ] not in ['top' , 'bottom' ]:
32+ self .options ['show_query' ] = 'top' if (isinstance (self .options ['show_query' ], bool )
33+ and self .options ['show_query' ]) else False
34+
2935 def run (self ):
3036 if not self .query :
3137 return
@@ -70,10 +76,9 @@ def run(self):
7076 if self .process :
7177 self .process .terminate ()
7278
73- if 'show_query' in self .options :
74- if 'enabled' in self .options ['show_query' ] and self .options ['show_query' ]['enabled' ]:
75- formattedQueryInfo = self ._formatShowQuery (self .query , queryTimerStart , queryTimerEnd )
76- self .callback (formattedQueryInfo + '\n ' )
79+ if self .options ['show_query' ]:
80+ formattedQueryInfo = self ._formatShowQuery (self .query , queryTimerStart , queryTimerEnd )
81+ self .callback (formattedQueryInfo + '\n ' )
7782
7883 return
7984
@@ -93,14 +98,13 @@ def run(self):
9398 resultString += errors .decode (self .encoding ,
9499 'replace' ).replace ('\r ' , '' )
95100
96- if 'show_query' in self .options :
97- if 'enabled' in self .options ['show_query' ] and self .options ['show_query' ]['enabled' ]:
98- formattedQueryInfo = self ._formatShowQuery (self .query , queryTimerStart , queryTimerEnd )
99- queryPlacement = self .options ['show_query' ].get ('placement' , 'top' )
100- if queryPlacement == 'top' :
101- resultString = "{0}\n {1}" .format (formattedQueryInfo , resultString )
102- elif queryPlacement == 'bottom' :
103- resultString = "{0}{1}\n " .format (resultString , formattedQueryInfo )
101+ if self .options ['show_query' ]:
102+ formattedQueryInfo = self ._formatShowQuery (self .query , queryTimerStart , queryTimerEnd )
103+ queryPlacement = self .options ['show_query' ]
104+ if queryPlacement == 'top' :
105+ resultString = "{0}\n {1}" .format (formattedQueryInfo , resultString )
106+ elif queryPlacement == 'bottom' :
107+ resultString = "{0}{1}\n " .format (resultString , formattedQueryInfo )
104108
105109 self .callback (resultString )
106110
0 commit comments