Skip to content

Commit

Permalink
change: make source more readable in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hfudev committed Oct 1, 2024
1 parent 8de01b9 commit cb6b08a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion idf_component_manager/version_solver/helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0

import logging
import typing as t

from idf_component_tools.semver import Range as SemverRange
Expand All @@ -14,6 +14,8 @@
from .mixology.range import Range
from .mixology.union import Union

logger = logging.getLogger(__name__)


def parse_constraint(spec: str) -> t.Union[Union, Range]:
try:
Expand Down Expand Up @@ -127,6 +129,7 @@ def root_dep(self, package: Package, spec: str) -> None:
if package.source:
spec = package.source.normalize_spec(spec)

logger.debug('Adding root dependency: %s %s', repr(package), spec)
self._root_dependencies.append(Dependency(package, spec))

def _versions_for(
Expand Down
3 changes: 3 additions & 0 deletions idf_component_tools/sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def __eq__(self, other: object) -> bool:
def __hash__(self):
return hash(self._hash_values())

def __str__(self) -> str:
return self.type

def __repr__(self) -> str:
return f'{type(self).__name__}({self.hash_key})'

Expand Down
3 changes: 3 additions & 0 deletions idf_component_tools/sources/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def __init__(self, **kwargs):

self._client = GitClient()

def __repr__(self) -> str:
return f'{self.type}({self.repo if self.path == "." else os.path.join(self.repo, self.repo_path)})'

@property
def repo(self) -> str:
return subst_vars_in_str(self.git)
Expand Down
3 changes: 3 additions & 0 deletions idf_component_tools/sources/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class LocalSource(BaseSource):
path: t.Optional[str] = None
override_path: t.Optional[str] = None

def __repr__(self) -> str:
return f'{self.type}({self.path or self.override_path})'

def model_post_init(self, __context: t.Any) -> None:
if not self.path and not self.override_path:
raise SourceError('Either "path" or "override_path" must be specified for local source')
Expand Down
3 changes: 3 additions & 0 deletions idf_component_tools/sources/web_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ class WebServiceSource(BaseSource):
type: Literal['service'] = 'service' # type: ignore
pre_release: bool = None # type: ignore

def __repr__(self) -> str:
return f'{self.type}({self.registry_url})'

@field_validator('registry_url')
@classmethod
def validate_registry_url(cls, v):
Expand Down

0 comments on commit cb6b08a

Please sign in to comment.