lol

python313Packages.django-compressor: fix bs4 4.13 compat

+45
+39
pkgs/development/python-modules/django-compressor/bs4-4.13-compat.patch
··· 1 + From 53f50bc0cee1cdfaf023ba65e1524b820cb7c18e Mon Sep 17 00:00:00 2001 2 + From: Matthias Kestenholz <mk@feinheit.ch> 3 + Date: Thu, 22 May 2025 10:37:20 +0200 4 + Subject: [PATCH] Disable bs4's multi valued attributes 5 + 6 + --- 7 + compressor/parser/beautifulsoup.py | 12 ++++-------- 8 + 1 file changed, 4 insertions(+), 8 deletions(-) 9 + 10 + diff --git a/compressor/parser/beautifulsoup.py b/compressor/parser/beautifulsoup.py 11 + index 91897485..f673410e 100644 12 + --- a/compressor/parser/beautifulsoup.py 13 + +++ b/compressor/parser/beautifulsoup.py 14 + @@ -10,7 +10,9 @@ def __init__(self, content): 15 + try: 16 + from bs4 import BeautifulSoup 17 + 18 + - self.soup = BeautifulSoup(self.content, "html.parser") 19 + + # Disable multi_valued_attributes 20 + + # http://www.crummy.com/software/BeautifulSoup/bs4/doc/#multi-valued-attributes 21 + + self.soup = BeautifulSoup(self.content, "html.parser", multi_valued_attributes={}) 22 + except ImportError as err: 23 + raise ImproperlyConfigured("Error while importing BeautifulSoup: %s" % err) 24 + 25 + @@ -21,13 +23,7 @@ def js_elems(self): 26 + return self.soup.find_all("script") 27 + 28 + def elem_attribs(self, elem): 29 + - attrs = dict(elem.attrs) 30 + - # hack around changed behaviour in bs4, it returns lists now instead of one string, see 31 + - # http://www.crummy.com/software/BeautifulSoup/bs4/doc/#multi-valued-attributes 32 + - for key, value in attrs.items(): 33 + - if type(value) is list: 34 + - attrs[key] = " ".join(value) 35 + - return attrs 36 + + return elem.attrs 37 + 38 + def elem_content(self, elem): 39 + return elem.string
+6
pkgs/development/python-modules/django-compressor/default.nix
··· 34 34 hash = "sha256-wdikii7k2LfyPEEeucl+LYjbGKGLocnoF41fW4NmqCI="; 35 35 }; 36 36 37 + patches = [ 38 + # https://github.com/django-compressor/django-compressor/issues/1279 39 + # https://github.com/django-compressor/django-compressor/pull/1296 40 + ./bs4-4.13-compat.patch 41 + ]; 42 + 37 43 build-system = [ 38 44 setuptools 39 45 ];