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

Minimal changes to allow running on Py3K #14

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ As of 0.0.7 yolk is in Gentoo's Portage tree as dev-python/yolk and a plugin for
Summary
-------

Yolk is a Python tool for obtaining information about installed Python packages and querying packages avilable on PyPI (Python Package Index).
Yolk is a Python tool for obtaining information about installed Python packages and querying packages available on PyPI (Python Package Index).

You can see which packages are active, non-active or in development mode and show you which have newer versions available by querying PyPI.

Expand All @@ -28,7 +28,7 @@ Usage Examples::

$ yolk -n
List only the non-activated (--multi-version) packages installed

$ yolk -l -f License,Author nose==1.0
Show the license and author for version 1.0 of the package `nose`

Expand Down Expand Up @@ -94,21 +94,21 @@ Changes
**0.4.3**: Added missing documentation and license files



**0.4.2**: Fix for -C when an integer isn't supplied

Fix for --entry-map from Jesus Rivero (Neurogeek) [email protected]. Thanks, Jesus!
Switch to BSD license from GPL-2

Switch to BSD license from GPL-2


**0.4.1**: Fix for -f fields

Add check for integer with -L


**0.4.0**: Added http proxy support for XML-RPC

Added case-insensitive search for -f

Non-existent packages with -S no longer show entire index (bug was with PyPI)
Expand All @@ -130,7 +130,7 @@ Changes

Removed dependency on elementtree


**0.2.0**: Added 'svn' type for -T

A kablillion bug fixes
Expand All @@ -148,7 +148,7 @@ Changes


**0.0.7**: New options: --entry-map and -entry-points

Improved results with --download-links

New plugin system. First plugin available: yolk-portage
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
long_description=open("README", "r").read(),
maintainer="Rob Cakebread",
author="Rob Cakebread",
author_email="cakebread @ gmail",
author_email="cakebread @ gmail dot com",
url="https://github.com/cakebread/yolk",
keywords="PyPI setuptools cheeseshop distutils eggs package management",
classifiers=["Development Status :: 4 - Beta",
Expand Down
23 changes: 12 additions & 11 deletions tests/rss_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#Python <2.5 has elementtree as 3rd party module
from cElementTree import iterparse
except ImportError:
print "You need to install cElementTree"
print("You need to install cElementTree")
sys.exit(2)


Expand Down Expand Up @@ -52,7 +52,7 @@ def get_pkg_ver(pv, add_quotes=True):

def test_api(pypi_xml):
"""Basic API tests"""
print "Testing API"""
print("Testing API""")
skipped = 0
skipped_msgs = []
failed = 0
Expand All @@ -68,29 +68,30 @@ def test_api(pypi_xml):
% (pkg_name, "- space in project name"))
try:
assert versions[0] == ver
print "Testing %s... passed" % elem.text
print("Testing %s... passed" % elem.text)
except:
failed += 1
failed_msgs.append("%s %s" % (pkg_name, versions))
print "Testing %s... failed" % elem.text
print("Testing %s... failed" % elem.text)

print "%s tests failed." % failed
print("%s tests failed." % failed)
for msg in failed_msgs:
print "\t%s" % msg
print "%s tests skipped." % skipped
print("\t%s" % msg)
print("%s tests skipped." % skipped)
for msg in skipped_msgs:
print "\t%s" % msg
print("\t%s" % msg)


def test_cli(pypi_xml):
"""Test the command-line tool"""
print "Testing CLI"
print("Testing CLI")
for event, elem in iterparse(pypi_xml):
if elem.tag == "title":
if not elem.text.startswith('Cheese Shop recent updates'):
print "Testing %s..." % elem.text
print("Testing %s..." % elem.text)
pkg_name, ver = get_pkg_ver(elem.text)
if " " in pkg_name:
print "Space in package name, skipping: %s" % pkg_name
print("Space in package name, skipping: %s" % pkg_name)
else:
os.system("yolk -V '%s'" % pkg_name)
os.system("yolk -D %s==%s" % (pkg_name, ver))
Expand Down
2 changes: 1 addition & 1 deletion yolk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"""

__docformat__ = 'restructuredtext'
__version__ = '0.4.3'
__version__ = '0.5.0'


51 changes: 25 additions & 26 deletions yolk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, stream, modulenames):
self.modulenames = modulenames

def __getattr__(self, attribute):
if not self.__dict__.has_key(attribute) or attribute == '__doc__':
if attribute not in self.__dict__ or attribute == '__doc__':
return getattr(self.stdout, attribute)
return self.__dict__[attribute]

Expand Down Expand Up @@ -237,9 +237,9 @@ def show_updates(self):
"""
Check installed packages for available updates on PyPI

@param project_name: optional package name to check; checks every
installed pacakge if none specified
@type project_name: string
self.project_name: optional package name to check; checks every
installed package if none specified
self.project_name: string

