summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVít Ondruch <vondruch@redhat.com>2011-10-12 16:36:06 +0200
committerTill Maas <opensource@till.name>2011-10-17 18:58:20 +0200
commit0b0bbb40460458a964e56b54c89a362d0915e571 (patch)
tree39b54dd663c8ce1e8cb7f6a7acc909b12a1eb250
parenteed9b30c662fe2d39e450169af987912295e147f (diff)
downloadcnucnu-0b0bbb40460458a964e56b54c89a362d0915e571.tar.gz
cnucnu-0b0bbb40460458a964e56b54c89a362d0915e571.tar.xz
cnucnu-0b0bbb40460458a964e56b54c89a362d0915e571.zip
URM - Rubygems support
Hi Till, I've got tired of copy/pasting and tweaking of RubyGems entries in your Upstrean Release Monitoring. So I put together small patch which should add RUBYGEMS-DEFAULT aliases for Regex and URL. Unfortunately, I am not Python developer neither I have clue how to test the code I have developed, so I just blindly believe it works as supposed. Could you please review the code and merge it or send me some feedback? And I have one more note. There is used several times the -DEFAULT suffix for aliases. While I see that it has its reasoning for the CPAN-DEFAULT and similar aliases, it has no meaning for rubygems, because the Regex does not using the default Regex, so the alias name should be adjusted probably. The default in URL aliases has no meaning at all IMO. Is it possible to remove the suffix? At least for Rubygems, although it would not be consistent :) Also, there seems to be some undocumented regex aliases, such as CPAN-DEFAULT, PEAR-DEFAULT and PECL-DEFAULT. Could you add the documentation on wiki or shall I? Thank you and best regards Vit >From 0c7097f750755c70d84e2e118e0c73b7917b5c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> Date: Wed, 12 Oct 2011 16:23:31 +0200 Subject: [PATCH] Add URL and regex aliases for RubyGems.
-rwxr-xr-xcnucnu/package_list.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/cnucnu/package_list.py b/cnucnu/package_list.py
index 0af4f16..adb6651 100755
--- a/cnucnu/package_list.py
+++ b/cnucnu/package_list.py
@@ -150,6 +150,10 @@ class Package(object):
if not name_override and name.startswith("php-pecl-"):
name = name[len("php-pecl-"):].replace("-","_")
regex = "DEFAULT"
+ elif regex == "RUBYGEMS-DEFAULT":
+ # strip "rubygem-" prefix only if name was not overridden
+ if not name_override and name.startswith("rubygem-"):
+ name = name[len("rubygem-"):]
# no elif here, because the previous regex aliases are only for name altering
if regex == "DEFAULT":
@@ -166,6 +170,8 @@ class Package(object):
regex = '<a href="/projects/[^/]*/releases/[0-9]*">([^<]*)</a>'
elif regex == "HACKAGE-DEFAULT" or regex== "DIR-LISTING-DEFAULT":
regex = 'href="([0-9][0-9.]*)/"'
+ elif regex == "RUBYGEMS-DEFAULT":
+ regex = '"gem_uri":"http:\/\/rubygems.org\/gems\/%s-([0-9.]*?)\.gem"' % re.escape(name)
self.__regex = regex
self._invalidate_caches()
@@ -178,7 +184,7 @@ class Package(object):
name = self.name
# allow name override with e.g. SF-DEFAULT:othername
if url:
- name_override = re.match(r"^((?:SF|FM|GNU|CPAN|HACKAGE|DEBIAN|GOOGLE|PEAR|PECL|PYPI|LP|GNOME)-DEFAULT)(?::(.+))$", url)
+ name_override = re.match(r"^((?:SF|FM|GNU|CPAN|HACKAGE|DEBIAN|GOOGLE|PEAR|PECL|PYPI|LP|GNOME|RUBYGEMS)-DEFAULT)(?::(.+))$", url)
if name_override:
url = name_override.group(1)
name = name_override.group(2)
@@ -219,6 +225,8 @@ class Package(object):
url = "https://launchpad.net/%s/+download" % name
elif url == "GNOME-DEFAULT":
url = "http://download.gnome.org/sources/%s/*/" % name
+ elif url == "RUBYGEMS-DEFAULT":
+ url = "http://rubygems.org/api/v1/gems/%s.json" % name
self.__url = url
self.html = None