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
Add a management command option to exclude files ... #1024
base: develop
Are you sure you want to change the base?
Conversation
from offline compression. It uses the fnmatch module to match the files and will output the list of excluded templates if verbose >=2. Example call: python manage.py compress -x "forms/*.html" -x "test*/*.html"
Hi, Please include tests for the changes introduced in this PR. |
Hello @diox, I checked the tests but the |
|
Any way we can help moving this forward? |
Hi, My comment from #1024 (comment) still applies. In order for it to be considered, pull request needs to come with tests and docs for the changes added. So if you want for this feature to be added, try forking the original poster repos (or work directly with them) and add tests & docs. |
Hi diox, thanks. We decided it's not the right solution for us anyways, so I'm not able to invest the time at the moment. With is solution, we'd need to train every user of our software to pass the new command-line parameters, but we'd rather like a solution that "just works" when you say "manage.py compress", so we're now using a custom django-level template loader that excludes the 3rd-party templates we don't actually use. |
@raphaelm could you clarify a bit more on your solution? Which is the template loader you use? It may be helpful for me also. Thank you |
Yeah, sure, you can have a look at our work in progress here: https://github.com/pretix/pretix/pull/2459/files |
Here's our solution. Place file in from __future__ import annotations
from pathlib import Path
from typing import cast
from compressor.management.commands import compress
from django.template import engines
from django.template.backends.django import DjangoTemplates
from django.template.loaders.app_directories import Loader
class CompressLoader(Loader):
"""Loader which only returns template paths inside this application."""
def get_dirs(self) -> list[str | Path]:
ds = super().get_dirs()
return [d for d in ds if "APPLICATION_DIR" in str(d)]
class Command(compress.Command):
"""Compressor for only edubroker_kom templates."""
def get_loaders(self) -> list[Loader]:
template = cast(DjangoTemplates, engines["django"])
return [CompressLoader(template.engine)] |
from offline compression. It uses the fnmatch module to
match the files and will output the list of excluded
templates if verbose >=2.
Example call:
python manage.py compress -x "forms/*.html" -x "test*/*.html"
This shoud fix #785