@returns: None
"""
Expand Down Expand Up @@ -310,7 +310,7 @@ def show_distributions(self, show):
for prefix in ignores:
if dist.location.startswith(prefix):
dist.location = dist.location.replace(prefix, "")
#Case-insensitve search because of Windows
#Case-insensitive search because of Windows
if dist.location.lower().startswith(get_python_lib().lower()):
develop = ""
else:
Expand Down Expand Up @@ -414,7 +414,7 @@ def show_deps(self):
"""
Show dependencies for package(s)

@returns: 0 - sucess 1 - No dependency info supplied
@returns: 0 - success 1 - No dependency info supplied
"""

pkgs = pkg_resources.Environment()
Expand Down Expand Up @@ -442,7 +442,7 @@ def show_pypi_changelog(self):
"""
Show detailed PyPI ChangeLog for the last `hours`

@returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server
@returns: 0 = success or 1 if failed to retrieve from XML-RPC server

"""
hours = self.options.show_pypi_changelog
Expand Down Expand Up @@ -493,7 +493,7 @@ def show_pypi_releases(self):

def show_download_links(self):
"""
Query PyPI for pkg download URI for a packge
Query PyPI for pkg download URI for a package

@returns: 0

Expand Down Expand Up @@ -565,7 +565,7 @@ def fetch(self):
if self.options.file_type == "svn":
version = "dev"
svn_uri = get_download_uri(self.project_name, \
"dev", True)
"dev", True)
if svn_uri:
directory = self.project_name + "_svn"
return self.fetch_svn(svn_uri, directory)
Expand All @@ -584,7 +584,7 @@ def fetch(self):
return self.fetch_uri(directory, uri)
else:
self.logger.error("No %s URI found for package: %s " % \
(self.options.file_type, self.project_name))
(self.options.file_type, self.project_name))
return 1

def fetch_uri(self, directory, uri):
Expand Down Expand Up @@ -612,8 +612,12 @@ def fetch_uri(self, directory, uri):
% (filename, uri))
self.logger.error(str(err_msg))
return 1
try:
content_type = headers.gettype()
except AttributeError:
content_type = headers.get_content_type()

if headers.gettype() in ["text/html"]:
if content_type == "text/html":
dfile = open(downloaded_filename)
if re.search("404 Not Found", "".join(dfile.readlines())):
dfile.close()
Expand Down Expand Up @@ -672,14 +676,14 @@ def browse_website(self, browser=None):
metadata = self.pypi.release_data(self.project_name, \
self.all_versions[0])
self.logger.debug("DEBUG: browser: %s" % browser)
if metadata.has_key("home_page"):
if "home_page" in metadata:
self.logger.info("Launching browser: %s" \
% metadata["home_page"])
if browser == 'konqueror':
browser = webbrowser.Konqueror()
else:
browser = webbrowser.get()
browser.open(metadata["home_page"], 2)
browser.open(metadata["home_page"], 2)
return 0

self.logger.error("No homepage URL found.")
Expand Down Expand Up @@ -725,10 +729,10 @@ def versions_available(self):
print_pkg_versions(self.project_name, self.all_versions)
else:
if self.version:
self.logger.error("No pacakge found for version %s" \
self.logger.error("No package found for version %s" \
% self.version)
else:
self.logger.error("No pacakge found for %s" % self.project_name)
self.logger.error("No package found for %s" % self.project_name)
return 1
return 0

Expand Down Expand Up @@ -784,13 +788,11 @@ def parse_search_spec(self, spec):
first = spec
(key1, term1) = first.split('=')
key1 = key1.strip()
spec = {key1: term1}

if second:
(key2, term2) = second.split('=')
key2 = key2.strip()

spec = {}
spec[key1] = term1
if second:
spec[key2] = term2
except:
self.logger.error(usage)
Expand All @@ -803,8 +805,8 @@ def pypi_search(self):
Search PyPI by metadata keyword
e.g. yolk -S name=yolk AND license=GPL

@param spec: Cheese Shop search spec
@type spec: list of strings
self.pkg_spec: Cheese Shop search spec
self.pkg_spec: list of strings

spec examples:
["name=yolk"]
Expand All @@ -815,7 +817,7 @@ def pypi_search(self):

"""
spec = self.pkg_spec
#Add remainging cli arguments to options.pypi_search
#Add remaining cli arguments to options.pypi_search
search_arg = self.options.pypi_search
spec.insert(0, search_arg.strip())

Expand All @@ -837,9 +839,6 @@ def show_entry_map(self):
"""
Show entry map for a package

@param dist: package
@param type: srting

@returns: 0 for success or 1 if error
"""
pprinter = pprint.PrettyPrinter()
Expand Down Expand Up @@ -870,7 +869,7 @@ def show_entry_points(self):
print(" %s" % entry_point)
if plugin.__doc__:
print(plugin.__doc__)
print
print()
except ImportError:
pass
if not found:
Expand Down
Loading