From 8c021b81cd3c8d0e9d631778db3307ed44997556 Mon Sep 17 00:00:00 2001 From: joknarf Date: Thu, 26 Dec 2024 10:22:58 +0100 Subject: [PATCH] proper sort filename --- pywebfs/pywebfs.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pywebfs/pywebfs.py b/pywebfs/pywebfs.py index 3608d87..4f7cb9f 100755 --- a/pywebfs/pywebfs.py +++ b/pywebfs/pywebfs.py @@ -9,6 +9,7 @@ import urllib import html import base64 +import unicodedata from functools import lru_cache # python 3.6 no TheedingHTTPServer @@ -529,6 +530,7 @@ """ #JAVASCRIPT=f"" RE_AGENT = re.compile(r"(Edg|Chrome|Safari|Firefox|Opera|Lynx)[^ ]*") +RE_ACCENT = re.compile(r"[\u0300-\u036f]") class BadStat: st_size = 0 @@ -948,7 +950,10 @@ def list_directory(self, path): self.write_html("\n") self.write_html('

0 file - 0 B

\n') return - entries = sorted(entries, key=lambda entry: (not entry.is_dir(), entry.name.lower())) + entries = sorted(entries, key=lambda entry: ( + not entry.is_dir(), + RE_ACCENT.sub("", unicodedata.normalize("NFD", entry.name.lower())) + )) nbfiles = 0 size = 0 for entry in entries: