Merge lp://staging/~rainct/terminator/lp-branch-links into lp://staging/terminator/trunk

Proposed by Siegfried Gevatter
Status: Merged
Merged at revision: 801
Proposed branch: lp://staging/~rainct/terminator/lp-branch-links
Merge into: lp://staging/terminator/trunk
Diff against target: 39 lines (+13/-4)
1 file modified
terminatorlib/terminatorterm.py (+13/-4)
To merge this branch: bzr merge lp://staging/~rainct/terminator/lp-branch-links
Reviewer Review Type Date Requested Status
Chris Jones (community) Approve
Terminator Pending
Review via email: mp+16668@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote :

- Recognize lp:<branch> links
- Improve the apturl regex to avoid bad matches.

Revision history for this message
Chris Jones (cmsj) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'terminatorlib/terminatorterm.py'
2--- terminatorlib/terminatorterm.py 2009-12-24 11:59:41 +0000
3+++ terminatorlib/terminatorterm.py 2009-12-30 01:36:19 +0000
4@@ -381,10 +381,13 @@
5 url = 'ftp://' + url
6 elif match == self.matches['addr_only']:
7 url = 'http://' + url
8- elif match == self.matches['launchpad']:
9+ elif match == self.matches['launchpad-bug']:
10 for item in re.findall(r'[0-9]+',url):
11 url = 'https://bugs.launchpad.net/bugs/%s' % item
12 return url
13+ elif match == self.matches['launchpad-branch']:
14+ url = url[3:] if url.startswith('lp:') else url
15+ url = 'https://code.launchpad.net/+branch/%s' % url
16 elif match == self.matches['apturl']:
17 # xdg-open will work as-is with apt: URLs
18 pass
19@@ -632,11 +635,17 @@
20 self.matches['addr_only'] = self._vte.match_add (lboundry + "(www|ftp)[" + hostchars + "]*\.[" + hostchars + ".]+(:[0-9]+)?(" + urlpath + ")?" + rboundry + "/?")
21 self.matches['email'] = self._vte.match_add (lboundry + "(mailto:)?[a-zA-Z0-9][a-zA-Z0-9.+-]*@[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z0-9][a-zA-Z0-9-]+[.a-zA-Z0-9-]*" + rboundry)
22 self.matches['nntp'] = self._vte.match_add (lboundry + '''news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@[-A-Za-z0-9.]+(:[0-9]+)?''' + rboundry)
23+ self.matches['apturl'] = self._vte.match_add ('\\bapt:/?/?\w+\\b') # apt+http isn't supported
24 # if the url looks like a Launchpad changelog closure entry LP: #92953 - make it a url to http://bugs.launchpad.net
25 # the regular expression is similar to the perl one specified in the Ubuntu Policy Manual - /lp:\s+\#\d+(?:,\s*\#\d+)*/i
26- self.matches['launchpad'] = self._vte.match_add ('\\b(lp|LP):?\s?#?[0-9]+(,\s*#?[0-9]+)*\\b')
27-
28- self.matches['apturl'] = self._vte.match_add ('\\bapt.*\\b')
29+ self.matches['launchpad-bug'] = self._vte.match_add ('\\b(lp|LP):?\s?#?[0-9]+(,\s*#?[0-9]+)*\\b')
30+ # same for Bazaar branches hosted on Launchpad
31+ lpfilters = {}
32+ lpfilters['project'] = '[a-z0-9]{1}[a-z0-9\.\-\+]+'
33+ lpfilters['group'] = '~%s' % lpfilters['project']
34+ lpfilters['series'] = lpfilters['project']
35+ lpfilters['branch'] = '[a-zA-Z0-9]{1}[a-zA-Z0-9_+@.-]+'
36+ self.matches['launchpad-branch'] = self._vte.match_add ('\\b((lp|LP):%(project)s(/%(series)s)?|(lp|LP):%(group)s/(%(project)s|\+junk)/%(branch)s)\\b' % lpfilters)
37
38 def _path_lookup(self, command):
39 if os.path.isabs (command):