/[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.2.2.2 Revision 1.2.2.3
9# along with this program; if not, write to the Free Software Foundation, 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 10# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11# 11#
12"""Module to deal with Changelog files in the portage tree""" 12"""Module to deal with Changelog files in the portage tree"""
13 13
14from packages import mstring
15import re 14import re
16from cgi import escape 15from cgi import escape
17 16
18#BUG_REGEX = re.compile(r'\B#[0-9]+|\bbug [0-9]+', re.I)
19BUG_REGEX = re.compile(r'((\B#|\bbug )([0-9]+))', re.I) 17BUG_REGEX = re.compile(r'((\B#|\bbug )([0-9]+))', re.I)
20DATE_REGEX = re.compile( 18DATE_REGEX = re.compile(r"""
21 r'[0-9]{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{4}[;:]', 19 (
22 re.M) 20 [0-9]{2}\s # Day
21 (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s # Month
22 [0-9]{4} # Year
23 )
24 [;:]""",
25 re.M|re.VERBOSE)
23GENTOO_DEV = re.compile(r'<((.+))@gentoo.org>', re.I) 26GENTOO_DEV = re.compile(r'<((.+))@gentoo.org>', re.I)
24 27
25def bugs_to_html(string): 28def bugs_to_html(string):
26 """Convert bug #'s to html, escape other html text""" 29 """Convert bug #'s to html, escape other html text"""
27 string = string.strip() 30 string = string.strip()
28 string = escape(string) 31 string = escape(string)
29## index = 1
30## while 1:
31## match = BUG_REGEX.search(string, index)
32## if not match:
33## break
34## start = match.start()
35## end = match.end()
36## substring = string[start:end]
37## if substring[0] == '#': # this of the form "#1234"
38## bugid = substring[1:]
39## else: # this is of the form "bug 1234"
40## bugid = substring[4:]
41## url = '<a href="/bugs/%s">%s</a>' % (bugid, substring)
42## (string, index) = mstring.replace_sub(string, url, start , end-1)
43 index = 0
44 string = BUG_REGEX.sub(r'<a href="/bugs/\3">\1</a>', string) 32 string = BUG_REGEX.sub(r'<a href="/bugs/\3">\1</a>', string)
45 match = DATE_REGEX.search(string, index) 33 match = DATE_REGEX.search(string)
46 if match: 34 if match:
47 start = match.start() 35 start = match.start()
48 next = DATE_REGEX.search(string, match.end() + 1) 36 next = DATE_REGEX.search(string, match.end() + 1)
49 if next: 37 if next:
50 end = next.start() - 1 38 end = next.start() - 1
51 else: 39 else:
52 end = len(string) 40 end = len(string)
53 substring = string[start:end] 41 string = string[start:end]
54 html = '<span class="change"><span class="date">%s</span>%s</span>' % \ 42 string = DATE_REGEX.sub(r'<span class="date">\1</span>: ', string)
55 (substring[:11], substring[11:])
56 (string, index) = mstring.replace_sub(string[:end+1], html, start, end)
57 #s = '<ul>' + s + '</ul>\n'
58 # convert email address to links to CIA stats
59 string = GENTOO_DEV.sub(r'(<a href="/stats/\2">\1</a>)', string) 43 string = GENTOO_DEV.sub(r'(<a href="/stats/\2">\1</a>)', string)
60 return string 44 return '<span class="change">%s</span>' % string
61 45
62def changelog(filename): 46def changelog(filename):
63 """(Try to) Extract only the most recent bits from a changelog file""" 47 """(Try to) Extract only the most recent bits from a changelog file"""
64 try: 48 try:
65 #print filename 49 #print filename

Legend:
Removed from v.1.2.2.2  
changed lines
  Added in v.1.2.2.3

  ViewVC Help
Powered by ViewVC 1.1.20