Gentoo Archives: gentoo-commits

From: "Markos Chandras (hwoarang)" <hwoarang@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in src/gwn: gwn_adds_removes.py
Date: Sat, 05 Oct 2013 15:15:44
Message-Id: 20131005151541.303142004C@flycatcher.gentoo.org
1 hwoarang 13/10/05 15:15:41
2
3 Modified: gwn_adds_removes.py
4 Log:
5 gwn_adds_removes.py: Update and clean up
6
7 Move away from GuideXML specific code and remove noise.
8 Fix a couple of prolems with parsing the list of developers and drop
9 the --attic option. We will always use hyperlinks even for dead packages
10
11 Revision Changes Path
12 1.6 src/gwn/gwn_adds_removes.py
13
14 file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/gwn_adds_removes.py?rev=1.6&view=markup
15 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/gwn_adds_removes.py?rev=1.6&content-type=text/plain
16 diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/gwn_adds_removes.py?r1=1.5&r2=1.6
17
18 Index: gwn_adds_removes.py
19 ===================================================================
20 RCS file: /var/cvsroot/gentoo/src/gwn/gwn_adds_removes.py,v
21 retrieving revision 1.5
22 retrieving revision 1.6
23 diff -u -r1.5 -r1.6
24 --- gwn_adds_removes.py 15 Mar 2008 11:09:47 -0000 1.5
25 +++ gwn_adds_removes.py 5 Oct 2013 15:15:41 -0000 1.6
26 @@ -8,9 +8,9 @@
27 OUTPUT_CHARSET = 'utf-8'
28
29 def parse(logfile):
30 -
31 +
32 # Read the log file
33 -
34 +
35 pkgs = {'added': [], 'removed': []}
36 log = open(logfile)
37 for i in log:
38 @@ -24,9 +24,9 @@
39 else:
40 cur.append(i)
41 log.close()
42 -
43 +
44 # Parse the information
45 -
46 +
47 for op in ('added', 'removed'):
48 for idx, pkg in enumerate(pkgs[op]):
49 pkg = pkg.split(',')
50 @@ -34,74 +34,46 @@
51 dev = pkg[2]
52 dt = datetime(*(time.strptime(pkg[3], '%Y-%m-%d %H:%M:%S')[0:6]))
53 pkgs[op][idx] = (cp, dev, dt)
54 -
55 +
56 return pkgs
57
58 def developers():
59 -
60 +
61 html = urllib2.urlopen(DEV_LIST).read()
62 doc = libxml2.htmlParseDoc(html, 'utf-8')
63 rows = doc.xpathEval('//table[@class = "ntable"]/tr')
64 devs = {}
65 -
66 +
67 for i in rows[1:]:
68 - ths = i.xpathEval('th/b')
69 tds = i.xpathEval('td')
70 - devs[ths[0].content] = tds[0].content.decode('utf-8')
71 -
72 + devs[tds[0].content] = tds[0].content.decode('utf-8')
73 +
74 doc.freeDoc()
75 return devs
76 -
77
78 -def write(data, devs, attic=False):
79 -
80 +
81 +def write(data, devs):
82 +
83 sections = {'added': 'Addition', 'removed': 'Removal'}
84 for s in sections:
85 -
86 - print '<section>'
87 - print '<title>%s:</title>' % (sections[s] + 's')
88 - print '<body>'
89 - print ''
90 -
91 - print '<table>'
92 - print ''
93 - print '<tr>'
94 - print '<th>Package:</th>'
95 - print '<th>%s date:</th>' % sections[s]
96 - print '<th>Contact:</th>'
97 - print '</tr>'
98 - print ''
99 -
100 for pkg in data[s]:
101 - print '<tr>'
102 ldata = (PACKAGE_LINK % pkg[0], '/'.join(pkg[0]))
103 if s == 'added':
104 - print '<ti><uri link="%s">%s</uri></ti>' % ldata
105 + what = "added"
106 else:
107 - if attic:
108 - ldata = (ATTIC_LINK % pkg[0], '/'.join(pkg[0]))
109 - print '<ti><uri link="%s">%s</uri></ti>' % ldata
110 - else:
111 - print '<ti>%s</ti>' % ldata[1]
112 - print '<ti>%s</ti>' % pkg[2].strftime('%d %b %Y')
113 - mdata = (pkg[1], devs[pkg[1]].encode(OUTPUT_CHARSET))
114 - print '<ti><mail link="%s@g.o">%s</mail></ti>' % mdata
115 - print '</tr>'
116 - print ''
117 -
118 - print '</table>'
119 - print ''
120 -
121 - print '</body>'
122 - print '</section>'
123 - print ''
124 -
125 + what = "removed"
126 + ldata = (ATTIC_LINK % pkg[0], '/'.join(pkg[0]))
127 + #who = (devs[pkg[1]].encode(OUTPUT_CHARSET), pkg[1])
128 + who = devs[pkg[1]]
129 + when = pkg[2].strftime('%d %b %Y')
130 + # You should copy this to the raw html code in the
131 + # blog post
132 + print '<a href="%s">%s</a> %s by %s on %s' % (ldata[0], ldata[1], what, who,when)
133
134 if __name__ == '__main__':
135 - if len(sys.argv) < 2 or len(sys.argv) > 3:
136 - print 'Usage: gwn_adds_removes.py <log-file> [--attic]'
137 + if len(sys.argv) != 2:
138 + print 'Usage: gwn_adds_removes.py <log-file>'
139 else:
140 data = parse(sys.argv[1])
141 devs = developers()
142 - attic = len(sys.argv) == 3 and sys.argv[2] == '--attic'
143 - write(data, devs, attic)
144 + write(data, devs)