<commit_before>
import ape.lib.basecommand
import os
import argparse
from urllib.request import Request, urlopen
from urllib.request import URLError
from bs4 import BeautifulSoup

class Command(ape.lib.basecommand.BaseCommand):

    prog_name = 'cd'
    prog_description = 'Change working directory.'

    def add_arguments(self):
        self.parser.add_argument('url',
            default = '.',
            help = "The URL to display.",
            nargs=1)

    def call(self):
        """
        A very basic web browser. Shows a plain-text version of 
        a URL.\nUsage: 'GOTO <url>'
        """

        url = ''.join(self.args.url)

        if url[0:7] != 'http://' and url[0:8] != 'https://':
            url = 'http://' + url

        req = Request(url)

        try:
            response = urlopen(req)
        except URLError as e:
            if hasattr(e, 'reason'):
                print("Failed to reach server.")
                print("Reason: ", e.reason)
            elif hasattr(e, 'code'):
                print("The server couldn't fulfill the request.")
                print("Error code: ", e.code)<commit_msg>get BS from PIP instead, add GOTO command<commit_after>
import ape.lib.basecommand
import os
import argparse
from urllib.request import Request, urlopen
from urllib.request import URLError
from bs4 import BeautifulSoup

class Command(ape.lib.basecommand.BaseCommand):

    prog_name = 'goto'
    prog_description = 'A basic text-based web page reader.'

    def add_arguments(self):
        self.parser.add_argument('url',
            default = '.',
            help = "The URL to display.",
            nargs=1)

    def call(self):
        """
        A very basic web browser. Shows a plain-text version of 
        a URL.\nUsage: 'GOTO <url>'
        """

        url = ''.join(self.args.url)

        if url[0:7] != 'http://' and url[0:8] != 'https://':
            url = 'http://' + url

        req = Request(url)

        try:
            response = urlopen(req)
        except URLError as e:
            if hasattr(e, 'reason'):
                print("Failed to reach server.")
                print("Reason: ", e.reason)
            elif hasattr(e, 'code'):
                print("The server couldn't fulfill the request.")
                print("Error code: ", e.code)
{'fraction_non_alphanumeric': 0.12251941328731665, 'fraction_numerical': 0.005176876617773943, 'mean_word_length': 1.9133165829145728, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6159331', 'n_tokens_mistral': 705, 'n_tokens_neox': 659, 'n_words': 199}