Skip to content

Commit

Permalink
Move consts to covered_files
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Oct 17, 2024
1 parent d6a8b11 commit 5d648e4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 44 deletions.
38 changes: 0 additions & 38 deletions src/reuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import gettext
import logging
import os
import re
from dataclasses import dataclass, field
from enum import Enum
from importlib.metadata import PackageNotFoundError, version
Expand Down Expand Up @@ -54,43 +53,6 @@
_LOGGER.debug("no translations found at %s", _LOCALE_DIR)


_IGNORE_DIR_PATTERNS = [
re.compile(r"^\.git$"),
re.compile(r"^\.hg$"),
re.compile(r"^\.sl$"), # Used by Sapling SCM
re.compile(r"^LICENSES$"),
re.compile(r"^\.reuse$"),
]

_IGNORE_MESON_PARENT_DIR_PATTERNS = [
re.compile(r"^subprojects$"),
]

_IGNORE_FILE_PATTERNS = [
# LICENSE, LICENSE-MIT, LICENSE.txt
re.compile(r"^LICEN[CS]E([-\.].*)?$"),
re.compile(r"^COPYING([-\.].*)?$"),
# ".git" as file happens in submodules
re.compile(r"^\.git$"),
re.compile(r"^\.hgtags$"),
re.compile(r".*\.license$"),
re.compile(r"^REUSE\.toml$"),
# Workaround for https://github.com/fsfe/reuse-tool/issues/229
re.compile(r"^CAL-1.0(-Combined-Work-Exception)?(\..+)?$"),
re.compile(r"^SHL-2.1(\..+)?$"),
]

_IGNORE_SPDX_PATTERNS = [
# SPDX files from
# https://spdx.github.io/spdx-spec/conformance/#44-standard-data-format-requirements
re.compile(r".*\.spdx$"),
re.compile(r".*\.spdx.(rdf|json|xml|ya?ml)$"),
]

# Combine SPDX patterns into file patterns to ease default ignore usage
_IGNORE_FILE_PATTERNS.extend(_IGNORE_SPDX_PATTERNS)


class SourceType(Enum):
"""
An enumeration representing the types of sources for license information.
Expand Down
2 changes: 1 addition & 1 deletion src/reuse/cli/spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import click

from .. import _IGNORE_SPDX_PATTERNS
from ..covered_files import _IGNORE_SPDX_PATTERNS
from ..i18n import _
from ..report import ProjectReport
from .common import ClickObj
Expand Down
42 changes: 37 additions & 5 deletions src/reuse/covered_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,51 @@
import contextlib
import logging
import os
import re
from pathlib import Path
from typing import Collection, Generator, Optional, cast

from . import (
_IGNORE_DIR_PATTERNS,
_IGNORE_FILE_PATTERNS,
_IGNORE_MESON_PARENT_DIR_PATTERNS,
)
from .types import StrPath
from .vcs import VCSStrategy

_LOGGER = logging.getLogger(__name__)

_IGNORE_DIR_PATTERNS = [
re.compile(r"^\.git$"),
re.compile(r"^\.hg$"),
re.compile(r"^\.sl$"), # Used by Sapling SCM
re.compile(r"^LICENSES$"),
re.compile(r"^\.reuse$"),
]

_IGNORE_MESON_PARENT_DIR_PATTERNS = [
re.compile(r"^subprojects$"),
]

_IGNORE_FILE_PATTERNS = [
# LICENSE, LICENSE-MIT, LICENSE.txt
re.compile(r"^LICEN[CS]E([-\.].*)?$"),
re.compile(r"^COPYING([-\.].*)?$"),
# ".git" as file happens in submodules
re.compile(r"^\.git$"),
re.compile(r"^\.hgtags$"),
re.compile(r".*\.license$"),
re.compile(r"^REUSE\.toml$"),
# Workaround for https://github.com/fsfe/reuse-tool/issues/229
re.compile(r"^CAL-1.0(-Combined-Work-Exception)?(\..+)?$"),
re.compile(r"^SHL-2.1(\..+)?$"),
]

_IGNORE_SPDX_PATTERNS = [
# SPDX files from
# https://spdx.github.io/spdx-spec/conformance/#44-standard-data-format-requirements
re.compile(r".*\.spdx$"),
re.compile(r".*\.spdx.(rdf|json|xml|ya?ml)$"),
]

# Combine SPDX patterns into file patterns to ease default ignore usage
_IGNORE_FILE_PATTERNS.extend(_IGNORE_SPDX_PATTERNS)


def is_path_ignored(
path: Path,
Expand Down

0 comments on commit 5d648e4

Please sign in to comment.