Skip to content

Conversation

JonoYang
Copy link
Collaborator

@JonoYang JonoYang commented Oct 4, 2018

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

    * Modify PackageURL constructor to accept a string of qualifiers in addition to a dictionary of qualifiers

Signed-off-by: Jono Yang <jyang@nexb.com>
Copy link
Member

@pombredanne pombredanne left a 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.

"""
Return normalized purl components.
"""
if encode is True:
Copy link
Member

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)"""
....


if namespace:
namespace = namespace.strip().strip('/')
if type and type in ('bitbucket', 'github', 'pypi'):
Copy link
Member

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

@pombredanne
Copy link
Member

You said:

Also, the PackageURL constructor has been changed to accept a string of qualifiers in addition to a dictionary of qualifiers.

I did not see such change or did I miss something?

@JonoYang
Copy link
Collaborator Author

JonoYang commented Oct 4, 2018

You said:

Also, the PackageURL constructor has been changed to accept a string of qualifiers in addition to a dictionary of qualifiers.

I did not see such change or did I miss something?

The change is in line 193, during the type check for qualifiers.

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
@JonoYang JonoYang force-pushed the normalize-qualifiers-function branch from 63ca00e to 2a4ceec Compare October 4, 2018 23:37
@pombredanne
Copy link
Member

LGTM! thanks++

@pombredanne pombredanne merged commit 6106da1 into package-url:master Oct 5, 2018
@pombredanne
Copy link
Member

And I pushed a new version at https://pypi.org/project/packageurl-python/

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