예제 #1
0
 def test_defaults(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults)
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "W:2: message 1 (short-name-1)\n"
         "C:4: message 4 (short-name-4)\n")
예제 #2
0
 def test_message_show_ids(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, show_id=True)
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "W1010:2: message 1 (short-name-1)\n"
         "C5010:4: message 4 (short-name-4)\n")
예제 #3
0
 def test_colorized_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='colorized')
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "W:2: message 1 (short-name-1)\x1b[39m\n"
         "\x1b[31mC:4: message 4 (short-name-4)\x1b[39m\n")
예제 #4
0
 def test_msvs_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='msvs')
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "presentation.pdf(2): [W1010(short-name-1)] message 1\n"
         "presentation.pdf(4): [C5010(short-name-4)] message 4\n")
예제 #5
0
 def test_msvs_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='msvs')
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "presentation.pdf(2): [W1010(short-name-1)] message 1\n"
         "presentation.pdf(4): [C5010(short-name-4)] message 4\n")
예제 #6
0
 def test_parseable_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='parseable')
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "presentation.pdf:2: [W1010(short-name-1), ] message 1\n"
         "presentation.pdf:4: [C5010(short-name-4), ] message 4\n")
예제 #7
0
 def test_parseable_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='parseable')
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "presentation.pdf:2: [W1010(short-name-1), ] message 1\n"
         "presentation.pdf:4: [C5010(short-name-4), ] message 4\n")
예제 #8
0
 def test_json_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='json')
     output.compare(
         '[{"msg": "message 1", "msg_name": "short-name-1", "help": '
         '"help 1", "id": "W1010", "page": "2"}, {"msg": "message 4"'
         ', "msg_name": "short-name-4", "help": "help 2", "id": "C50'
         '10", "page": "4"}]')
예제 #9
0
 def test_json_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='json')
     output.compare(
         '[{"msg": "message 1", "msg_name": "short-name-1", "help": '
         '"help 1", "id": "W1010", "page": "2"}, {"msg": "message 4"'
         ', "msg_name": "short-name-4", "help": "help 2", "id": "C50'
         '10", "page": "4"}]')
예제 #10
0
 def test_file_output(self):
     with TempDirectory() as d:
         os.chdir(d.path)
         output_handler(self.path, self.rezults, report_file=True)
         compare(
             d.read('presentation.lintrez'),
             "********************** Slide Deck presentation.pdf\n"
             "W:2: message 1 (short-name-1)\n"
             "C:4: message 4 (short-name-4)\n\n")
예제 #11
0
 def test_file_output(self):
     with TempDirectory() as d:
         os.chdir(d.path)
         output_handler(self.path,
                        self.rezults,
                        report_file='presentation.lintrez')
         compare(
             d.read('presentation.lintrez'),
             "********************** Slide Deck presentation.pdf\n"
             "W:2: message 1 (short-name-1)\n"
             "C:4: message 4 (short-name-4)\n\n")
예제 #12
0
 def test_html_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='html')
     output.compare("<!DOCTYPE html>\n"
                    "<html>\n"
                    "<body>\n"
                    "<h1>Slide Deck presentation.pdf</h1>\n"
                    "<p>W1010:2: message 1 (short-name-1)</p>\n"
                    "<p>C5010:4: message 4 (short-name-4)</p>\n"
                    "</body>\n"
                    "</html>")
예제 #13
0
 def test_html_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='html')
     output.compare(
         "<!DOCTYPE html>\n"
         "<html>\n"
         "<body>\n"
         "<h1>Slide Deck presentation.pdf</h1>\n"
         "<p>W1010:2: message 1 (short-name-1)</p>\n"
         "<p>C5010:4: message 4 (short-name-4)</p>\n"
         "</body>\n"
         "</html>")
