Allow comments and blank lines in other-requirements.txt

Change-Id: I96581e2b1c5896649990144e751be6cbd984d349
This commit is contained in:
Marius Gedminas 2015-05-05 11:22:18 +03:00
parent 726d1e4315
commit decf073166
3 changed files with 14 additions and 3 deletions

View File

@ -75,6 +75,9 @@ Version constraints are a comma separated list of constraints where each
constraint is (== | < | <= | >= | > | !=) VERSION, and the constraints are ANDed
together (the same as pip requirements version constraints).
Comments are allowed: everything from the first ``#`` to the end of the line is
ignored.
Developing bindep
=================

View File

@ -40,8 +40,8 @@ debversion_compiled = makeGrammar(debversion_grammar, {})
grammar = debversion_grammar + """
rules = rule*
rule = <name>:name selector?:selector version?:version '\n' -> (
rules = (rule|comment|blank)*:bits -> [r for r in bits if r is not None]
rule = <name>:name selector?:selector version?:version ('\n'|comment) -> (
name, selector or [], version or [])
lowercase = ('a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'|'k'|'l'|'m'|'n'|'o'|'p'
|'q'|'r'|'s'|'t'|'u'|'v'|'w'|'x'|'y'|'z')
@ -52,6 +52,9 @@ selector = ws '[' profile:p1 (ws profile)*:p2 ']' -> [p1] + p2
oneversion = <('<=' | '<' | '!=' | '==' | '>=' | '>')>:rel <debversion>:v -> (
rel, v)
version = ws oneversion:v1 (',' oneversion)*:v2 -> [v1] + v2
comment = ws? '#' any* '\n' -> None
any = ~'\n' anything
blank = ws? '\n' -> None
"""

View File

@ -186,12 +186,17 @@ class TestDepends(TestCase):
depends.check_rules([("foo", [], [("!=", "123")])]))
def test_parser_patterns(self):
Depends(dedent("""\
depends = Depends(dedent("""\
foo
bar [something]
baz [platform:this platform:that-those]
quux [anotherthing !nothing] <=12
womp # and a comment
# a standalone comment and a blank line
# all's ok? good then
"""))
self.assertEqual(len(depends.active_rules(['default'])), 2)
def test_parser_invalid(self):
self.assertRaises(ometa.runtime.ParseError,