@@ -22,7 +22,7 @@ def append(self, var):
22
22
class preprocessor :
23
23
def __init__ (self , inFile = sys .argv [0 ], outFile = '' , defines = {}, removeMeta = False ,
24
24
escapeChar = None , mode = None , escape = '#' , run = True , resume = False ,
25
- save = True , overload = True ):
25
+ save = True , overload = True , quiet = False ):
26
26
# public variables
27
27
self .defines = customDict ()
28
28
#support for <=0.7.7
@@ -42,6 +42,7 @@ def __init__(self, inFile=sys.argv[0], outFile='', defines={}, removeMeta=False,
42
42
self .resume = resume
43
43
self .save = save
44
44
self .overload = overload
45
+ self .quiet = quiet
45
46
self .readEncoding = sys .stdin .encoding
46
47
self .writeEncoding = sys .stdout .encoding
47
48
@@ -303,8 +304,9 @@ def lexer(self, line):
303
304
self .__ifblocks .pop (- 1 )
304
305
self .__ifconditions .pop (- 1 )
305
306
else :
306
- print ('Warning trying to remove more blocks than present' , \
307
- self .input , self .__linenum )
307
+ if not self .quiet :
308
+ print ('Warning trying to remove more blocks than present' ,
309
+ self .input , self .__linenum )
308
310
self .__ifblocks = []
309
311
self .__ifconditions = []
310
312
@@ -313,8 +315,8 @@ def lexer(self, line):
313
315
# escapechar + space ==> comment
314
316
# starts with #!/ ==> shebang
315
317
# else print warning
316
- if len (line .split ()[0 ]) > 1 and not line .startswith ('#!/' ):
317
- print ('Warning unknown directive or comment starting with ' , \
318
+ if len (line .split ()[0 ]) > 1 and not line .startswith ('#!/' ) and not self . quiet :
319
+ print ('Warning unknown directive or comment starting with ' ,
318
320
line .split ()[0 ], self .input , self .__linenum + 1 )
319
321
320
322
return False , True
@@ -374,7 +376,7 @@ def parse(self):
374
376
continue
375
377
finally :
376
378
#Warnings for unclosed #ifdef blocks
377
- if self .__ifblocks :
379
+ if self .__ifblocks and not self . quiet :
378
380
print ('Warning: Number of unclosed Ifdefblocks: ' , len (self .__ifblocks ))
379
381
print ('Can cause unwished behaviour in the preprocessed code, preprocessor is safe' )
380
382
try :
0 commit comments