-
Notifications
You must be signed in to change notification settings - Fork 51
Break out qualifiers normalization subroutine as its own function #10
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
Break out qualifiers normalization subroutine as its own function #10
Conversation
* Modify PackageURL constructor to accept a string of qualifiers in addition to a dictionary of qualifiers Signed-off-by: Jono Yang <jyang@nexb.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you: this makes a lot of sense
Do you mind adding a test for this new function?
See also my other comments.
src/packageurl.py
Outdated
""" | ||
Return normalized purl components. | ||
""" | ||
if encode is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to make this a function that's shared: something like
def get_quoter(encode=True):
"""Return quoting callable given an `encode` tri-boolean (True, False or None)"""
....
src/packageurl.py
Outdated
|
||
if namespace: | ||
namespace = namespace.strip().strip('/') | ||
if type and type in ('bitbucket', 'github', 'pypi'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hindsight, if type in... would be enough
You said:
I did not see such change or did I miss something? |
The change is in line 193, during the type check for |
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
63ca00e
to
2a4ceec
Compare
LGTM! thanks++ |
And I pushed a new version at https://pypi.org/project/packageurl-python/ |
By breaking out this functionality into its own function from
normalize()
, users can easily create a dictionary of qualifiers from a properly formatted string of qualifiers and vice versa.Also, the PackageURL constructor has been changed to accept a string of qualifiers in addition to a dictionary of qualifiers.
Signed-off-by: Jono Yang jyang@nexb.com