j2cli
j2cli copied to clipboard
[Feature Request] Load custom filters from Python modules
The current implementation allows loading custom filters from Python files by using the --filters argument.
My problem is I have compiled Python files, i.e Python bytecode (.pyc files) and passing them to --filters fails with the following error:
ValueError: source code string cannot contain null bytes
I understand the main reason for the above behavior is using Python's imp.load_source function, which can't read bytecode: https://github.com/kolypto/j2cli/blob/26a67e9419d96b7f92871e8b93dba00306c5df0b/j2cli/cli.py#L72-L74
A solution to the above would be to introduce a new argument, e.g --filters-modules MODULE, which will accept Python modules and load them using importlib.import_module.