<commit_before>import bencode

def main():
    parse_torrent()

def parse_torrent():
    '''DESC: Asks user for location of .torrent file. Parses and saves metadata results'''
    t_content = ''
    torrent_file = raw_input("Torrent File Location: ")

    try:
        with open(torrent_file, 'r') as content_file:
            t_content = content_file.read()
            meta_data = bencode.bdecode(t_content)
            print meta_data
            import pdb; pdb.set_trace()
    except:
        print 'WASP: Error opening file'



class Wasp(object):

    def __init__(self, meta_data):
        self.announce = meta_data['announce']
        self.piece_length = meta_data['info']['piece length']
        self.pieces = meta_data['info']['pieces']
        # TODO: Only works on single file torrents
        self.name = meta_data['info']['name']
        self.length = meta_data['info']['length']

    def apple(self):
        print "I AM CLASSY APPLES!"



if __name__ == "__main__":
    main()
<commit_msg>handle individual file. Need to fix this for multi file torrents though<commit_after>import bencode

def main():
    parse_torrent()

def parse_torrent():
    "DESC: Asks user for location of .torrent file. Parses and saves metadata results"
    t_content = ''
    torrent_file = raw_input("Torrent File Location: ")

    try:
        with open(torrent_file, 'r') as content_file:
            t_content = content_file.read()
            meta_data = bencode.bdecode(t_content)
            print meta_data
            hatchling = Wasp(meta_data)

    except:
        print 'WASP: Error opening file'



class Wasp(object):
    "DESC: A wasp is a single instance of a torrent. Includes all metadata and functionality in seeding/leeching"

    def __init__(self, meta_data):
        import pdb; pdb.set_trace()
        self.announce = meta_data['announce']
        self.piece_length = meta_data['info']['piece length']
        self.pieces = meta_data['info']['pieces']
        self.name = meta_data['info']['name']
        # TODO: Only works on single file torrents
        file = meta_data['info']['files'][0]
        self.length = file['length']

    def apple(self):
        print "I AM CLASSY APPLES!"



if __name__ == "__main__":
    main()

{'fraction_non_alphanumeric': 0.11204979991107158, 'fraction_numerical': 0.00044464206313917296, 'mean_word_length': 2.7562604340567614, 'pattern_counts': {'":': 2, '<': 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': '1257544', 'n_tokens_mistral': 698, 'n_tokens_neox': 673, 'n_words': 192}