<commit_before>#Parser of Baka-Tsuki ePUB generator page
#python3
import requests, re
from bs4 import BeautifulSoup

class bte_gen(BeautifulSoup):
    def __init__(self, query):
        self.query = query
        self.result = dict()
        self.bteUrl = "http://ln.m-chan.org/v3/"
        self.bteGenHead = requests.get(self.bteUrl)
        self.bteGenHead.raise_for_status()
        super().__init__(self.bteGenHead.text)
        self.matches = self.find_all("a", text=re.compile(query, re.IGNORECASE))

    def perform_search(self):
        for match in self.matches:
            listLinks = []
            bteGenMatchContent = requests.get(self.bteUrl + match['href'])
            listBooksSoup = BeautifulSoup(bteGenMatchContent.text)
            listBooks = listBooksSoup.find_all("tr")
            listBooks.pop(0) #pop header
            for book in listBooks:
                #volume_number = book.td.find_next("td").string
                volume_number = book.td.next_sibling.next_sibling
                volume_name   = volume_number.next_sibling.next_sibling
                volume_text   = "Volume"
                if volume_number.string:
                    volume_text+= " {}".format(volume_number.string)
                if volume_name.string:
                    volume_text+= " {}".format(volume_name.string)
                listLinks.append("{0}: {1}{2}".format(volume_text, self.bteUrl, book.td.a['href']))
            if listLinks: self.result[match.string] = listLinks
        return any(listLinks)

    def print_findings(self):
        for key, value in self.result.items():
            print(key)
            for val in value:
                print(val)
<commit_msg>A little enchantment and style correction<commit_after>"""Parser of Baka-Tsuki ePUB generator page"""
#python3
import requests, re
from bs4 import BeautifulSoup

class bte_gen(BeautifulSoup):
    """ Base class of module """
    def __init__(self, query):
        self.query = query
        self.result = dict()
        self.bte_url = "http://ln.m-chan.org/v3/"
        self.bte_gen_head = requests.get(self.bte_url)
        self.bte_gen_head.raise_for_status()
        super().__init__(self.bte_gen_head.text)
        self.matches = self.find_all("a", text=re.compile(query, re.IGNORECASE))

    def update_query(self, new_query):
        """ Replace query and re-search with new one """
        self.query = new_query
        self.matches = self.find_all("a", text=re.compile(self.query, re.IGNORECASE))
        self.result = dict()
        return self.perform_search()

    def perform_search(self):
        """ Performs search and save results in self.result

            Format of result dictionary:
            { Novel's name : List of links }

            @return true if anything is found
            @return false otherwise
        """
        for match in self.matches:
            list_links = []
            matched_content = requests.get(self.bte_url + match['href'])
            books_soup = BeautifulSoup(matched_content.text)
            list_books = books_soup.find_all("tr")
            list_books.pop(0) #pop header
            for book in list_books:
                #volume_number = book.td.find_next("td").string
                volume_number = book.td.next_sibling.next_sibling
                volume_name = volume_number.next_sibling.next_sibling
                volume_text = "Volume"
                if volume_number.string:
                    volume_text += " {}".format(volume_number.string)
                if volume_name.string:
                    volume_text += " {}".format(volume_name.string)
                list_links.append("{0}: {1}{2}".format(volume_text, self.bte_url, book.td.a['href']))
            if list_links:
                self.result[match.string] = list_links
        return any(list_links)

    def print_findings(self):
        """ Printout of findings """
        for key, value in self.result.items():
            print(key)
            for val in value:
                print(val)

{'fraction_non_alphanumeric': 0.10816174646489705, 'fraction_numerical': 0.0034730836020838503, 'mean_word_length': 2.1135135135135137, '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': '2530142', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1180, 'n_words': 243}