66import sys
77
88Verbose = False
9+ PrintGetRawWhoisResult = False
10+
911Failures = {}
1012IgnoreReturncode = False
1113
@@ -20,12 +22,15 @@ def xType(x):
2022 return s .split ("'" )[1 ]
2123
2224
23- def testItem (d ):
25+ def testItem (d : str , printgetRawWhoisResult : bool = False ):
26+ global PrintGetRawWhoisResult
27+
2428 w = whois .query (
2529 d ,
2630 ignore_returncode = IgnoreReturncode ,
2731 verbose = Verbose ,
2832 internationalized = True ,
33+ include_raw_whois_text = PrintGetRawWhoisResult ,
2934 )
3035
3136 if w is None :
@@ -174,6 +179,8 @@ def usage():
174179 # files are processed as in the -f option so comments and empty lines are skipped
175180 # the option can be repeated to specify more then one directory
176181
182+ [ -p | --print also print text containing the raw output of whois ]
183+
177184 # options are exclusive and without any options the test2 program does nothing
178185
179186 # test one specific file with verbose and IgnoreReturncode
@@ -214,12 +221,14 @@ def showFailures():
214221def main (argv ):
215222 global Verbose
216223 global IgnoreReturncode
224+ global PrintGetRawWhoisResult
217225
218226 try :
219227 opts , args = getopt .getopt (
220228 argv ,
221- "vIhaf :d:D:r:H:" ,
229+ "pvIhaf :d:D:r:H:" ,
222230 [
231+ "print" ,
223232 "verbose" ,
224233 "IgnoreReturncode" ,
225234 "all" ,
@@ -268,6 +277,9 @@ def main(argv):
268277 if opt in ("-v" , "--verbose" ):
269278 Verbose = True
270279
280+ if opt in ("-p" , "--print" ):
281+ PrintGetRawWhoisResult = True
282+
271283 if opt in ("-D" , "--Directory" ):
272284 directory = arg
273285 isDir = os .path .isdir (directory )
@@ -325,7 +337,6 @@ def main(argv):
325337 return
326338
327339 if len (domains ):
328- print ("## ===== TEST DOMAINS" )
329340 testDomains (domains )
330341 showFailures ()
331342 return
0 commit comments