<commit_before>#!/usr/bin/env python
import subprocess
import sys
import shutil

# Check whether whois command is available
try:
	subprocess.check_output(["whois","google.com"])
except OSError:
	print('ERROR: whois command not found. \n\tIs it installed? Are you using Linux?')
	sys.exit()

suffixes = []
prefixes = []

readingPrefixes = False

# 1. Get prefixes and suffixes and put them into arrays
f = open('input.txt')
for l in f:
	line = l.strip()
	if line == '--prefixes':
		readingPrefixes = True
		continue
	elif line == '--suffixes':
		readingPrefixes = False
		continue
	elif not line:
		continue # Ignore empty lines

	if readingPrefixes:
		prefixes.append(line)
	else:
		suffixes.append(line)
f.close()

# 2. create list of domains from prefixes and suffixes
domains	=[]
for pre in prefixes:
	for suff in suffixes:
		domains.append( pre + suff + ".io")

# 3. Get list of domains that have aleady found to be free and removed them
checkeddomains= [line.strip() for line in open('free-domains.txt')] # Strip out newlines too
for remove in checkeddomains:
	try:
		domains.remove(remove)
	except ValueError:
		pass # Ignore exceptions


# 4. Check list of domains and write to file
for domain in domains:
	print(' Checking: ' + domain), # Comma means no newline is printed
	try:
		result = subprocess.check_output(["whois", domain])
		print('\tTAKEN')
	except subprocess.CalledProcessError:
		f = open('free-domains.txt', 'r+')
		# Exception means that the domain is free
		print('\tFREE')
		f.write(domain + '\n')
		f.close()
print("DONE!")<commit_msg>Changed script to use python-whois module<commit_after>#!/usr/bin/env python
from time import sleep
import sys
try:
	import whois
except ImportError:
	print "ERROR: This script requires the python-whois module to run."
	print "   You can install it via 'pip install python-whois'"
	sys.exit(0)

# CONFIG. Change top-level domain to check here
TLD = '.co.uk'

# 1. Get prefixes and suffixes from input.txt
suffixes = []
prefixes = []
readingPrefixes = False
f = open('input.txt')
for l in f:
	line = l.strip()
	if line == '--prefixes':
		readingPrefixes = True
		continue
	elif line == '--suffixes':
		readingPrefixes = False
		continue
	elif not line:
		continue # Ignore empty lines

	if readingPrefixes:
		prefixes.append(line)
	else:
		suffixes.append(line)
f.close()

# 2. create list of domains from prefixes and suffixes
domains	=[]
for pre in prefixes:
	for suff in suffixes:
		domains.append( pre + suff + TLD)

# 3. Get list of domains that have aleady found to be free and removed them
checkeddomains= [line.strip() for line in open('free-domains.txt')] # Strip out newlines too
for remove in checkeddomains:
	try:
		domains.remove(remove)
	except ValueError:
		pass # Ignore exceptions

# 4. Check list of domains and write to file
for domain in domains:
	sleep(0.5) # Too many requests lead to incorrect responses
	print(' Checking: ' + domain), # Comma means no newline is printed
	try:
		w = whois.whois(domain)
		print('\tTAKEN')
	except whois.parser.PywhoisError:
		# Exception means that the domain is free
		print('\tFREE')
		f = open('free-domains.txt', 'a')
		f.write(domain + '\n')
		f.close()
print("DONE!")
{'fraction_non_alphanumeric': 0.1115987460815047, 'fraction_numerical': 0.0034482758620689655, 'mean_word_length': 4.017295597484277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3640798', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1034, 'n_words': 379}