<commit_before>import logging
import sys
from mechanize import Browser
from lxml import html

_log = logging.getLogger(__name__)
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

class BrowserPlus(Browser):

    def __init__(self):
        Browser.__init__(self)
        self.set_handle_robots(False)
        self.addheaders = [('Accept',
            'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')]
        
    def contains(self, msg):
        """This returns true if the string provided in msg is contained in the
        browsers current page.
        """
        return msg in self._tree().xpath('string()')

    def _tree(self):
        return html.fromstring(self.response().read())

    def select_form_by(self, attr, idname):
        formcount = 0
        for frm in self.forms():
            if str(frm.attrs[attr])==idname:
                break
            formcount += 1
        return self.select_form(nr=formcount)
   
    def get(self, css):
        """Returns the first occurence of an element matching the css selector
        if it exists and None otherwise
        """
        e = self.get_all(css)
        if e:
            return e[0]
        return None

    def get_all(self, css):
        """Returns a list of all elements that match the css selector
        """
        return self._tree().cssselect(css)

    def go(self, text):
        try:
            return self.follow_link(text_regex=text)
        except:
            _log.error("Can't find link with text '%s'" % text)
            return None<commit_msg>Refactored parameter name to be more meaningful<commit_after>import logging
import sys
from mechanize import Browser
from lxml import html

_log = logging.getLogger(__name__)
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

class BrowserPlus(Browser):

    def __init__(self):
        Browser.__init__(self)
        self.set_handle_robots(False)
        self.addheaders = [('Accept',
            'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')]
        
    def contains(self, msg):
        """This returns true if the string provided in msg is contained in the
        browsers current page.
        """
        return msg in self._tree().xpath('string()')

    def _tree(self):
        return html.fromstring(self.response().read())

    def select_form_by(self, attr, search):
        formcount = 0
        for frm in self.forms():
            if str(frm.attrs[attr]) == search:
                break
            formcount += 1
        return self.select_form(nr=formcount)
   
    def get(self, css):
        """Returns the first occurence of an element matching the css selector
        if it exists and None otherwise
        """
        e = self.get_all(css)
        if e:
            return e[0]
        return None

    def get_all(self, css):
        """Returns a list of all elements that match the css selector
        """
        return self._tree().cssselect(css)

    def go(self, text):
        try:
            return self.follow_link(text_regex=text)
        except:
            _log.error("Can't find link with text '%s'" % text)
            return None
{'fraction_non_alphanumeric': 0.10347003154574133, 'fraction_numerical': 0.004416403785488959, 'mean_word_length': 2.219289340101523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2587183', 'n_tokens_mistral': 915, 'n_tokens_neox': 890, 'n_words': 264}