Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for skipping license paths #851

Merged
merged 1 commit into from
Sep 19, 2024
Merged

Conversation

bryteise
Copy link
Member

Add support for a new config file with glob like handling of paths as some projects contain license files that are not the license of the project.

scan_for_licenses now looks at the configuration and does glob like matching for all the potential license files it tries to add.

This change caused a few structural adjustments to the code and a slight style change for importing just the toplevel util submodule that are superficial.

Add support for a new config file with glob like handling of paths as
some projects contain license files that are not the license of the
project.

scan_for_licenses now looks at the configuration and does glob like
matching for all the potential license files it tries to add.

This change caused a few structural adjustments to the code and a
slight style change for importing just the toplevel util submodule
that are superficial.

Signed-off-by: William Douglas <william.douglas@intel.com>
@bryteise bryteise merged commit 7b01f0b into master Sep 19, 2024
4 checks passed
@bryteise bryteise deleted the license-skip-support branch September 19, 2024 19:02
file_path = 'a/ab'
self.assertFalse(util.globlike_match(file_path, match_name))

match_name = ['a', 'b*']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oopsie, will fix.

@@ -274,3 +274,31 @@ def open_auto(*args, **kwargs):
assert 'encoding' not in kwargs
assert 'errors' not in kwargs
return open(*args, encoding="utf-8", errors="surrogateescape", **kwargs)


def globlike_match(filename, match_name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you didn't edit this aside from moving it to util?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, same function though the signature had to change since it isn't a class method (though it wasn't using any of the object's fields).

license_skips
Each line in the file should be a full path, that path is prefixed into a
tempfile directory + the package tarfile prefix. Requires using '*' to be
effective (e.g. /tmp/*/pkgname-*/path/to/license).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we hide some of this prefix? Especially if it's going to be boilerplate /tmp/*/... we should just prepend it when skip_license calls globlike_match, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh that is nicer, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants