aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-09-26 15:36:20 -0400
committerNick Mathewson <nickm@torproject.org>2019-09-27 21:04:22 -0400
commitd229399e77f17a8ad19a793fcc7252027c0d3758 (patch)
tree71dee57d4ec7dc262fa6133cb7019b4a28b37278
parent6f0e697e4155ca567ddfd46a7f4e7c013287c42a (diff)
downloadtor-d229399e77f17a8ad19a793fcc7252027c0d3758.tar.gz
tor-d229399e77f17a8ad19a793fcc7252027c0d3758.zip
annotate_ifdef_directives: Allow it to be imported as a module.
-rwxr-xr-xscripts/maint/annotate_ifdef_directives20
1 files 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)