/[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 Revision 1.2
2 2
3import mstring 3import mstring
4import re 4import re
5 5
6 6
7BUG_REGEX = re.compile(r'#[0-9]+|bug [0-9]+',re.I) 7BUG_REGEX = re.compile(r'\b#[0-9]+|\bbug [0-9]+',re.I)
8BUG_URL = 'http://bugs.gentoo.org/show_bug.cgi?id=' 8BUG_URL = 'http://bugs.gentoo.org/show_bug.cgi?id='
9 9
10def bugs_to_html(s): 10def bugs_to_html(s):
11 index = 1 11 index = 1
12 while 1: 12 while 1:
13 match = BUG_REGEX.search(s,index) 13 match = BUG_REGEX.search(s,index)
14 if not match: 14 if not match:
15 break 15 break
16 start = match.start() 16 start = match.start()
17 end = match.end() 17 end = match.end()
18 substring = s[start:end] 18 substring = s[start:end]
19 if substring[0] == '#': # this of the form "#1234" 19 if substring[0] == '#': # this of the form "#1234"
20 bugid = substring[1:] 20 bugid = substring[1:]
21 else: # this is of the form "bug 1234" 21 else: # this is of the form "bug 1234"
22 bugid = substring[4:] 22 bugid = substring[4:]
23 url = '<a href="%s%s">%s</a>' % (BUG_URL,bugid,substring) 23 url = '<a href="%s%s">%s</a>' % (BUG_URL,bugid,substring)
24 (s,index) = mstring.replace_sub(s,url,start,end-1) 24 (s,index) = mstring.replace_sub(s,url,start,end-1)
25 return s 25 return s
26 26
27def changelog(filename): 27def changelog(filename):
28 try: 28 try:
29 #print filename 29 #print filename
30 fp = open(filename,'r') 30 fp = open(filename,'r')
31 except IOError: 31 except IOError:
32 return "" 32 return ""
33 33
34 34
35 s = "" 35 s = ""
36 # find first line that isn't blank or a comment 36 # find first line that isn't blank or a comment
37 while True: 37 while True:
38 line = fp.readline() 38 line = fp.readline()
39 if not line: break 39 if not line: break
40 #print line 40 #print line
41 if line[0] not in ['#','','\n']: 41 if line[0] not in ['#','','\n']:
42 s = s + line 42 s = s + line
43 break 43 break
44 44
45 # append next strings until you reach next "*" 45 # append next strings until you reach next "*"
46 while True: 46 while True:
47 line = fp.readline() 47 line = fp.readline()
48 #print repr(line) 48 #print repr(line)
49 if not line or line[0] == '*': break 49 if not line or line[0] == '*': break
50 else: s= s + line 50 else: s= s + line
51 51
52 return s 52 return s

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20