Skip to content

Commit

Permalink
Reduce the amount of branches to satisfy the linter
Browse files Browse the repository at this point in the history
  • Loading branch information
carmenbianca committed Sep 23, 2023
1 parent ffe89e1 commit 4049236
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/reuse/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,14 @@ def reuse_info_of(self, path: StrPath) -> List[ReuseInfo]:
# Search the file for REUSE information.
with path.open("rb") as fp:
try:
read_limit: Optional[int] = _HEADER_BYTES
# Completely read the file once
# to search for possible snippets
if _contains_snippet(fp):
_LOGGER.debug(
f"'{path}' seems to contain an SPDX Snippet"
)
read_limit = None
else:
read_limit = _HEADER_BYTES
# Reset read position
fp.seek(0)
# Scan the file for REUSE info, possibly limiting the read
Expand All @@ -214,10 +213,9 @@ def reuse_info_of(self, path: StrPath) -> List[ReuseInfo]:
decoded_text_from_binary(fp, size=read_limit)
)
if file_result.contains_copyright_or_licensing():
source_type = SourceType.FILE_HEADER
if path.suffix == ".license":
source_type = SourceType.DOT_LICENSE
else:
source_type = SourceType.FILE_HEADER
file_result = file_result.copy(
path=self.relative_from_root(
original_path
Expand Down

0 comments on commit 4049236

Please sign in to comment.