[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] annotate_ifdef_directives: Allow it to be imported as a module.
commit d229399e77f17a8ad19a793fcc7252027c0d3758
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Thu Sep 26 15:36:20 2019 -0400
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 514b5e58b..6ff9b8ec4 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)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits