Skip to content

Commit

Permalink
Merge pull request #3699 from getnikola/fix-3698
Browse files Browse the repository at this point in the history
Fix #3698 — ignore .DS_Store files in listing indexes
  • Loading branch information
Kwpolska committed Jul 9, 2023
2 parents 84f6a2b + 1a7e7df commit 69a633f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions nikola/plugins/task/listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 69a633f

Please sign in to comment.