Skip to content
Permalink
Browse files
fix: fixed parsing of subsequent use rule statements directly beneath…
… each other (#1548)
  • Loading branch information
johanneskoester committed Mar 31, 2022
1 parent c3a593e commit 77d5a08ab49d67b8cbd8ea4b6b6b7792edb38e3b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
@@ -162,11 +162,11 @@ def colon(self, token):
def is_block_end(self, token):
return (self.line and self.indent <= 0) or is_eof(token)

def block(self, token):
def block(self, token, force_block_end=False):
if self.lasttoken == "\n" and is_comment(token):
# ignore lines containing only comments
self.line -= 1
if self.is_block_end(token):
if force_block_end or self.is_block_end(token):
yield from self.decorate_end(token)
yield "\n", token
raise StopAutomaton(token)
@@ -1063,7 +1063,7 @@ def state_modifier(self, token):
)
elif is_newline(token) or is_comment(token) or is_eof(token):
# end of the statement, close block manually
yield from self.block(token)
yield from self.block(token, force_block_end=True)
else:
self.error(
"Expecting either 'as', 'with' or end of line in 'use rule' statement.",
@@ -1092,7 +1092,7 @@ def state_as(self, token):
yield from ()
elif is_newline(token) or is_comment(token) or is_eof(token):
# end of the statement, close block manually
yield from self.block(token)
yield from self.block(token, force_block_end=True)
else:
self.error(
"Expecting rulename modifying pattern (e.g. modulename_*) after 'as' keyword.",
@@ -0,0 +1,40 @@
shell.executable("bash")

configfile: "config/config.yaml"


module test1:
snakefile:
"module-test/Snakefile"
config:
config
replace_prefix:
{"results/": "results/testmodule1/"}




module test2:
snakefile:
"module-test/Snakefile"
config:
config
replace_prefix:
{"results/": "results/testmodule2/"}


use rule * from test1 as test1_*

use rule * from test2 as test2_*



rule all:
default_target: True
input:
rules.test1_a.output,
rules.test2_a.output


assert test1.some_func() == 15
assert test2.some_func() == 15
@@ -0,0 +1 @@
test: 1
Empty file.
@@ -0,0 +1,12 @@
configfile: "config.yaml" # does not exist, but this statement should be ignored on module import


def some_func():
return 15


rule a:
output:
"results/test.out"
shell:
"echo {config[test]} > {output}"
@@ -1582,5 +1582,10 @@ def test_pipe_depend_target_file():
run(dpath("test_pipe_depend"), targets=["test.txt"], shouldfail=True)


@skip_on_windows # platform independent issue
def test_github_issue1500():
run(dpath("test_github_issue1500"), dryrun=True)


def test_github_issue1542():
run(dpath("test_github_issue1542"), dryrun=True)

0 comments on commit 77d5a08

Please sign in to comment.