From d229399e77f17a8ad19a793fcc7252027c0d3758 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 26 Sep 2019 15:36:20 -0400 Subject: annotate_ifdef_directives: Allow it to be imported as a module. --- scripts/maint/annotate_ifdef_directives | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/maint/annotate_ifdef_directives b/scripts/maint/annotate_ifdef_directives index 514b5e58bb..6ff9b8ec4c 100755 --- a/scripts/maint/annotate_ifdef_directives +++ b/scripts/maint/annotate_ifdef_directives @@ -274,14 +274,16 @@ def translate(f_in, f_out): if len(stack) or cur_level != whole_file: raise Problem("Missing #endif") -import sys,os +if __name__ == '__main__': -if sys.argv[1] == "--self-test": - import doctest - doctest.testmod() - sys.exit(0) + import sys,os -for fn in sys.argv[1:]: - with open(fn+"_OUT", 'w') as output_file: - translate(open(fn, 'r'), output_file) - os.rename(fn+"_OUT", fn) + if sys.argv[1] == "--self-test": + import doctest + doctest.testmod() + sys.exit(0) + + for fn in sys.argv[1:]: + with open(fn+"_OUT", 'w') as output_file: + translate(open(fn, 'r'), output_file) + os.rename(fn+"_OUT", fn) -- cgit v1.2.3-54-g00ecf