From 7a8c43ee6a1f9c50bec8cc5234eff8b1d5e61088 Mon Sep 17 00:00:00 2001 From: Johannes Gijsbers Date: Sat, 11 Sep 2004 16:34:35 +0000 Subject: [PATCH] Add 'if __name__ == "__main__":' to files already as a usable as a module. --- Demo/scripts/eqfix.py | 4 ++-- Demo/scripts/fact.py | 3 ++- Demo/scripts/ftpstats.py | 3 ++- Demo/scripts/lpwatch.py | 9 +++++---- Demo/scripts/makedir.py | 3 ++- Demo/scripts/markov.py | 3 ++- Demo/scripts/mboxconvert.py | 3 ++- Demo/scripts/mkrcs.py | 3 ++- Demo/scripts/newslist.py | 4 ++-- Demo/scripts/pi.py | 3 ++- Demo/scripts/primes.py | 3 ++- Demo/scripts/unbirthday.py | 3 ++- Demo/scripts/update.py | 3 ++- 13 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Demo/scripts/eqfix.py b/Demo/scripts/eqfix.py index deac4f8a614..165ca4906b2 100755 --- a/Demo/scripts/eqfix.py +++ b/Demo/scripts/eqfix.py @@ -194,5 +194,5 @@ def fixline(line): print line, return line - -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/fact.py b/Demo/scripts/fact.py index 5497f6650e9..03cab8bb857 100755 --- a/Demo/scripts/fact.py +++ b/Demo/scripts/fact.py @@ -45,4 +45,5 @@ def main(): except EOFError: pass -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/ftpstats.py b/Demo/scripts/ftpstats.py index 13d055313ad..b37a58d9bdc 100755 --- a/Demo/scripts/ftpstats.py +++ b/Demo/scripts/ftpstats.py @@ -141,4 +141,5 @@ def add(dict, key, item): else: dict[key] = [item] -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/lpwatch.py b/Demo/scripts/lpwatch.py index 0af3cbd056d..8887dee7d3b 100755 --- a/Demo/scripts/lpwatch.py +++ b/Demo/scripts/lpwatch.py @@ -103,7 +103,8 @@ def makestatus(name, thisuser): lines.append('lpq exit status %r' % (sts,)) return string.joinfields(lines, ': ') -try: - main() -except KeyboardInterrupt: - pass +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + pass diff --git a/Demo/scripts/makedir.py b/Demo/scripts/makedir.py index 209f6c4385a..f70facd0817 100755 --- a/Demo/scripts/makedir.py +++ b/Demo/scripts/makedir.py @@ -17,4 +17,5 @@ def makedirs(p): makedirs(head) os.mkdir(p, 0777) -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/markov.py b/Demo/scripts/markov.py index 3329351b955..bddec569364 100755 --- a/Demo/scripts/markov.py +++ b/Demo/scripts/markov.py @@ -113,4 +113,5 @@ def tuple(list): i = len(list)/2 return tuple(list[:i]) + tuple(list[i:]) -test() +if __name__ == "__main__": + test() diff --git a/Demo/scripts/mboxconvert.py b/Demo/scripts/mboxconvert.py index ba1f7343848..502d774f83d 100755 --- a/Demo/scripts/mboxconvert.py +++ b/Demo/scripts/mboxconvert.py @@ -120,4 +120,5 @@ def message(f, delimiter = ''): print return sts -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/mkrcs.py b/Demo/scripts/mkrcs.py index 45a68b92c41..cacdda0a546 100755 --- a/Demo/scripts/mkrcs.py +++ b/Demo/scripts/mkrcs.py @@ -57,4 +57,5 @@ def makedirs(p): makedirs(head) os.mkdir(p, 0777) -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/newslist.py b/Demo/scripts/newslist.py index b9f9c0ea11d..a6312149804 100755 --- a/Demo/scripts/newslist.py +++ b/Demo/scripts/newslist.py @@ -359,8 +359,8 @@ def main(): createpage(rootpage, tree, '') print 'Done' - -main() +if __name__ == "__main__": + main() # That's all folks ###################################################################### diff --git a/Demo/scripts/pi.py b/Demo/scripts/pi.py index d6337238a81..9b242451aaf 100755 --- a/Demo/scripts/pi.py +++ b/Demo/scripts/pi.py @@ -30,4 +30,5 @@ def output(d): # Flush so the output is seen immediately sys.stdout.flush() -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/primes.py b/Demo/scripts/primes.py index 00eb05f9b13..5935a3c84a8 100755 --- a/Demo/scripts/primes.py +++ b/Demo/scripts/primes.py @@ -23,4 +23,5 @@ def primes(min, max): if i >= min: print i i = i+2 -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/unbirthday.py b/Demo/scripts/unbirthday.py index e3b7be73f0c..2d0b8e5f403 100755 --- a/Demo/scripts/unbirthday.py +++ b/Demo/scripts/unbirthday.py @@ -103,4 +103,5 @@ def mkdate((year, month, day)): days = days + day return days -main() +if __name__ == "__main__": + main() diff --git a/Demo/scripts/update.py b/Demo/scripts/update.py index 67a07838da9..32ad6c86e12 100755 --- a/Demo/scripts/update.py +++ b/Demo/scripts/update.py @@ -88,4 +88,5 @@ def main(): curfile = FileObj(filename) curfile.process(lineno, line[n:]) -main() +if __name__ == "__main__": + main()