예제 #14
0
def lint(target_file,
         config_file,
         output,
         enable_disable_ids,
         msg_info,
         group="slidelint.pluggins"):
    """ main function that bring all thing together: loads slidelint pluggins,
    parses config file, handles command-line options, runs checkers and
    formats output.

    It takes:

        * target_file - path to pdf file or None
        * config_file - path to config file or None
        * output - it's a dict object for controlling results output:
            format - format of the output report, it's None
                     or one of [text', 'parseable', 'colorized',
                     'msvs', 'html'],
            files_output - file path, empty string or None, if empty
                           string than report will be
                           written to file otherwise printed to stdout,
            ids - if True then messages ids will be added to report
        * enable_disable_ids - command-line options for enabling/disabling
                               messages/checkers/categories, takes
        * msg_info -  ['list of messages ids,], None, or 'All' """
    pluggins = PlugginsHandler(group=group)
    config = LintConfig(config_file)
    config.compose(pluggins.checkers, *enable_disable_ids)
    if msg_info:
        # displaying help messages
        rezult = []
        for checker in pluggins.load_checkers():
            kwargs = {'msg_info': msg_info}
            kwargs.update(config.get_checker_args(checker.name))
            rezult += list(checker.check(**kwargs))
        msg_ids = []
        output['ids'] = True
    else:
        # run checkers
        # mute messaging from appearing in report
        msg_ids = config.disable_messages
        checkers = pluggins.load_checkers(
            categories=config.categories,
            checkers=config.checkers_ids,
            disabled_categories=config.disable_categories,
            disabled_checkers=config.disable_checkers)
        # lets run all checkers separately in different processes
        rezult = MultiprocessingManager()
        for checker in checkers:
            kwargs = {'target_file': target_file}
            kwargs.update(config.get_checker_args(checker.name))
            rezult.append(checker.check, kwargs)
    return output_handler(target_file, rezult, msg_ids, output['format'],
                          output['files_output'], output['ids'])
예제 #15
0
파일: cli.py 프로젝트: alunix/slidelint
def lint(target_file, config_file, output, enable_disable_ids,
         msg_info, group="slidelint.pluggins"):
    """ main function that bring all thing together: loads slidelint pluggins,
    parses config file, handles command-line options, runs checkers and
    formats output.

    It takes:

        * target_file - path to pdf file or None
        * config_file - path to config file or None
        * output - it's a dict object for controlling results output:
            format - format of the output report, it's None
                     or one of [text', 'parseable', 'colorized',
                     'msvs', 'html'],
            files_output - file path, empty string or None, if empty
                           string than report will be
                           written to file otherwise printed to stdout,
            ids - if True then messages ids will be added to report
        * enable_disable_ids - command-line options for enabling/disabling
                               messages/checkers/categories, takes
        * msg_info -  ['list of messages ids,], None, or 'All' """
    pluggins = PlugginsHandler(group=group)
    config = LintConfig(config_file)
    config.compose(pluggins.checkers, *enable_disable_ids)
    if msg_info:
        # displaying help messages
        rezult = []
        for checker in pluggins.load_checkers():
            kwargs = {'msg_info': msg_info}
            kwargs.update(config.get_checker_args(checker.name))
            rezult += list(checker.check(**kwargs))
        msg_ids = []
        output['ids'] = True
    else:
        # run checkers
        # mute messaging from appearing in report
        msg_ids = config.disable_messages
        checkers = pluggins.load_checkers(
            categories=config.categories,
            checkers=config.checkers_ids,
            disabled_categories=config.disable_categories,
            disabled_checkers=config.disable_checkers
        )
        # lets run all checkers separately in different processes
        rezult = MultiprocessingManager()
        for checker in checkers:
            kwargs = {'target_file': target_file}
            kwargs.update(config.get_checker_args(checker.name))
            rezult.append(checker.check, kwargs)
    return output_handler(target_file, rezult, msg_ids, output['format'],
                          output['files_output'], output['ids'])
예제 #16
0
 def test_defaults(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults)
     output.compare("********************** Slide Deck presentation.pdf\n"
                    "W:2: message 1 (short-name-1)\n"
                    "C:4: message 4 (short-name-4)\n")
예제 #17
0
 def test_message_mute_ids(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, mute_ids=['W1010'])
     output.compare("********************** Slide Deck presentation.pdf\n"
                    "C:4: message 4 (short-name-4)\n")
예제 #18
0
 def test_colorized_format(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, output_format='colorized')
     output.compare("********************** Slide Deck presentation.pdf\n"
                    "W:2: message 1 (short-name-1)\x1b[39m\n"
                    "\x1b[31mC:4: message 4 (short-name-4)\x1b[39m\n")
예제 #19
0
 def test_message_show_ids(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, show_id=True)
     output.compare("********************** Slide Deck presentation.pdf\n"
                    "W1010:2: message 1 (short-name-1)\n"
                    "C5010:4: message 4 (short-name-4)\n")
예제 #20
0
 def test_message_mute_ids(self):
     with OutputCapture() as output:
         output_handler(self.path, self.rezults, mute_ids=['W1010'])
     output.compare(
         "********************** Slide Deck presentation.pdf\n"
         "C:4: message 4 (short-name-4)\n")