Skip to content

Commit

Permalink
Removed logging silence hack from search
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeta committed May 16, 2012
1 parent 388f3d9 commit 0b3e1b5
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions pip2/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,31 @@
containing information about the package.
"""

import logging

import pip2.commands.freeze
from pip2.compat import packaging


pkg_logger = logging.getLogger("packaging")
old_lvl = pkg_logger.getEffectiveLevel()


def search(package):
"""
Searches the PYPIs for packages based off of
the 'package' parameter, the default is the http://python.org/pypi index
"""
results = dict()

# temp for future ref, fail gracefully
try:
client = packaging.pypi.xmlrpc.Client()
except:
raise

# don't display irrational version warnings
pkg_logger.setLevel(logging.ERROR)
# temp for future ref
try:
projects = client.search_projects(name=package, summary=package)
except:
raise
finally:
pkg_logger.setLevel(old_lvl)
client = packaging.pypi.xmlrpc.Client()
projects = client.search_projects(name=package, summary=package)
installed = pip2.commands.freeze.freeze()

for project in projects:
results[project.name] = dict()
# temp for future ref.
# Sometimes a release can't be found or
# version number can't be rationalized
# if all releases for a project have irrational versions then the
# releases list will be empty
try:
# get the latest release
project.sort_releases()
release = project.releases[0]
except IndexError:
results[project.name]['summary'] = "CANNOT GET SUMMARY"
else:
results[project.name]['summary'] = release.metadata['summary']
#f = results[project.name]['summary']
#f = f.replace('\n', ' ').replace('\t', ' ').replace(' ', ' ')
#results[project.name]['summary'] = f
if project.name in installed.keys():
results[project.name]['installed_version'] = \
installed[project.name]['version']
Expand Down

0 comments on commit 0b3e1b5

Please sign in to comment.