aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2020-08-05 06:02:52 +0000
committerSam James <sam@gentoo.org>2020-08-05 06:03:49 +0000
commit732fb3bbfd7d007fdca78dd4587f1a7bd34bfa6c (patch)
tree8443ac779138c9556c79b0e126908c6af4344742
parentfix pam_ssh formatting (diff)
downloadpambase-732fb3bbfd7d007fdca78dd4587f1a7bd34bfa6c.tar.gz
pambase-732fb3bbfd7d007fdca78dd4587f1a7bd34bfa6c.tar.bz2
pambase-732fb3bbfd7d007fdca78dd4587f1a7bd34bfa6c.zip
pambase.py: strip all blank lines
It's simpler to do this in pambase.py than with Jinja 2, at least for now. Signed-off-by: Sam James <sam@gentoo.org>
-rwxr-xr-xpambase.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pambase.py b/pambase.py
index 1ebafbe..9765778 100755
--- a/pambase.py
+++ b/pambase.py
@@ -67,7 +67,7 @@ def process_args(args):
def parse_templates(processed_args):
load = FileSystemLoader('')
- env = Environment(loader=load)
+ env = Environment(loader=load, trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True)
templates = [
"login",
@@ -87,6 +87,11 @@ def parse_templates(processed_args):
with open('stack/{0}'.format(template_name), "w+") as output:
rendered_template = template.render(processed_args)
+ # Strip all intermediate lines to not worry about appeasing Jinja
+ lines = rendered_template.split("\n")
+ lines = [line for line in lines if line]
+ rendered_template = "\n".join(lines)
+
if rendered_template:
output.write(rendered_template + "\n")