<commit_before>import cups
from printer import Printer
from jobs import Jobs

class System:

    def __init__(self):
        self.connection = cups.Connection()

    def printer_name(self, printer):
        printers = self.connection.getPrinters()

        for index, this_printer_name in enumerate(printers.keys()):
            this_printer = printers[this_printer_name]

            if this_printer["device-uri"] == printer["device-uri"]:
                return this_printer_name

        raise RuntimeException("failed to determine printer name of printer %s", printer["device-uri"])

    def printer(self):
        if (self.connection.getDefault()):
            return Printer(self.connection, self.printer_name(self.connection.getDefault()))

        printers = self.connection.getPrinters()

        if printers.has_key("Canon_CP910_2"):
            return Printer(self.connection, self.printer_name(printers["Canon_CP910_2"]))

        return None

    def has_printer(self):
        return self.printer() is not None

    def jobs(self):
        return Jobs(self.connection.getJobs())<commit_msg>the default printer is a name, not a printer<commit_after>import cups
from printer import Printer
from jobs import Jobs

class System:

    def __init__(self):
        self.connection = cups.Connection()

    def printer_name(self, printer):
        printers = self.connection.getPrinters()

        for index, this_printer_name in enumerate(printers.keys()):
            this_printer = printers[this_printer_name]

            if this_printer["device-uri"] == printer["device-uri"]:
                return this_printer_name

        raise RuntimeException("failed to determine printer name of printer %s", printer["device-uri"])

    def printer(self):
        if (self.connection.getDefault()):
            return Printer(self.connection, self.connection.getDefault())

        printers = self.connection.getPrinters()

        if printers.has_key("Canon_CP910_2"):
            return Printer(self.connection, self.printer_name(printers["Canon_CP910_2"]))

        return None

    def has_printer(self):
        return self.printer() is not None

    def jobs(self):
        return Jobs(self.connection.getJobs())
{'fraction_non_alphanumeric': 0.1009009009009009, 'fraction_numerical': 0.007207207207207207, 'mean_word_length': 3.023550724637681, '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': '1500990', 'n_tokens_mistral': 645, 'n_tokens_neox': 608, 'n_words': 147}