Fixing finding licenses#15
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the --scheme flag with --project, introduces functions to locate Xcode’s DerivedData and SourcePackages paths, and refactors license discovery to use pathlib.
- Change CLI flag from
--schemeto--projectand update argument parsing. - Add
get_xcode_derived_data_baseandfind_derived_data_for_projectto resolve DerivedData. - Rewrite
get_packages_licensesto usePath.iterdirand read license files.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/xctools_kamaalio/actions/acknowledgments.py | Updated argument parsing, added DerivedData resolution, refactored license discovery, and minor formatting updates |
| pyproject.toml | Bumped version from 0.4.0 to 0.5.0 |
Comments suppressed due to low confidence (1)
src/xctools_kamaalio/actions/acknowledgments.py:218
- [nitpick] The function name could be shortened or clarified, e.g.,
get_derived_data_base, since the Xcode context is already in the module name.
def get_xcode_derived_data_base() -> Path:
| for content_path in packages_directory.iterdir(): | ||
| if not content_path.is_dir(): | ||
| continue | ||
|
|
||
| package_name = root.split("/")[-1] | ||
| for package_path in content_path.iterdir(): | ||
| if not package_path.is_file() or "license" not in package_path.name.lower(): | ||
| continue | ||
|
|
||
| license_path = os.path.join(root, "LICENSE") | ||
| with open(license_path, "r") as file: | ||
| licenses[package_name] = file.read() | ||
| licenses[content_path.name] = package_path.read_text() | ||
|
|
There was a problem hiding this comment.
Current logic only searches one level deep for license files; nested LICENSE files or unconventional names may be missed. Consider using Path.rglob with a case-insensitive pattern to ensure all licenses are found.
| def find_derived_data_for_project(project_name: str) -> Path: | ||
| base = get_xcode_derived_data_base() | ||
| pattern = str(base / f"{project_name}-*") | ||
| matches = glob.glob(pattern) |
There was a problem hiding this comment.
Instead of glob.glob followed by sorting, consider using base.glob(f"{project_name}-*") and max() with a key on Path.stat().st_mtime to avoid the extra dependency and simplify the code.
ee736d0 to
4c507a9
Compare
Pull Request Overview
This PR replaces the
--schemeflag with--project, introduces functions to locate Xcode’s DerivedData and SourcePackages paths, and refactors license discovery to usepathlib.--schemeto--projectand update argument parsing.get_xcode_derived_data_baseandfind_derived_data_for_projectto resolve DerivedData.get_packages_licensesto usePath.iterdirand read license files.