-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathghi-create.py
115 lines (87 loc) · 3.34 KB
/
ghi-create.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/python
#
# ATENÇÃO! AVISO DE IMPORTÂNCIA MÁXIMA: NÃO EXECUTE ESTE SCRIPT
#
# O código está demasiadamente imaturo, apesar de já fazer o essencial do que
# se espera dele: popula o repositório OSMBrasil/semanario com issues.
#
# A EXECUÇÃO DESTE CÓDIGO PODE ENCHER O REPOSITÓRIO DE ISSUES INDESEJADAS.
#
# Este programa está sendo compartilhado em tal estado apenas como forma de
# transmitir conhecimento e atestar os marcos alcançados. Como proponente de
# um fluxo de trabalho sofisticado para OSMBrasil/semanario, usando kanban,
# e que está em pleno ensaio, preciso deixar visíveis os progressos.
#
# Na maturidade este programa estará integrado como comando do paicemana.
#
# @alexandre-mbm ‒ Alexandre Magno ‒ [email protected]
#
############################ Variables #####################################
translators = ['alexandre-mbm', 'jgpacker', 'vgeorge']
milestone = 1 # 256 (1), 257 (2)
label_t = 'tradução' # tradução, revisão, movimento, conserto
label_r = 'revisão' # tradução, revisão, movimento, conserto
filename = 'archive-4205.md'
repo_user = 'OSMBrasil'
repo_name = 'semanario'
############################# Preload ######################################
from paicemana.mdanalyzer import MarkdownAnalyzer
from getpass import getpass, getuser
from github3 import login, GitHub
import sys
try:
import readline
except ImportError:
pass
# Fix Python 2.x. see: http://stackoverflow.com/a/7321970/3391915
try:
input = raw_input
except NameError:
pass
############################# Functions ####################################
def get_github():
try:
user = input('GitHub username: ')
except KeyboardInterrupt:
user = getuser()
password = getpass('GitHub password for {0}: '.format(user))
# Obviously you could also prompt for an OAuth token
if not (user and password):
print("Cowardly refusing to login without a username and password.")
sys.exit(1)
return login(user, password)
def put_issues_of_translations(organizer): # TODO use or change
for section in organizer.sections:
repo.create_issue(
section.name,
body=None,
assignee=section.translator,
milestone=milestone,
labels=[label_t]
)
def put_issues_of_revisions(organizer): # TODO use or change
for section in organizer.sections:
repo.create_issue(
section.name,
body=None,
assignee=section.reviser,
milestone=milestone,
labels=[label_r]
)
def test_print_sections(organizer):
for section in organizer.sections:
print(section.score, section.translator, section.reviser, section.name)
def test_put_issues_of_translations(organizer):
print(milestone, label_t)
def test_put_issues_of_revisions(organizer):
print(milestone, label_r)
############################# Program ######################################
if __name__ == "__main__":
analyzer = MarkdownAnalyzer(filename)
organizer = analyzer.getOrganizer()
organizer.distribute_for(translators)
github = get_github()
repo = github.repository(repo_user, repo_name)
test_print_sections(organizer)
test_put_issues_of_translations(organizer)
test_put_issues_of_revisions(organizer)