示例#1
0
 def from_sexp(cls, sexp):
     if isinstance(sexp, Symbol):
         return cls(checker=sexp.value(), maximum_level=None)
     else:
         level, checker = parse_cons_cell(sexp)
         if not isinstance(checker, Symbol):
             raise ValueError('Invalid checker: ' + repr(checker))
         if not isinstance(level, Symbol):
             raise ValueError('Invalid level: ' + repr(level))
         return cls(checker=checker.value(), maximum_level=level.value())
示例#2
0
 def from_sexp(cls, sexp):
     if isinstance(sexp, Symbol):
         return cls(checker=sexp.value(), maximum_level=None)
     else:
         level, checker = parse_cons_cell(sexp)
         if not isinstance(checker, Symbol):
             raise ValueError('Invalid checker: ' + repr(checker))
         if not isinstance(level, Symbol):
             raise ValueError('Invalid level: ' + repr(level))
         return cls(checker=checker.value(),
                    maximum_level=level.value())
示例#3
0
文件: flycheck.py 项目: cnh/flycheck
 def from_sexp(cls, sexp):
     if isinstance(sexp, Symbol):
         return cls(checker=sexp.value(), warnings_only=False,
                    no_errors=False)
     else:
         predicate, checker = parse_cons_cell(sexp)
         if not isinstance(checker, Symbol):
             raise ValueError('Invalid checker: ' + repr(checker))
         if not isinstance(predicate, Symbol):
             raise ValueError('Invalid predicate: ' + repr(predicate))
         predicate = predicate.value()
         if predicate not in {'no-errors', 'warnings-only'}:
             raise ValueError('Invalid predicate: ' + repr(predicate))
         return cls(checker=checker.value(),
                    warnings_only=predicate == 'warnings-only',
                    no_errors=predicate == 'no-errors')
示例#4
0
 def from_sexp(cls, sexp):
     if isinstance(sexp, Symbol):
         return cls(checker=sexp.value(),
                    warnings_only=False,
                    no_errors=False)
     else:
         predicate, checker = parse_cons_cell(sexp)
         if not isinstance(checker, Symbol):
             raise ValueError('Invalid checker: ' + repr(checker))
         if not isinstance(predicate, Symbol):
             raise ValueError('Invalid predicate: ' + repr(predicate))
         predicate = predicate.value()
         if predicate not in {'no-errors', 'warnings-only'}:
             raise ValueError('Invalid predicate: ' + repr(predicate))
         return cls(checker=checker.value(),
                    warnings_only=predicate == 'warnings-only',
                    no_errors=predicate == 'no-errors')
def test_parse_cons_cell(sexp, car, cdr):
    assert lisp_util.parse_cons_cell(sexp) == (car, cdr)
def test_parse_cons_cell_no_cons_cell(sexp):
    with pytest.raises(ValueError) as excinfo:
        lisp_util.parse_cons_cell(sexp)
    assert str(excinfo.value) == 'Not a cons cell: {0!r}'.format(sexp)