Skip to content

Commit

Permalink
Ensure files actually exist following iterdir.
Browse files Browse the repository at this point in the history
Hopefully avoids WIndows-specific bug.
  • Loading branch information
domdfcoding committed Feb 12, 2025
1 parent a3bd07b commit 8372b17
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sphinx_licenseinfo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#

# stdlib
import os
import textwrap
from typing import Any, Dict, Iterable, List, Optional, Tuple, cast

Expand Down Expand Up @@ -98,9 +99,11 @@ def run(self) -> List[docutils.nodes.Node]:
elif "py" in self.options:
distro: Distribution = get_distribution(self.options["py"])

license_files = sorted(f.name for f in distro.path.glob("LICEN[CS]E*"))
if distro.path.joinpath("licenses").is_dir():
license_files.extend(sorted(map(str, distro.path.joinpath("licenses").iterdir())))
license_files = list(f.name for f in distro.path.glob("LICEN[CS]E*"))
licenses_dir = distro.path / "licenses"
if licenses_dir.is_dir():
license_files.extend(f"licenses/{f}" for f in os.listdir(licenses_dir))
license_files = sorted(f for f in license_files if distro.path.joinpath(f).is_file())

if not license_files:
return self.problematic(
Expand Down

0 comments on commit 8372b17

Please sign in to comment.