-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnome-maintainer
executable file
·1412 lines (1123 loc) · 48 KB
/
gnome-maintainer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
#
# Python script useful to maintainers.
# Copyright (C) 2006-2011 Martyn Russell <[email protected]>
#
# This script will:
# - Summarise bugs mentioned in the ChangeLog (from Bugzilla)
# - List translation updates
# - List bugs fixed
# - Output the summary and translations using a template (in HTML too)
# - Upload your tarball and install the module.
# - Create the email for you just to send it.
#
# Usage:
# - You should run this script from the directory of the project you maintain.
# - You need to specify a revision to compare the HEAD/TRUNK.
#
# Changes:
# - If you make _ANY_ changes, please send them in so I can incorporate them.
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import sys
import os
import string
import re
import urllib
import csv
import optparse
import time
import datetime
#import gnomevfs, gobject
import StringIO
import libxml2
from string import Template
# Script
script_name = 'Maintainer'
script_version = '0.10'
script_about = 'A script to do the laborious tasks when releasing a GNOME project.'
# Bugzilla Services used (comment out those unused for you)
bugzillas = {
'GNOME': {
'shortcut' : 'GB',
'url' : 'bugzilla.gnome.org',
'username' : None,
'password' : None,
'can_query' : True,
'service' : None
},
'Debian': {
'shortcut' : 'DB',
'url' : 'bugs.debian.org',
'username' : None,
'password' : None,
'can_query' : False,
'service' : None
},
'RedHat': {
'shortcut' : 'RH',
'url' : 'bugzilla.redhat.com',
'username' : None,
'password' : None,
'can_query' : False,
'service' : None
},
'FreeDesktop': {
'shortcut' : 'FD',
'url' : 'bugs.freedesktop.org',
'username' : None,
'password' : None,
'can_query' : False,
'service' : None
}
# 'Mozilla': {
# 'shortcut' : 'MB',
# 'url' : 'bugzilla.mozilla.org',
# 'username' : None,
# 'password' : None,
# 'can_query' : False,
# 'service' : None
# },
# 'Nokia': {
# 'shortcut' : 'NB',
# 'url' : 'projects.maemo.org/bugzilla',
# 'username' : None,
# 'password' : None,
# 'can_query' : False,
# 'service' : None
# }
}
# Translation directories
po_dir = 'po'
help_dir = 'help'
# Translator information template
translator_template = 'Updated $lang: $translator'
# Addresses
upload_server = 'master.gnome.org'
# Formatting
format_bullet = '*'
format_date = '%d %B %Y'
# Cached bug IDs to names
bug_names = {}
# Default templates
template = '''
What is it?
===========
$about
Where can I get it?
===================
Download $name $version from:
$download
$md5sums
What's new?
===========
The changes are:
$fixed
Translations:
$translations
Manual Translations:
$help_translations
--
$footer
'''
template_in_html = '''
<p>$name $version is now available for download from:</p>
<ul>
<li><a href="$download">$download</a></li>
</ul>
<p>$md5sums</p>
<h3>What is it?</h3>
<p>$about</p>
<h3>What's New</h3>
$news
<h3>Bugs Fixed</h3>
$fixed
<h3>Translations</h3>
$translations
<h3>Help Manual Translations</h3>
$help_translations
--
$footer
'''
template_update_news = '''
NEW in %s:
==============
%s
Translations:
%s
Help Manual Translations:
%s
'''
def debug(string):
if opts.debug:
print string
class BugzillaService:
def __init__(self, package_info, shortcut, name, url, username, password, can_query):
self.package_info = package_info
self.name = name
self.shortcut = shortcut
self.url = url
self.username = username
self.password = password
self.can_query = can_query
def ask(self, bugs, query, url, just_titles):
debug('Retrieving bug information for: %s...' % (bugs))
f = urllib.urlopen(query)
s = f.read()
f.close()
try:
doc = libxml2.parseDoc(s)
except:
return ''
root = doc.children
if root.name != "bugzilla":
return 'Response from %s Bugzilla was not good, ' \
'We should know better than to interface with public services :)' % (self.name)
summary = ''
for bug in doc.xpathEval('//bug'):
bug_id = bug.xpathEval('bug_id')[0].content
short_desc = bug.xpathEval('short_desc')[0].content
bug_status = bug.xpathEval('bug_status')[0].content
resolution_node = bug.xpathEval('resolution')
if resolution_node:
resolution = resolution_node[0].content
else:
resolution = 'NONE'
reporter_name_node = bug.xpathEval('reporter/@name')
if reporter_name_node:
reporter_name = reporter_name_node[0].content
else:
reporter_name = 'NONE'
assigned_to_node = bug.xpathEval('assigned_to/@name')
if assigned_to_node:
assigned_to = assigned_to_node[0].content
else:
assigned_to = 'NONE'
if not just_titles:
if summary != '':
summary += ' ----------------------------------------\n'
else:
summary = ''
link = '%s%s' % (url, bug_id)
summary += ' %s Bug #%s, %s\n' % (self.name, bug_id, short_desc)
summary += ' %s\n' % (link)
summary += ' Reporter: %s, Assigned to: %s\n' % (reporter_name, assigned_to)
summary += ' Status: %s, Resolution: %s\n' % (bug_status, resolution)
else:
summary += ' %s Fixes: %s#%s, %s\n' % (format_bullet, self.shortcut, bug_id, short_desc)
doc.freeDoc()
return summary
def generate_request(self, bug_list, just_titles):
if not bug_list:
return ''
if not self.can_query:
debug('Not retrieving bug information for bug list (disabled in config)')
summary = ''
for bug in bug_list.split(','):
summary += ' %s Fixes: %s#%s, \n' % (format_bullet, self.shortcut, bug)
return summary
if self.username and self.password:
query = 'https://%s:%s@%s/show_bug.cgi?ctype=xml;id=' % (self.username, self.password, self.url)
else:
query = 'https://%s/show_bug.cgi?ctype=xml;id=' % (self.url)
bugs = bug_list.split()[0]
s = bugs
s = s.replace(',', '%2c')
s = s.replace(self.shortcut + '#', '')
query = query + s
bug_url = 'https://%s/show_bug.cgi?id=' % (self.url)
debug('Using query "%s"' % (query))
return self.ask (bugs, query, bug_url, just_titles)
def get_summary(self, bug_list):
if len(bug_list) < 1:
return ''
return self.generate_request(bug_list, True)
def url_to_shortcut(self, string):
if string.find('bugzilla.gnome.org') > 0:
return 'GB#'
elif string.find('bugs.debian.org') > 0:
return 'DB#'
elif string.find('bugs.freedesktop.org') > 0:
return 'FD#'
elif string.find('bugzilla.redhat.com') > 0:
return 'RH#'
elif string.find('bugs.gentoo.org') > 0:
return 'GT#'
elif string.find('bugzilla.mozilla.org') > 0:
return 'MB#'
elif string.find('projects.maemo.org/bugzilla') > 0:
return 'NB#'
return None
def shortcut_to_url(self, string):
if string.find('GB#') > 0:
return 'bugzilla.gnome.org'
elif string.find('DB#') > 0:
return 'bugs.debian.org'
elif string.find('FD#') > 0:
return 'bugs.freedesktop.org'
elif string.find('RH#') > 0:
return 'bugzilla.redhat.com'
elif string.find('GT#') > 0:
return 'bugs.gentoo.org'
elif string.find('MB#') > 0:
return 'bugzilla.mozilla.org'
elif string.find('NB#') > 0:
return 'projects.maemo.org/bugzilla'
return None
class PackageInfo:
def __init__(self, version):
self.name = None
self.version = version
self.module = None
self.description = None
self.vc_command = None
self.vc_paramters = None
if os.path.exists('CVS'):
debug('Version control system is CVS')
self.vc_command = 'cvs'
self.vc_parameters = '-u'
elif os.path.exists('.svn'):
debug('Version control system is SVN')
self.vc_command = 'svn'
self.vc_parameters = ''
elif os.path.exists('.git'):
debug('Version control system is GIT')
self.vc_command = 'git'
self.vc_parameters = ''
else:
print 'Version control system unrecognised, not cvs or svn'
sys.exit(1)
# Get information from all sources
self.get_doap_info()
self.get_configh_info()
# Make sure we have everything we need, otherwise exit.
self.sanity_check()
def sanity_check(self):
if self.vc_command == None:
print 'Could not get version control system'
sys.exit(1)
if self.name == None:
print 'Could not get package name'
sys.exit(1)
if self.version == None:
print 'Could not get package version'
sys.exit(1)
if self.module == None:
print 'Could not get package module'
sys.exit(1)
def get_doap_info(self):
filename = None
for file in os.listdir("."):
if file.endswith(".doap"):
if filename != None:
print 'Multiple .doap files found, no way forward'
return
else:
filename = file
if filename == None:
print 'Could not find .doap file in current directory'
return
if not os.path.exists(filename):
print 'Could not find %s in current directory' % (filename)
return
f = open(filename, 'r')
s = f.read()
f.close()
key = {}
key['package'] = '<name'
key['version'] = '' # Not in DOAP file
key['bugreport'] = '<bug-database rdf:resource="'
key['description'] = '<description'
for line in s.splitlines(1):
if line.find(key['package']) > 0:
p2 = line.rfind('</name>')
p1 = line.find('>') + 1
st = line[p1:p2]
if len(st) > 0:
self.name = st
debug('Using "%s" as name from %s' % (st, filename))
elif line.find(key['bugreport']) > 0:
p2 = line.rfind('"')
p1 = line.rfind('=') + 1
st = line[p1:p2]
if len(st) > 0:
self.module = st
debug('Using "%s" as module from %s' % (st, filename))
elif line.find(key['description']) > 0:
p2 = line.rfind('</description>')
p1 = line.find('>') + 1
st = line[p1:p2]
if len(st) > 0:
self.description = st
debug('Using "%s" as description from %s' % (st, filename))
def get_configh_info(self):
filename = 'config.h'
if not os.path.exists(filename):
if not opts.package_version:
print 'Expected %s to exist, but it could not be found in current directory' % (filename)
return
f = open(filename, 'r')
s = f.read()
f.close()
key = {}
key['package'] = '#define PACKAGE_NAME "'
key['version'] = '#define PACKAGE_VERSION "'
key['bugreport'] = '#define PACKAGE_BUGREPORT "'
for line in s.splitlines(1):
if line.startswith(key['package']):
p1 = len(key['package'])
p2 = line.rfind('"')
st = line[p1:p2]
if len(st) > 0:
self.name = st
debug('Using "%s" as name %s' % (st, filename))
elif line.startswith(key['version']):
p1 = len(key['version'])
p2 = line.rfind('"')
st = line[p1:p2]
if len(st) > 0:
self.version = st
debug('Using "%s" as version %s' % (st, filename))
elif line.startswith(key['bugreport']):
p2 = line.rfind('"')
p1 = line.rfind('=') + 1
st = line[p1:p2]
if len(st) > 0:
self.module = st
debug('Using "%s" as module %s' % (st, filename))
def get_svn_root(self):
info = os.popen('svn info --xml').read()
key = '<root>'
start = info.find(key)
if start == -1:
print 'Could not get Root (start) for subversion details'
sys.exit(1)
start += len(key)
key = '</root>'
end = info.find(key, start)
if end == -1:
print 'Could not get Root (end) for subversion details'
sys.exit(1)
return info[start:end]
def get_svn_url(self):
info = os.popen('svn info --xml').read()
key = '<url>'
start = info.find(key)
if start == -1:
print 'Could not get URL (start) for subversion details'
sys.exit(1)
start += len(key)
key = '</url>'
end = info.find(key, start)
if end == -1:
print 'Could not get URL (end) for subversion details'
sys.exit(1)
return info[start:end]
def get_bugs(service, tag):
who_exp = ''
# Commands to get change set
if pi.vc_command == 'cvs':
cmd = '%s diff %s -r %s ChangeLog' % (pi.vc_command, pi.vc_parameters, tag)
elif pi.vc_command == 'svn':
url = get_svn_url()
root = get_svn_root()
revision = "%s/tags/%s" % (root, tag)
debug('Using SVN root: %s...' % (root))
debug('Using SVN diff url1: %s...' % (url))
debug('Using SVN diff url2: %s...' % (revision))
cmd = '%s diff %s %s/ChangeLog %s/ChangeLog' % (pi.vc_command, pi.vc_parameters, revision, url)
elif pi.vc_command == 'git':
cmd = '%s %s log %s..HEAD' % (pi.vc_command, pi.vc_parameters, tag)
# Regular expressions need to get details
if pi.vc_command == 'cvs' or pi.vc_command == 'svn':
who_exp = '^\+(?P<date>[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]) ' \
'(?P<name>.*) <*@*>*'
bug_exp = '.*#(?P<bug>[0-9]+)(.*\((?P<name>.*)\))?'
elif pi.vc_command == 'git':
who_exp = '^Author: (?P<name>.*) <*@*>*'
bug_exp = '.*(?P<repo>((bug |GB#|DB#|NB#|FD#|RH#|GT#|MB#)|(http(s)?[:][/][/].*?(id|bug)[=])))(?P<bug>[0-9]+)(.*\((?P<name>.*)\))?'
bugs = ''
# Pattern to match ChangeLog entry
changelog_pattern = re.compile(who_exp, re.S | re.M)
# Pattern to match bug fixers name, e.g.: "#123456 (Martyn Russell)"
bugfix_pattern = re.compile(bug_exp, re.S | re.M | re.I)
pos = 0
changes = os.popen(cmd).read()
while not pos == -1:
start = pos
# Find end of first line
end = changes.find('\n', pos)
line = changes[pos:end]
pos = end + 1
# Try and get the second line
end = changes.find('\n', pos)
if not end == -1:
line = changes[start:end]
if len(line) < 1:
break
# Check this is a change
if not pi.vc_command == 'git' and not line[0] == '+':
continue
# Get committer details
match = changelog_pattern.match(line)
if match:
last_committer = match.group('name')
continue
# Get bug fix details
match = bugfix_pattern.match(line)
if not match:
continue
bug = match.group('bug')
name = match.group('name')
repo = match.group('repo')
if len(repo) > 3:
repo_shortcut = service.url_to_shortcut(repo)
else:
repo_shortcut = repo
if repo_shortcut == None:
debug('Repository was unrecognised from URL %s' % (repo))
continue
# Don't include the end '#' in repo in comparison
if service.shortcut != None and service.shortcut != repo_shortcut[:-1]:
continue
if bug == '':
continue
if name == None:
name = last_committer.strip()
else:
name = name.replace('\n', '')
name = name.replace('\t', '')
name = name.replace('+', ' ')
name = name.strip()
repo_lower = repo.lower()
if repo_lower == 'bug ':
repo = 'GB#'
else:
repo = repo.upper()
# Set name for bug
bug_names[bug] = name
if bugs.find(bug) > -1:
continue
# Add bug to list
if not bugs == '':
bugs = bugs + ','
bugs += bug
return bugs
def get_last_translator(lang, dir):
exp = '["]Last[-]Translator[:] (?P<name>.*?)( *[<].*[>]*)?\n'
trans_pattern = re.compile(exp)
file = os.path.join (dir, lang + ".po")
debug(' Trying to open PO file "%s"....' % (file))
try:
f = open(file, 'r')
except IOError, (errno, strerror):
# If this fails, we try to use the 'dir/lang/lang.po' for help PO files
file = os.path.join (dir, lang, lang + ".po")
debug('Trying to open PO file "%s"....' % (file))
try:
f = open(file, 'r')
except IOError, (errno, strerror):
return ''
translator = ''
line = f.readline()
while translator == '' and line != '':
match = trans_pattern.match (line)
if not match:
line = f.readline()
continue
translator = match.group ('name')
if translator != '':
translator = translator.strip()
f.close()
return translator
def get_translators(pi, type, tag, dir):
translators = {}
if not os.path.exists(dir):
return None
if pi.vc_command == 'cvs':
cmd = '%s diff -u -r %s %s/ChangeLog' % (pi.vc_command, tag, dir)
# Set changelog format for getting name
who_exp = '^\+(?P<date>[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]) ' \
'(?P<name>.*) <*@*>*'
lang_exp = '.*\* (.*/)?(?P<lang>.*).po: ((.*) by (?P<name>[^.]*)\.?)?'
# Pattern to match ChangeLog entry
changelog_pattern = re.compile(who_exp, re.S | re.M)
# Pattern to match language and sponsored name for change, e.g.:
# "en_GB.po: Updated by Martyn Russell"
lang_pattern = re.compile(lang_exp, re.S | re.M)
elif pi.vc_command == 'svn':
url = pi.get_svn_url()
root = pi.get_svn_root()
revision = "%s/tags/%s" % (root, tag)
debug('Using SVN root: %s...' % (root))
debug('Using SVN diff url1: %s...' % (url))
debug('Using SVN diff url2: %s...' % (revision))
cmd = '%s diff %s %s/%s/ChangeLog %s/%s/ChangeLog' % (pi.vc_command, pi.vc_parameters, revision, dir, url, dir)
# Set changelog format for getting name
who_exp = '^\+(?P<date>[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]) ' \
'(?P<name>.*) <*@*>*'
lang_exp = '.*\* (.*/)?(?P<lang>.*).po: ((.*) by (?P<name>[^.]*)\.?)?'
# Pattern to match ChangeLog entry
changelog_pattern = re.compile(who_exp, re.S | re.M)
# Pattern to match language and sponsored name for change, e.g.:
# "en_GB.po: Updated by Martyn Russell"
lang_pattern = re.compile(lang_exp, re.S | re.M)
if not pi.vc_command == 'git':
pos = 0
changes = os.popen(cmd).read()
while not pos == -1:
start = pos
# Find end of first line
end = changes.find('\n', pos)
line = changes[pos:end]
pos = end + 1
# Try and get the second line
end = changes.find('\n', pos)
if not end == -1:
line = changes[start:end]
if len(line) < 1:
break
# Check this is a change
if not line[0] == '+':
continue
# Get committer details
match = changelog_pattern.match(line)
if match:
last_committer = match.group('name')
#date = match.group('date')
continue
# Get bug fix details
match = lang_pattern.match(line)
if not match:
continue
lang = match.group('lang')
name = match.group('name')
if lang == '':
continue
# Get last translator from .po file
last_translator = get_last_translator (lang, dir)
debug('Found lang "%s" with last translator "%s"' % (lang, last_translator))
if last_translator != '':
if translators.has_key (lang):
if translators[lang].find (last_translator) == -1:
translators[lang] += ', ' + last_translator
else:
translators[lang] = last_translator
if name == None:
name = last_committer.strip()
#if opts.debug:
# print 'Found lang "%s" with last committer "%s" on "%s"' % (lang, name, date)
else:
name = name.replace('\n', '')
name = name.replace('\t', '')
name = name.replace('+', ' ')
name = name.strip()
debug('Found lang "%s" with last committer "%s" **' % (lang, name))
if last_translator != '':
if translators.has_key (lang):
if translators[lang].find (last_translator) == -1:
translators[lang] += ', ' + last_translator
else:
translators[lang] = last_translator
if translators.has_key(lang):
if translators[lang].find(name) > -1:
continue;
translators[lang] += ', ' + name
else:
translators[lang] = name
else:
cmd = 'git diff-tree --name-only -r %s.. %s/*.po' % (tag, dir)
text = os.popen(cmd).read()
file_exp = '^%s/(?P<lang>.*).po' % (dir)
file_pattern = re.compile(file_exp, re.S | re.M)
for line in text.splitlines():
match = file_pattern.match(line)
if not match:
continue
lang = match.group('lang')
if lang == '':
continue
debug('Found lang %s' % (lang))
cmd = 'git log --pretty=format:"%%an" %s.. -- %s/%s.po' % (tag, dir, lang)
who = os.popen(cmd).read()
names = who.split('\n')
for name in names:
debug(' Found "%s"' % (name))
if len(name) < 1:
continue
if translators.has_key(lang):
if translators[lang].find(name) > -1:
continue
translators[lang] += ', ' + name
else:
translators[lang] = name
# Get last translator from .po file
last_translator = get_last_translator (lang, dir)
debug(' Last translator "%s"' % (last_translator))
if len(last_translator) < 1:
continue
if translators.has_key(lang):
if translators[lang].find(last_translator) > -1:
continue
translators[lang] += ', ' + last_translator
else:
translators[lang] = last_translator
summary = ''
if opts.html:
summary += '<ul>'
sorted_langs = translators.keys ()
sorted_langs.sort ()
for lang in sorted_langs:
if len(summary) > 0:
summary += '\n'
t = Template(translator_template)
text = t.substitute (translator = translators[lang], lang = lang)
if opts.html:
summary += '<li>%s</li>' % (text)
else:
summary += ' %s %s' % (format_bullet, text)
if opts.html:
summary += '\n</ul>'
if len(summary) < 1:
return None
return summary
def get_description(pi):
debug('Retrieving product descripton for %s ...' % (pi.name))
if pi.description != None:
return pi.description
query = 'https://bugzilla.gnome.org/browse.cgi?product=%s' % (pi.name)
f = urllib.urlopen(query)
s = f.read()
f.close()
if len(s) < 1:
return ''
#
# HACK ALERT! HACK ALERT!
#
# This is likely to change if the Bugzilla page formatting changes, so
# we put a lot of debugging in here.
s1 = '<p><i>'
i = s.find(s1)
if i == -1:
debug('Could not find string "%s"' % (s1))
return ''
start = i + len(s1)
s2 = '</i></p>'
end = s.find(s2, i + 1)
if end == -1:
debug('Could not find string "%s"' % (s2))
return ''
# Set description
pi.desciption = s[start:end]
return pi.desciption
def get_default_template():
if opts.html:
return template_in_html
return template
def get_news():
f = open ('NEWS', 'r')
s = f.read()
f.close()
start = s.find ('NEW in '+ pi.version)
start = s.find ('\n', start) + 1
start = s.find ('\n', start) + 1
end = s.find ('NEW in', start) - 1
return s[start:end]
def create_release_note(service, tag, template_file):
# Open template file
if template_file == '' or template_file == 'DEFAULT':
debug('Using DEFAULT template')
s = get_default_template()
else:
debug('Using template file "%s"' % (template_file))
f = open(template_file, 'r')
s = f.read()
f.close()
if len(s) < 1:
print 'Template file was empty or does not exist'
sys.exit(1)
# Check we have everything
if s.find('$download') == -1:
print 'Could not find "$download" in template'
sys.exit(1)
#if s.find('$news') == -1:
# print 'Could not find "$news" in template'
# sys.exit(1)
if s.find('$fixed') == -1:
print 'Could not find "$fixed" in template'
sys.exit(1)
if s.find('$translations') == -1:
print 'Could not find "$translations" in template'
sys.exit(1)
if s.find('$help_translations') == -1:
print 'Could not find "$help_translations" in template'
sys.exit(1)
# Get date for footer
today = datetime.date.today()
date = today.strftime(format_date)
# Set up variables
name = pi.name # Needed for template
version = pi.version # Needed for template
# FIXME: Get ALL bugs,
bugs_gb = get_bugs(service, tag)
bugs_nb = ''
download = 'http://download.gnome.org/sources/%s/%s/' % (pi.name.lower(),
pi.version)
# Get an MD5 sum of the tarballs.
md5sums = ''
tarball = '%s-%s.tar.gz' % (pi.name.lower(), pi.version)
if not os.path.exists(tarball):
print 'Tarball does not exist, could not find %s' % (tarball)
sys.exit(1)
cmd = 'md5sum %s' % (tarball)
md5sums += os.popen(cmd).read()
#cmd = 'md5sum %s-%s.tar.bz2' % (pi.name.lower(), pi.version)
#md5sums += os.popen(cmd).read()
if opts.html:
md5sums = md5sums.replace('\n', '<br>\n')
about = get_description(pi)