From 940ccdb473b8b639cfec4d5c6270fd0e02734d32 Mon Sep 17 00:00:00 2001 From: Kenny Workman Date: Wed, 4 Oct 2023 10:33:28 -0700 Subject: [PATCH] Compiled should carry print_compilation keyword --- snakemake/parser.py | 10 ++++++++-- snakemake/workflow.py | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/snakemake/parser.py b/snakemake/parser.py index 104d0923f..4f6707332 100644 --- a/snakemake/parser.py +++ b/snakemake/parser.py @@ -71,6 +71,7 @@ def __init__(self, token): class TokenAutomaton: subautomata: Dict[str, Any] = {} deprecated: Dict[str, str] = {} + print_compilation = False def __init__(self, snakefile: "Snakefile", base_indent=0, dedent=0, root=True): self.root = root @@ -239,7 +240,11 @@ def keyword(self): class Include(GlobalKeywordState): - pass + def block_content(self, token): + if self.print_compilation: + yield f"{token.string}, print_compilation=True", token + else: + yield token.string, token class Workdir(GlobalKeywordState): @@ -1202,8 +1207,9 @@ def format_tokens(tokens) -> Generator[str, None, None]: t_ = t -def parse(path, workflow, overwrite_shellcmd=None, rulecount=0): +def parse(path, workflow, overwrite_shellcmd=None, rulecount=0, print_compilation=False): Shell.overwrite_cmd = overwrite_shellcmd + TokenAutomaton.print_compilation = print_compilation with Snakefile(path, workflow, rulecount=rulecount) as snakefile: automaton = Python(snakefile) linemap = dict() diff --git a/snakemake/workflow.py b/snakemake/workflow.py index 9c5ffb49a..91e700a1a 100644 --- a/snakemake/workflow.py +++ b/snakemake/workflow.py @@ -1197,6 +1197,7 @@ def include( snakefile, self, rulecount=self._rulecount, + print_compilation=print_compilation, ) self._rulecount = rulecount