<commit_before>#!/usr/bin/env python
# vim: set fileencoding=utf-8

import urllib
from urlparse import urlparse
import requests
import logging

LOG = logging.getLogger(__name__)

def dictmerge(dst, src):
	for key, value in src.items():
		if not key in dst:
			dst[key] = value
			continue
		if value.__class__ is list:
			dst[key].extend(src[key])
		else:
			dst[key] = dictmerge(dst[key], src[key])
	return dst

class Hammer(object):
	def __init__(self, host):
		self.hostname = host['name']
		self.hostport = host['port']
		self.cookies = []
		self.lastpath = None
		self.responses = {}
		self.response_code = -1
		self.rpm = 0
		self.session = requests.Session()

	def log_status(self, status, path, new_location):
		if LOG.getEffectiveLevel() > logging.INFO:
			return

		def good():
			LOG.info(u"\x1B[034;1m(✓) {0}\x1B[0m response from {1}".format(status, path))

		def redir():
			LOG.info(u"\x1B[037;1m(→) {0}\x1B[0m redirect from {1} to {2}".format(status, path, new_location))

		def bad():
			LOG.info(u"\x1B[031;1m(✘) {0}\x1B[0m response from {1}".format(status, path))

		codes = {}<commit_msg>Python3 compatibility<commit_after>#!/usr/bin/env python
# vim: set fileencoding=utf-8

try:
	from urllib.parse import urlparse
except ImportError:
	from urlparse import urlparse

import requests
import logging

LOG = logging.getLogger(__name__)

def dictmerge(dst, src):
	for key, value in src.items():
		if not key in dst:
			dst[key] = value
			continue
		if value.__class__ is list:
			dst[key].extend(src[key])
		else:
			dst[key] = dictmerge(dst[key], src[key])
	return dst

class Hammer(object):
	def __init__(self, host):
		self.hostname = host['name']
		self.hostport = host['port']
		self.cookies = []
		self.lastpath = None
		self.responses = {}
		self.response_code = -1
		self.rpm = 0
		self.session = requests.Session()

	def log_status(self, status, path, new_location):
		if LOG.getEffectiveLevel() > logging.INFO:
			return

		def good():
			LOG.info("\x1B[034;1m(✓) {0}\x1B[0m response from {1}".format(status, path))

		def redir():
			LOG.info("\x1B[037;1m(→) {0}\x1B[0m redirect from {1} to {2}".format(status, path, new_location))

		def bad():
			LOG.info("\x1B[031;1m(✘) {0}\x1B[0m response from {1}".format(status, path))

		codes = {}
{'fraction_non_alphanumeric': 0.1583590648434054, 'fraction_numerical': 0.027790030877812087, 'mean_word_length': 4.096629213483146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7601708', 'n_tokens_mistral': 950, 'n_tokens_neox': 858, 'n_words': 206}