public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Markos Chandras (hwoarang)" <hwoarang@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo commit in src/gwn: get_glsas.py
Date: Mon,  1 Sep 2014 21:20:49 +0000 (UTC)	[thread overview]
Message-ID: <20140901212049.3F4004765@oystercatcher.gentoo.org> (raw)

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)





             reply	other threads:[~2014-09-01 21:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01 21:20 Markos Chandras (hwoarang) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-11-26 18:54 [gentoo-commits] gentoo commit in src/gwn: get_glsas.py Markos Chandras (hwoarang)
2013-10-12 16:08 Markos Chandras (hwoarang)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140901212049.3F4004765@oystercatcher.gentoo.org \
    --to=hwoarang@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox