]> gitweb.michael.orlitzky.com - djbdns-logparse.git/commitdiff
bin/djbdns-logparse: only import sys.stdin within main().
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 15 Sep 2022 00:54:35 +0000 (20:54 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 15 Sep 2022 00:55:19 +0000 (20:55 -0400)
bin/djbdns-logparse

index 44514f15b4c610882cfa7ab03a4f647c091f6818..998f5475c6127306a7ff3a5b5e32e1837a768aa0 100755 (executable)
@@ -24,7 +24,7 @@ Convert tinydns and dnscache logs to human-readable form
 #   ** http://www.hungry.com/~fn/dnscache-log.pl.txt
 #
 
-import sys, re
+import re
 from struct import pack
 from time import strftime, gmtime
 from subprocess import Popen, PIPE
@@ -238,11 +238,12 @@ def main():
 
     # Parse zero or more positional arguments into a list of
     # "logfiles". If none are given, read from stdin instead.
+    from sys import stdin
     parser.add_argument("logfiles",
                         metavar="LOGFILE",
                         type=FileType("r"),
                         nargs="*",
-                        default=[sys.stdin],
+                        default=[stdin],
                         help="djbdns logfile to process (default: stdin)")
 
     args = parser.parse_args()