Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
4.2 KiB

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