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 a simple order strategy for result of search command #4131

Closed
wants to merge 5 commits into from

Conversation

bukn
Copy link

@bukn bukn commented Nov 22, 2016

Mostly, I use "pip search" just with a package name that I want to install. I just want to make sure that the name is correct. But most of the time, the result is very confused. I add a small ordering strategy on search result by giving them a score. The solution is very elementary. But, at least, if I did search with the exactly package name, that package would come at the very first line. I'm using this version of pip search on my own laptop for a while. Till now, it works fine. :-)

p = re.compile(query)
p_ignorecase = re.compile(query, re.IGNORECASE)
for index, item in enumerate(hits):
hits[index]['match_score'] = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

for any use of hits[index] you can just use item

the enumerate is also unnecessary then

Copy link
Author

Choose a reason for hiding this comment

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

sorry, the habbit took from php :-)

for index, item in enumerate(hits):
hits[index]['match_score'] = 0
name = item['name']
summary = item['summary']
Copy link
Contributor

Choose a reason for hiding this comment

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

just use summary = item['summary'] or ''

@RonnyPfannschmidt
Copy link
Contributor

there should be a few unit-tests for the function - at first glance it seems potentially fragile

from __future__ import absolute_import

import logging
import sys
import textwrap
import re
Copy link
Member

Choose a reason for hiding this comment

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

Global imports should be alphabetically ordered

Copy link
Author

Choose a reason for hiding this comment

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

Got it. Modified.

@xavfernandez xavfernandez added C: search 'pip search' type: enhancement Improvements to functionality labels Nov 22, 2016
@xavfernandez
Copy link
Member

xavfernandez commented Nov 22, 2016

It feels like you are trying to shove into pip improvements to the search currently happening in PyPI and that will soon happen in warehouse.
I think the improvement should directly go there...

@@ -1,6 +1,8 @@

Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary.

@pradyunsg
Copy link
Member

Could you add a news file for this?

@pradyunsg pradyunsg added the S: awaiting response Waiting for a response/more information label Aug 21, 2017
@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Sep 1, 2017
@pradyunsg
Copy link
Member

Closing due to lack of a response.

@pradyunsg pradyunsg removed the S: awaiting response Waiting for a response/more information label Nov 4, 2017
@pradyunsg pradyunsg closed this Nov 4, 2017
@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: search 'pip search' needs rebase or merge PR has conflicts with current master type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants