diff --git a/CHANGES.txt b/CHANGES.txt index 75dd4ec6f1..f7c4b91c58 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,7 @@ Features Bugfixes -------- +* Ignore ``.DS_Store`` files in listing indexes (Issue #3698) * Fix baguetteBox.js invoking in the base theme (Issue #3687) New in v8.2.4 diff --git a/nikola/plugins/task/listings.py b/nikola/plugins/task/listings.py index 5a1b140135..4c1636e558 100644 --- a/nikola/plugins/task/listings.py +++ b/nikola/plugins/task/listings.py @@ -107,6 +107,7 @@ def gen_tasks(self): """Render pretty code listings.""" # Things to ignore in listings ignored_extensions = (".pyc", ".pyo") + ignored_files = (".DS_Store",) def render_listing(in_name, out_name, input_folder, output_folder, folders=[], files=[]): needs_ipython_css = False @@ -183,7 +184,9 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f for input_folder, output_folder in self.kw['listings_folders'].items(): for root, dirs, files in os.walk(input_folder, followlinks=True): - files = [f for f in files if os.path.splitext(f)[-1] not in ignored_extensions] + files = [f for f in files + if os.path.splitext(f)[-1] not in ignored_extensions and + f not in ignored_files] uptodate = {'c': self.site.GLOBAL_CONTEXT} @@ -224,7 +227,7 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f 'clean': True, }, self.kw["filters"]) for f in files: - if f == '.DS_Store': + if f in ignored_files: continue ext = os.path.splitext(f)[-1] if ext in ignored_extensions: