mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-01 17:12:26 +00:00
Update gen_contrib.py to match current contributors.py
Now `manage.py gen_contrib` generates a contributors.py matching the already existing format. It normalizes names to make the list more enjoyable. Before using this to seriously generate contributors.py we need to figure out a way to add pseudo names, or tell everyone to change their name on GitLab.
This commit is contained in:
parent
13c5622ea4
commit
8edf77ca7d
1 changed files with 29 additions and 7 deletions
|
@ -32,16 +32,38 @@ class Command(BaseCommand):
|
||||||
""" The command object for `gen_contrib` """
|
""" The command object for `gen_contrib` """
|
||||||
help = 'Update contributors list'
|
help = 'Update contributors list'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _contrib_file_generator(contributors):
|
||||||
|
"""
|
||||||
|
Generate the content of contributors.py
|
||||||
|
"""
|
||||||
|
buffer = "# -*- mode: python; coding: utf-8 -*-\n"
|
||||||
|
buffer += "\"\"\"re2o.contributors\n"
|
||||||
|
buffer += "A list of the proud contributors to Re2o\n"
|
||||||
|
buffer += "\"\"\"\n"
|
||||||
|
buffer += "\n"
|
||||||
|
buffer += "CONTRIBUTORS = [\n"
|
||||||
|
for name in contributors:
|
||||||
|
# Split name into parts
|
||||||
|
names = name.split()
|
||||||
|
|
||||||
|
# Normalize it
|
||||||
|
names = list(map(str.capitalize, names))
|
||||||
|
|
||||||
|
# Put it back together
|
||||||
|
name_text = " ".join(names)
|
||||||
|
buffer += " '{}',\n".format(name_text)
|
||||||
|
buffer += "]"
|
||||||
|
|
||||||
|
return buffer
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
contributeurs = [
|
contributors = [
|
||||||
item.split('\t')[1]
|
item.split('\t')[1]
|
||||||
for item in os.popen("git shortlog -s -n").read().split("\n")
|
for item in os.popen("git shortlog -s -n").read().split("\n")
|
||||||
if '\t' in item
|
if '\t' in item
|
||||||
]
|
]
|
||||||
self.stdout.write(self.style.SUCCESS("Exportation Sucessfull"))
|
self.stdout.write(self.style.SUCCESS("Exportation Successful"))
|
||||||
with open("re2o/contributors.py", "w") as contrib_file:
|
with open("re2o/contributors.py", "w") as contrib_file:
|
||||||
contrib_file.write("\"\"\"re2o.contributors\n")
|
content = self._contrib_file_generator(contributors)
|
||||||
contrib_file.write("A list of the contributors to Re2o\n")
|
contrib_file.write(content)
|
||||||
contrib_file.write("\"\"\"\n")
|
|
||||||
contrib_file.write("\n")
|
|
||||||
contrib_file.write("CONTRIBUTORS = " + str(contributeurs))
|
|
||||||
|
|
Loading…
Reference in a new issue