/[gentoo]/src/packages/changelogs.py
Gentoo

Diff of /src/packages/changelogs.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1.1.1 Revision 1.6
1#!/usr/bin/python -OO 1#
2# Copyright (C) 2003-2005, marduk <marduk@python.net>
3#
4# This copyrighted material is made available to anyone wishing to use,
5# modify, copy, or redistribute it subject to the terms and conditions
6# of the GNU General Public License v.2.
7#
8# You should have received a copy of the GNU General Public License
9# along with this program; if not, write to the Free Software Foundation,
10# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11#
12"""Module to deal with Changelog files in the portage tree"""
2 13
3import mstring 14import mstring
4import re 15import re
16from cgi import escape
5 17
18#BUG_REGEX = re.compile(r'#[0-9]+|bug [0-9]+',re.I)
19BUG_REGEX = re.compile(r'((\B#|\bbug )([0-9]+))', re.I)
20DATE_REGEX = re.compile(
21 r'[0-9]{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{4}[;:]',
22 re.M)
23GENTOO_DEV = re.compile(r'&lt;((.+))@gentoo.org&gt;', re.I)
24BUG_URL = 'http://bugs.gentoo.org/show_bug.cgi?id='
25CIA_URL = 'http://cia.navi.cx/stats/author/'
6 26
7BUG_REGEX = re.compile(r'#[0-9]+|bug [0-9]+',re.I)
8BUG_URL = 'http://bugs.gentoo.org/show_bug.cgi?id='
9
10def bugs_to_html(s): 27def bugs_to_html(string):
11 index = 1 28 """Convert bug #'s to html, escape other html text"""
12 while 1: 29 string = string.strip()
30 string = escape(string)
31 index = 0
32 string = BUG_REGEX.sub('<a href="%s\\3">\\1</a>' % BUG_URL, string)
13 match = BUG_REGEX.search(s,index) 33 match = DATE_REGEX.search(string, index)
14 if not match: 34 if match:
15 break
16 start = match.start() 35 start = match.start()
17 end = match.end() 36 next = DATE_REGEX.search(string, match.end() + 1)
37 if next:
38 end = next.start() - 1
39 else:
40 end = len(string)
18 substring = s[start:end] 41 substring = string[start:end]
19 if substring[0] == '#': # this of the form "#1234" 42 html = '<span class="change"><span class="date">%s</span>%s</span>' % \
20 bugid = substring[1:] 43 (substring[:11], substring[11:])
21 else: # this is of the form "bug 1234" 44 (string, index) = mstring.replace_sub(string[:end+1], html, start, end)
22 bugid = substring[4:] 45 string = GENTOO_DEV.sub('(<a href="%s\\2">\\1</a>)' % CIA_URL, string)
23 url = '<a href="%s%s">%s</a>' % (BUG_URL,bugid,substring) 46 return '<span class="change">%s\n\n</span>' % string
24 (s,index) = mstring.replace_sub(s,url,start,end-1)
25 return s
26 47
27def changelog(filename): 48def changelog(filename):
28 try: 49 try:
29 #print filename 50 #print filename
30 fp = open(filename,'r') 51 fp = open(filename,'r')

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.20