Simplify and fix bugs in is_valid_package_atom().
authorZac Medico <zmedico@gentoo.org>
Tue, 6 Nov 2007 09:39:26 +0000 (09:39 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 6 Nov 2007 09:39:26 +0000 (09:39 -0000)
svn path=/main/trunk/; revision=8445

pym/_emerge/__init__.py

index 4733f43f0a5b80802732895441ac6a5d0c1a4a87..e1063dc336a61639b3bde1837524114c49a16ecb 100644 (file)
@@ -4983,17 +4983,11 @@ def checkUpdatedNewsItems(portdb, vardb, NEWS_PATH, UNREAD_PATH, repo_id):
        return manager.getUnreadItems( repo_id, update=True )
 
 def is_valid_package_atom(x):
-       try:
-               testkey = portage.dep_getkey(x)
-       except portage.exception.InvalidData:
-               return False
-       if testkey.startswith("null/"):
-               testatom = x.replace(testkey[5:], "cat/"+testkey[5:])
-       elif "/" not in x:
-               testatom = "cat/"+x
-       else:
-               testatom = x
-       return portage.isvalidatom(testatom)
+       if "/" not in x:
+               alphanum = re.search(r'\w', x)
+               if alphanum:
+                       x = x[:alphanum.start()] + "cat/" + x[alphanum.start():]
+       return portage.isvalidatom(x)
 
 def show_blocker_docs_link():
        print