<commit_before>'''
Missile generator
'''
from itertools import cycle
from exceptions import AmmoFileError


class HttpAmmo(object):

    def __init__(self, uri, headers, method='GET', http_ver='1.1'):
        self.method = method
        self.uri = uri
        self.proto = 'HTTP/%s' % http_ver
        self.headers = headers
        self.body = []
        self.loops = 0

    def to_s(self):
        if self.headers:
            headers = '\r\n'.join(self.headers) + '\r\n'
        return "%s %s %s\r\n%s\r\n" % (self.method, self.uri, self.proto, headers)


class SimpleGenerator(object):

    '''Generates ammo based on given sample'''

    def __init__(self, missile_sample):
        self.missiles = cycle([(missile_sample.to_s(), None)])

    def __iter__(self):
        for m in self.missiles:
            self.loops += 1
            yield m

    def loop_count(self):
        return self.loops<commit_msg>default headers -- empty<commit_after>'''
Missile generator
'''
from itertools import cycle
from exceptions import AmmoFileError


class HttpAmmo(object):

    def __init__(self, uri, headers, method='GET', http_ver='1.1'):
        self.method = method
        self.uri = uri
        self.proto = 'HTTP/%s' % http_ver
        self.headers = headers
        self.body = []
        self.loops = 0

    def to_s(self):
        if self.headers:
            headers = '\r\n'.join(self.headers) + '\r\n'
        else:
            headers = ''
        return "%s %s %s\r\n%s\r\n" % (self.method, self.uri, self.proto, headers)


class SimpleGenerator(object):

    '''Generates ammo based on given sample'''

    def __init__(self, missile_sample):
        self.missiles = cycle([(missile_sample.to_s(), None)])

    def __iter__(self):
        for m in self.missiles:
            self.loops += 1
            yield m

    def loop_count(self):
        return self.loops
{'fraction_non_alphanumeric': 0.13127001067235858, 'fraction_numerical': 0.004268943436499467, 'mean_word_length': 2.2665505226480835, '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': '2062718', 'n_tokens_mistral': 609, 'n_tokens_neox': 590, 'n_words': 151}