Use startswith and endswith to simplify code.
authorZac Medico <zmedico@gentoo.org>
Fri, 12 Jan 2007 08:27:31 +0000 (08:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 12 Jan 2007 08:27:31 +0000 (08:27 -0000)
svn path=/main/trunk/; revision=5598

pym/getbinpkg.py

index 7067eefd43f18b0c34a7fe2c20914e8b7d5f5096..40f3c64204e8dcb0f8d175f6bba864996f3c77e6 100644 (file)
@@ -6,7 +6,7 @@
 if not hasattr(__builtins__, "set"):
        from sets import Set as set
 
-from output import *
+#from output import *
 import htmllib,HTMLParser,formatter,sys,os,xpak,time,tempfile,base64,urllib2
 
 try:
@@ -50,7 +50,7 @@ class ParseLinks(HTMLParser.HTMLParser):
        def get_anchors_by_prefix(self,prefix):
                newlist = []
                for x in self.PL_anchors:
-                       if (len(x) >= len(prefix)) and (x[:len(suffix)] == prefix):
+                       if x.startswith(prefix):
                                if x not in newlist:
                                        newlist.append(x[:])
                return newlist
@@ -58,7 +58,7 @@ class ParseLinks(HTMLParser.HTMLParser):
        def get_anchors_by_suffix(self,suffix):
                newlist = []
                for x in self.PL_anchors:
-                       if (len(x) >= len(suffix)) and (x[-len(suffix):] == suffix):
+                       if x.endswith(prefix):
                                if x not in newlist:
                                        newlist.append(x[:])
                return newlist