Skip to content

Commit

Permalink
Merge pull request #1094 from carmenbianca/refactor-consts
Browse files Browse the repository at this point in the history
Refactor constants
  • Loading branch information
carmenbianca authored Oct 24, 2024
2 parents c38ca2a + 9f9f413 commit f8466ba
Show file tree
Hide file tree
Showing 21 changed files with 649 additions and 626 deletions.
41 changes: 3 additions & 38 deletions src/reuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import gettext
import logging
import os
import re
from dataclasses import dataclass, field
from enum import Enum
from importlib.metadata import PackageNotFoundError, version
from typing import Any, Optional

from boolean.boolean import Expression
from license_expression import Licensing

try:
__version__ = version("reuse")
Expand All @@ -43,6 +43,8 @@

_LOGGER = logging.getLogger(__name__)

_LICENSING = Licensing()

_PACKAGE_PATH = os.path.dirname(__file__)
_LOCALE_DIR = os.path.join(_PACKAGE_PATH, "locale")

Expand All @@ -54,43 +56,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
7 changes: 2 additions & 5 deletions src/reuse/_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@
from jinja2.exceptions import TemplateNotFound

from . import ReuseInfo
from ._util import (
_determine_license_suffix_path,
contains_reuse_info,
detect_line_endings,
)
from ._util import _determine_license_suffix_path
from .comment import (
NAME_STYLE_MAP,
CommentStyle,
EmptyCommentStyle,
get_comment_style,
)
from .exceptions import CommentCreateError, MissingReuseInfoError
from .extract import contains_reuse_info, detect_line_endings
from .header import add_new_header, find_and_replace_header
from .i18n import _
from .project import Project
Expand Down
Loading

0 comments on commit f8466ba

Please sign in to comment.