From f4295044c4ae0c7f3b58e2ff5a195fc21051c0f9 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 14 Feb 2014 18:40:43 +0100 Subject: Add GITHUB-TAGS alias Proposed by Christopher Meng --- cnucnu/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cnucnu/__init__.py b/cnucnu/__init__.py index 0c817cb..8c67f94 100644 --- a/cnucnu/__init__.py +++ b/cnucnu/__init__.py @@ -53,6 +53,10 @@ ALIASES = { "regex": '([^<]*)', "url": "http://freshmeat.net/projects/{name}", }, + "GITHUB-TAGS": { + "url": "https://api.github.com/repos/{name}/tags", + "regex": '"name":\s*"([\d\.]+)"', + }, "GNU-DEFAULT": { "url": "http://ftp.gnu.org/gnu/{name}/" }, @@ -140,8 +144,10 @@ def unalias(name, value, what): format_values = {"name": re.escape(name), "raw_name": re.escape(raw_name)} elif what == "url": - format_values = {"name": urllib.quote(name, safe=""), - "raw_name": urllib.quote(raw_name, safe="")} + # Slashes need to be allowed for GITHUB alias and should not cause + # be used/cause trouble for other packages + format_values = {"name": urllib.quote(name, safe="/"), + "raw_name": urllib.quote(raw_name, safe="/")} else: raise NotImplementedError("what needs ot be 'regex' or 'url'") -- cgit