]> git.mxchange.org Git - friendica.git/blob - util/make_credits.py
Add missing doc in api.php
[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', 'rabuzarus', 'Alberto Díaz']
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", "Ratten", "Vít Šesták 'v6ak'"]
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 try:
50     os.chdir(path+'/addon')
51     #  get the contributors
52     print('> getting contributors to the addons')
53     p = subprocess.Popen(['git', 'shortlog', '--no-merges', '-s'],
54                              stdout=subprocess.PIPE,
55                              stderr=subprocess.STDOUT)
56     c = iter(p.stdout.readline, b'')
57     for i in c:
58         name = i.decode().split('\t')[1].split('\n')[0]
59         if not name in contributors and name not in dontinclude:
60             contributors.append(name)
61 except FileNotFoundError:
62     print('  > no addon directory found ( THE LIST OF CONTRIBUTORS WILL BE INCOMPLETE )')
63 n2 = len(contributors)
64 print('  > found %d new contributors' % (n2-n1))
65 print('> total of %d contributors to the repositories of friendica' % n2)
66 os.chdir(path)
67 #  get the translators
68 print('> getting translators')
69 intrans = False
70 for f in glob.glob(path+'/view/lang/*/messages.po'):
71     i = open(f, 'r')
72     l = i.readlines()
73     i.close()
74     for ll in l:
75         if intrans and ll.strip()=='':
76             intrans = False;
77         if intrans and ll[0]=='#':
78             name = ll.split('# ')[1].split(',')[0].split(' <')[0]
79             if not name in contributors and name not in dontinclude:
80                 contributors.append(name)
81         if "# Translators:" in ll:
82             intrans = True
83 #  get the translators from the addons
84 for f in glob.glob(path+'/addon/*/lang/*/messages.po'):
85     i = open(f, 'r')
86     l = i.readlines()
87     i.close()
88     for ll in l:
89         if intrans and ll.strip()=='':
90             intrans = False;
91         if intrans and ll[0]=='#':
92             name = ll.split('# ')[1].split(',')[0].split(' <')[0]
93             if not name in contributors and name not in dontinclude:
94                 contributors.append(name)
95         if "# Translators:" in ll:
96             intrans = True
97 #  done with the translators
98
99 n3 = len(contributors)
100 print('  > found %d translators' % (n3-n2))
101 print('> found a total of %d contributors and translators' % n3)
102 contributors.sort(key=str.lower)
103
104 f = open(path+'/util/credits.txt', 'w')
105 f.write("\n".join(contributors))
106 f.close()
107 print('> list saved to util/credits.txt')