示例#1
0
 def test_exeption(self):
     mltprsm = MultiprocessingManager()
     mltprsm.append(exeption_raising_func, {'arg': 0})
     exp = IOError(
         "The function 'exeption_raising_func' of "
         "'slidelint.tests.modules.linter.test_modules' module"
         " raised an Exception:\ninteger division or modulo by zero")
     with ShouldRaise(exp):
         [i for i in mltprsm]
示例#2
0
 def test_exeption(self):
     mltprsm = MultiprocessingManager()
     mltprsm.append(exeption_raising_func, {'arg': 0})
     exp = IOError(
         "The function 'exeption_raising_func' of "
         "'slidelint.tests.modules.linter.test_modules' module"
         " raised an Exception:\ninteger division or modulo by zero")
     with ShouldRaise(exp):
         [i for i in mltprsm]
示例#3
0
 def test_bad_args(self):
     mltprsm = MultiprocessingManager()
     mltprsm.append(exeption_raising_func, {'x': 0})
     exp = IOError(
         "The function 'exeption_raising_func' of "
         "'slidelint.tests.modules.linter.test_modules' module raised an "
         "Exception:\nexeption_raising_func() got an unexpected keyword"
         " argument 'x'",)
     with ShouldRaise(exp):
         [i for i in mltprsm]
示例#4
0
 def test_bad_args(self):
     mltprsm = MultiprocessingManager()
     mltprsm.append(exeption_raising_func, {'x': 0})
     exp = IOError(
         "The function 'exeption_raising_func' of "
         "'slidelint.tests.modules.linter.test_modules' module raised an "
         "Exception:\nexeption_raising_func() got an unexpected keyword"
         " argument 'x'", )
     with ShouldRaise(exp):
         [i for i in mltprsm]
示例#5
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'])
示例#6
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'])
示例#7
0
 def test_rezult(self):
     mltprsm = MultiprocessingManager()
     mltprsm.append(exeption_raising_func, {'arg': 1.0})
     mltprsm.append(exeption_raising_func, {'arg': 2.0})
     mltprsm.append(exeption_raising_func, {'arg': 4.0})
     compare([1.0, 0.5, 0.25], [i for i in mltprsm])
示例#8
0
 def test_rezult(self):
     mltprsm = MultiprocessingManager()
     mltprsm.append(exeption_raising_func, {'arg': 1.0})
     mltprsm.append(exeption_raising_func, {'arg': 2.0})
     mltprsm.append(exeption_raising_func, {'arg': 4.0})
     compare([1.0, 0.5, 0.25], [i for i in mltprsm])