added Roger Meyer to the credits
[friendica.git/.git] / bin / dev / make_credits.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 """
5 This script will collect the contributors to friendica and its translations from
6   * the git log of the friendica core and addons repositories
7   * the translated messages.po from core and the addons.
8 The collected names will be saved in CREDITS.txt which is also parsed from
9 yourfriendica.tld/credits.
10
11 The output is not perfect, so remember to open a fresh (re)created credits.txt file
12 in your fav editor to check for obvious mistakes and doubled entries.
13
14 Initially written by Tobias Diekershoff for the Friendica Project. Released under
15 the terms of the AGPL version 3 or later, same as Friendica.
16 """
17
18 from sys import argv
19 import os, glob, subprocess
20
21 #  a list of names to not include, those people get into the list by other names
22 #  but they use different names on different systems and automatical mapping does
23 #  not work in some cases.
24 dontinclude = ['root', 'friendica', 'bavatar', 'tony baldwin', 'Taek', 'silke m',
25                'leberwurscht', 'abinoam', 'fabrixxm', 'FULL NAME', 'Hauke Zuehl',
26                'Michal Supler', 'michal_s', 'Manuel Pérez', 'rabuzarus',
27                'Alberto Díaz', 'hoergen oostende', 'Friendica', 'vinzv',
28                'Vincent Vindarel']
29
30
31 #  this script is in the /bin/dev directory of the friendica installation
32 #  so the friendica path is the 0th argument of calling this script but we
33 #  need to remove the name of the file and the name of the directory
34 path = os.path.abspath(argv[0].split('bin/dev/make_credits.py')[0])
35 print('> base directory is assumed to be: '+path)
36 #  a place to store contributors
37 contributors = ["Andi Stadler", "Ratten", "Roger Meyer", "Vít Šesták 'v6ak'"]
38 #  get the contributors
39 print('> getting contributors to the friendica core repository')
40 p = subprocess.Popen(['git', 'shortlog', '--no-merges', '-s'],
41                          stdout=subprocess.PIPE,
42                          stderr=subprocess.STDOUT)
43 c = iter(p.stdout.readline, b'')
44 for i in c:
45     name = i.decode().split('\t')[1].split('\n')[0]
46     if not name in contributors and name not in dontinclude:
47         contributors.append(name)
48 n1 = len(contributors)
49 print('  > found %d contributors' % n1)
50 #  get the contributors to the addons
51 try:
52     os.chdir(path+'/addon')
53     #  get the contributors
54     print('> getting contributors to the addons')
55     p = subprocess.Popen(['git', 'shortlog', '--no-merges', '-s'],
56                              stdout=subprocess.PIPE,
57                              stderr=subprocess.STDOUT)
58     c = iter(p.stdout.readline, b'')
59     for i in c:
60         name = i.decode().split('\t')[1].split('\n')[0]
61         if not name in contributors and name not in dontinclude:
62             contributors.append(name)
63 except FileNotFoundError:
64     print('  > no addon directory found ( THE LIST OF CONTRIBUTORS WILL BE INCOMPLETE )')
65 n2 = len(contributors)
66 print('  > found %d new contributors' % (n2-n1))
67 print('> total of %d contributors to the repositories of friendica' % n2)
68 os.chdir(path)
69 #  get the translators
70 print('> getting translators')
71 intrans = False
72 for f in glob.glob(path+'/view/lang/*/messages.po'):
73     i = open(f, 'r')
74     l = i.readlines()
75     i.close()
76     for ll in l:
77         if intrans and ll.strip()=='':
78             intrans = False;
79         if intrans and ll[0]=='#':
80             name = ll.split('# ')[1].split(',')[0].split(' <')[0]
81             if not name in contributors and name not in dontinclude:
82                 contributors.append(name)
83         if "# Translators:" in ll:
84             intrans = True
85 #  get the translators from the addons
86 for f in glob.glob(path+'/addon/*/lang/*/messages.po'):
87     i = open(f, 'r')
88     l = i.readlines()
89     i.close()
90     for ll in l:
91         if intrans and ll.strip()=='':
92             intrans = False;
93         # at this point Transifex sometimes includes a "#, fuzzy" we eill
94         # ignore all lines starting with "#," as they do not contains any
95         # "Name email, year" information.
96         if not "#," in ll:
97             if intrans and ll[0]=='#':
98                 name = ll.split('# ')[1].split(',')[0].split(' <')[0]
99                 if not name in contributors and name not in dontinclude:
100                     contributors.append(name)
101         if "# Translators:" in ll:
102             intrans = True
103 #  done with the translators
104
105 n3 = len(contributors)
106 print('  > found %d translators' % (n3-n2))
107 print('> found a total of %d contributors and translators' % n3)
108 contributors.sort(key=str.lower)
109
110 f = open(path+'/CREDITS.txt', 'w')
111 f.write("\n".join(contributors))
112 f.close()
113 print('> list saved to CREDITS.txt')