]> git.mxchange.org Git - friendica.git/blob - util/make_credits.py
Merge pull request #2158 from annando/1512-vier-fonts
[friendica.git] / util / 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 /util/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']
27
28
29 #  this script is in the /util sub-directory of the friendica installation
30 #  so the friendica path is the 0th argument of calling this script but we
31 #  need to remove the name of the file and the name of the directory
32 path = os.path.abspath(argv[0].split('util/make_credits.py')[0])
33 print('> base directory is assumed to be: '+path)
34 #  a place to store contributors
35 contributors = ['Andi Stadler']
36 #  get the contributors
37 print('> getting contributors to the friendica core repository')
38 p = subprocess.Popen(['git', 'shortlog', '--no-merges', '-s'],
39                          stdout=subprocess.PIPE,
40                          stderr=subprocess.STDOUT)
41 c = iter(p.stdout.readline, b'')
42 for i in c:
43     name = i.decode().split('\t')[1].split('\n')[0]
44     if not name in contributors and name not in dontinclude:
45         contributors.append(name)
46 n1 = len(contributors)
47 print('  > found %d contributors' % n1)
48 #  get the contributors to the addons
49 os.chdir(path+'/addon')
50 #  get the contributors
51 print('> getting contributors to the addons')
52 p = subprocess.Popen(['git', 'shortlog', '--no-merges', '-s'],
53                          stdout=subprocess.PIPE,
54                          stderr=subprocess.STDOUT)
55 c = iter(p.stdout.readline, b'')
56 for i in c:
57     name = i.decode().split('\t')[1].split('\n')[0]
58     if not name in contributors and name not in dontinclude:
59         contributors.append(name)
60 n2 = len(contributors)
61 print('  > found %d new contributors' % (n2-n1))
62 print('> total of %d contributors to the repositories of friendica' % n2)
63 os.chdir(path)
64 #  get the translators
65 print('> getting translators')
66 intrans = False
67 for f in glob.glob(path+'/view/*/messages.po'):
68     i = open(f, 'r')
69     l = i.readlines()
70     i.close()
71     for ll in l:
72         if intrans and ll.strip()=='':
73             intrans = False;
74         if intrans and ll[0]=='#':
75             name = ll.split('# ')[1].split(',')[0].split(' <')[0]
76             if not name in contributors and name not in dontinclude:
77                 contributors.append(name)
78         if "# Translators:" in ll:
79             intrans = True
80 #  get the translators from the addons
81 for f in glob.glob(path+'/addon/*/lang/*/messages.po'):
82     i = open(f, 'r')
83     l = i.readlines()
84     i.close()
85     for ll in l:
86         if intrans and ll.strip()=='':
87             intrans = False;
88         if intrans and ll[0]=='#':
89             name = ll.split('# ')[1].split(',')[0].split(' <')[0]
90             if not name in contributors and name not in dontinclude:
91                 contributors.append(name)
92         if "# Translators:" in ll:
93             intrans = True
94 #  done with the translators
95
96 n3 = len(contributors)
97 print('  > found %d translators' % (n3-n2))
98 print('> found a total of %d contributors and translators' % n3)
99 contributors.sort(key=str.lower)
100
101 f = open(path+'/util/credits.txt', 'w')
102 f.write("\n".join(contributors))
103 f.close()
104 print('> list saved to util/credits.txt')