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

Contents of /src/packages/changelogs.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download) (as text)
Tue Oct 4 01:36:27 2005 UTC (8 years, 6 months ago) by marduk
Branch: MAIN
CVS Tags: release_1-5
Changes since 1.2: +39 -39 lines
File MIME type: text/x-python
* fixed regex for finding bug #'s
* fixes to bugs_to_html()

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

  ViewVC Help
Powered by ViewVC 1.1.20