Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 27, 2025
1 parent c0e052a commit 618c59e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions surfactant/cmd/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
import pathlib
import queue
import re
from enum import Enum, auto
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union

import click
from loguru import logger

from surfactant import ContextEntry
from surfactant.cmd.internal.generate_utils import SpecimenConfigParamType
from surfactant.configmanager import ConfigManager
from surfactant.fileinfo import sha256sum
from surfactant.plugin.manager import call_init_hooks, find_io_plugin, get_plugin_manager
from surfactant.relationships import parse_relationships
from surfactant.sbomtypes import SBOM, Software
from surfactant.cmd.internal.generate_utils import SpecimenConfigParamType


# Converts from a true path to an install path
Expand Down
16 changes: 9 additions & 7 deletions surfactant/cmd/internal/generate_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: MIT
import os
import json
import os
import pathlib

import click
from loguru import logger


class SpecimenConfigParamType(click.Path):
"""
Expand Down Expand Up @@ -40,7 +40,7 @@ def _get_param_type(filename: str):
tuple: A 3-tuple containing:
- str: The parameter type ('FILE', 'DIR', 'CONFIG', or '' for default)
- Path: The filepath as a Path object
- Path or None: The install prefix path (for files), directory path (for dirs),
- Path or None: The install prefix path (for files), directory path (for dirs),
or None (for config or default)
"""

Expand All @@ -60,7 +60,7 @@ def convert(self, value, param, ctx):
# value received may already be the right type
if isinstance(value, list):
return value

param_type, filepath, installprefix = self._get_param_type(value)

# validate filepath exists and is readable
Expand Down Expand Up @@ -96,7 +96,9 @@ def convert(self, value, param, ctx):
try:
config = json.load(f)
except json.decoder.JSONDecodeError as err:
self.fail(f"{filepath.as_posix()!r} config file contains invalid JSON", param, ctx)
self.fail(
f"{filepath.as_posix()!r} config file contains invalid JSON", param, ctx
)

for entry in config:
extract_path = entry["extractPaths"]
Expand All @@ -106,5 +108,5 @@ def convert(self, value, param, ctx):
self.fail(f"invalid extract path in config file: {pth}", param, ctx)
else:
self.fail(f"{value!r} is not a valid specimen config type", param, ctx)
return config

return config

0 comments on commit 618c59e

Please sign in to comment.