From 2aabcb8f69c1ef4cf170ec9f753eafb29c2e5555 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 12 Sep 2009 17:47:58 +0000 Subject: Reimplement isjustname() using the Atom class. Thanks to Marat Radchenko for the suggestion. svn path=/main/trunk/; revision=14234 --- pym/portage/dep.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/pym/portage/dep.py b/pym/portage/dep.py index cf06eca7f..c16b816b6 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -918,28 +918,23 @@ def isvalidatom(atom, allow_blockers=False): def isjustname(mypkg): """ - Checks to see if the depstring is only the package name (no version parts) + Checks to see if the atom is only the package name (no version parts). + Raises InvalidAtom if the input is invalid. Example usage: >>> isjustname('media-libs/test-3.0') - 0 - >>> isjustname('test') - 1 + False >>> isjustname('media-libs/test') - 1 + True @param mypkg: The package atom to check - @param mypkg: String + @param mypkg: String or Atom @rtype: Integer @return: One of the following: - 1) 0 if the package string is not just the package name - 2) 1 if it is + 1) False if the package string is not just the package name + 2) True if it is """ - myparts = mypkg.split('-') - for x in myparts: - if ververify(x): - return 0 - return 1 + return str(mypkg) == str(Atom(mypkg).cp) iscache = {} -- cgit v1.2.3-1-g7c22