03a4ac012e8f18c8f238f153118bbf5f247bc7ca
[wolnelektury.git] / apps / compress / filters / csstidy_python / __init__.py
1 from django.conf import settings
2
3 from compress.filter_base import FilterBase
4 from compress.filters.csstidy_python.csstidy import CSSTidy
5
6 COMPRESS_CSSTIDY_SETTINGS = getattr(settings, 'COMPRESS_CSSTIDY_SETTINGS', {})
7
8 class CSSTidyFilter(FilterBase):
9     def filter_css(self, css):
10         tidy = CSSTidy()
11
12         for k, v in COMPRESS_CSSTIDY_SETTINGS.items():
13             tidy.setSetting(k, v)
14
15         tidy.parse(css)
16
17         r = tidy.Output('string')
18
19         return r