Skip to content

Conversation

@cjmartian
Copy link
Contributor

This fixes #9814

Instead of split we use rsplit to correctly parse a url. We also change the max split to 1 instead of 2

@cjmartian cjmartian requested a review from a team as a code owner April 14, 2020 20:21
@cjmartian cjmartian self-assigned this Apr 14, 2020
@cla-bot cla-bot bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 14, 2020


def test_dist_str(self):
m1 = MatchSpec.from_dist_str("anaconda/{}::python-3.6.6-0.tar.bz2".format(context.subdir))
Copy link
Contributor

Choose a reason for hiding this comment

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

When using .format() and positional arguments, best practice is to enumerate each position. So

"anaconda/{0}::python-3.6.6-0.tar.bz2".format(context.subdir)

One reason is that it has a substantial speed advantage, approaching the speed of the older % string composition. The performance obviously doesn't matter here, but it can make a difference in a tight loop.

parts = {}
if dist_str.endswith(CONDA_PACKAGE_EXTENSION_V1):
dist_str = dist_str[:-len(CONDA_PACKAGE_EXTENSION_V1)]
if '::' in dist_str:
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess after line 182 we should start adding in

        if dist_str.endswith(CONDA_PACKAGE_EXTENSION_V2):
            dist_str = dist_str[:-len(CONDA_PACKAGE_EXTENSION_V2)]

Copy link
Contributor

Choose a reason for hiding this comment

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

Although another best practice is to use string slices instead of .endswith(), again for performance reasons. See comment at #9812 (comment).

Copy link
Contributor

@kalefranz kalefranz left a comment

Choose a reason for hiding this comment

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

Added one more comment, and still have one other comment we should address.

subdir = None
parts.update({
'channel': channel_str,
'subdir': subdir,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little nervous here about adding parts["subdir"] = None, and I don't think we need to. Instead of

parts.update({
    'channel': channel_str,
    'subdir': subdir,
})

let's just do

parts["channel"] = channel_str
if subdir:
    parts["subdir"] = subdir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I made that change

@kalefranz
Copy link
Contributor

Also now you can rebase against master.

Copy link
Contributor

@kalefranz kalefranz left a comment

Choose a reason for hiding this comment

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

Looks like test failure is just appveyor timeout. Everything looked to pass in what the appveyor run got to.

@kalefranz kalefranz merged commit 305bf88 into conda:master Apr 24, 2020
@cjmartian cjmartian deleted the fix-url-parsing branch April 24, 2020 16:48
@kalefranz kalefranz added this to the 4.8.4 milestone Apr 26, 2020
@github-actions
Copy link

Hi there, thank you for your contribution to Conda!

This pull request has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue or pull request if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Aug 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed [bot] added once the contributor has signed the CLA locked [bot] locked due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

url as channel name breaks splitting channel_subdir_str by slash

2 participants