hwoarang 14/09/01 21:20:49 Modified: get_glsas.py Log: get_glsas.py: Multiple fixes - Add command line arguments for start-stop date - Escape ',' in description since it conflicts with the wordpress pluging for tables - Take care of GLSAs for multiple packages - improve code to construct the GLSA id hyperlink
Revision Changes Path 1.4 src/gwn/get_glsas.py file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?rev=1.4&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?rev=1.4&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?r1=1.3&r2=1.4 Index: get_glsas.py =================================================================== RCS file: /var/cvsroot/gentoo/src/gwn/get_glsas.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- get_glsas.py 26 Nov 2013 18:54:44 -0000 1.3 +++ get_glsas.py 1 Sep 2014 21:20:49 -0000 1.4 @@ -25,13 +25,12 @@ if td.a: # Fetch GLSA id and reconstruct the href glsanum = str(td.a).split() - if str(date_from) in str(glsanum[2]): - foundone = 1 - glsanum = glsanum[0] + " " + \ - glsanum[1] + glsanum[2] + glsanum[3] - glsa_list.append(glsanum) - else: - return + if any(str(date_from) in date for date in glsanum): + foundone = 1 + glsanum = glsanum[0] + " " + glsanum[1] + glsanum[2] + glsanum[3] + glsa_list.append(glsanum) + else: + break passt += 1 else: # Ignore table headers @@ -43,14 +42,26 @@ elif passt == 2: # Fetch package name and construct href - package = str(td.string).strip() - package = "<a href=\"http://packages.gentoo.org/package/%s\">%s</a>" % (package, package) + if td.a: + # This is usually for GLSAs for + # multiple packages. + # FIXME: There has to be a better way + # to do that... + package = td.find_next(text=True).strip().split()[0] + extra_pkg = \ + td.find_next(text=True).strip() + " more)" + package = \ + "<a href=\"http://packages.gentoo.org/package/%s\">%s</a>" \ + % (package, extra_pkg) + else: + package = str(td.string).strip() + package = "<a href=\"http://packages.gentoo.org/package/%s\">%s</a>" % (package, package) package_list.append(package) passt += 1 elif passt == 3: # Fetch description - description = str(td.string).strip() + description = str(td.string).strip().replace(',','\,') description_list.append(description) passt += 1 @@ -66,6 +77,15 @@ # get dates from command line, else use now (time.time()) starttime = time.gmtime(time.time() - (60 * 60 * 24 * 1)) endtime = time.gmtime(time.time() + (60 * 60 * 24 * 31)) + if len(sys.argv) >=1: + if len(sys.argv) >= 2: + starttime = time.strptime(str(int(sys.argv[1])), "%Y%m%d") + endtime = time.strptime(str(int(sys.argv[2])), "%Y%m%d") + else: + print "Usage: " + os.path.basename(sys.argv[0]) + " [start-date] [end-date]" + print "dates must be passed in 'yyyymmdd' format" + print "if no dates are specified then it defaults to a date range of the last 31 days" + # Format the string to what we expect date_to = time.strftime("%Y%m", endtime) date_from = time.strftime("%Y%m", starttime)
