Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert value to string prior calling render_template() #104

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

kkaarreell
Copy link
Collaborator

@kkaarreell kkaarreell commented Oct 9, 2024

Fixes an issue when value from yaml is parsed as number, not string.

Traceback (most recent call last):
  File "/usr/bin/newa", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1690, in invoke
    rv.append(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/newa/cli.py", line 765, in cmd_schedule
    mapping[key] = render_template(value, **jinja_vars)
  File "/usr/lib/python3.9/site-packages/newa/__init__.py", line 115, in render_template
    return environment.from_string(template).render(**variables).strip()
  File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 941, in from_string
    return cls.from_code(self, self.compile(source), globals, None)
  File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 629, in compile
    source = self._generate(source, name, filename, defer_init=defer_init)
  File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 586, in _generate
    return generate(
  File "/usr/lib/python3.9/site-packages/jinja2/compiler.py", line 83, in generate
    raise TypeError("Can't compile non template nodes")
TypeError: Can't compile non template nodes

@kkaarreell kkaarreell self-assigned this Oct 9, 2024
@kkaarreell kkaarreell merged commit b86ae7a into main Oct 9, 2024
15 checks passed
@kkaarreell kkaarreell deleted the ks_str_fix branch October 9, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant