@@ -80,11 +80,11 @@ def get_columns_from_github(repo,token,project_id):
80
80
return result
81
81
82
82
83
- def get_open_issues_from_github (repo ,token ,project_id ):
83
+ def get_open_issues_from_github (repo ,token ,project_id , page ):
84
84
# GET /repos/:owner/:repo/issues
85
85
urlparts = (str (GITHUB_URL ),"repos" ,str (GITHUB_OWNER ) , str (GITHUB_REPO ) , "issues" )
86
86
url = "/" .join (urlparts )
87
-
87
+ url += "?per_page=100&page=" + str ( page )
88
88
pprint (url )
89
89
90
90
headers = {"Authorization" : "token " + GITHUB_TOKEN ,
@@ -98,8 +98,8 @@ def get_project_cards_from_github(repo,token,column_id):
98
98
# GET /projects/columns/:column_id/cards
99
99
urlparts = (str (GITHUB_URL ),"projects" , "columns" , str (column_id ),"cards" )
100
100
url = "/" .join (urlparts )
101
-
102
- pprint (url )
101
+ url += "?per_page=100"
102
+ # pprint(url)
103
103
104
104
headers = {"Authorization" : "token " + GITHUB_TOKEN ,
105
105
"Accept" : "application/vnd.github.inertia-preview+json" }
@@ -123,7 +123,7 @@ def create_project_card(repo,token,my_column_id,my_issue_id):
123
123
urlparts = (str (GITHUB_URL ),"projects" , "columns" , str (my_column_id ),"cards" )
124
124
url = "/" .join (urlparts )
125
125
126
- pprint (url )
126
+ # pprint(url)
127
127
128
128
headers = {"Authorization" : "token " + GITHUB_TOKEN ,
129
129
"Accept" : "application/vnd.github.inertia-preview+json" }
@@ -161,7 +161,7 @@ def create_project_card(repo,token,my_column_id,my_issue_id):
161
161
#print my_project_id
162
162
163
163
columns = get_columns_from_github (GITHUB_REPO ,GITHUB_TOKEN ,my_project_id )
164
- pprint (columns )
164
+ # pprint(columns)
165
165
# pprint(columns.json())
166
166
167
167
# create temporary index for easy of use
@@ -188,52 +188,53 @@ def create_project_card(repo,token,my_column_id,my_issue_id):
188
188
print "My column id is " + str (my_column_id )
189
189
190
190
# Read all issues from GitHub
191
- print "Retrieving all current issues from GitHub"
192
- issues = get_open_issues_from_github (GITHUB_REPO ,GITHUB_TOKEN ,my_project_id )
193
- if issues .status_code == 200 :
194
- file = open ("issues.txt" ,"w" )
195
- file .write (pformat (issues .json ()))
196
- file .close ()
197
-
198
- # Read all project cards from GitHub
199
- # print "Retrieving all current cards from GitHub"
200
- # cards=get_project_cards_from_github(GITHUB_REPO,GITHUB_TOKEN,my_column_id)
201
- # if cards.status_code==200:
202
- # file = open("cards.txt","w")
203
- # file.write(pformat(cards.json()))
204
- # file.close()
205
-
206
- # We now have everything to find out what needs to be done.
207
-
208
-
209
-
210
- pprint (card_index )
211
-
212
- print "About to start adding " + str (len (issues .json ())) + " issues to the project."
213
- print "Adding cards linked to issues"
214
- issue_counter = 0
215
- #file = open("AddIssuesToProject.log","a")
216
- for issue in issues .json ():
217
- issue_counter += 1
218
- print "Doing issue: " + str (issue_counter )
219
- # if issue already in cards do nothing
220
- if str (issue ["number" ]) in card_index :
221
- print "Card for issue " + str (issue ["number" ]) + " exists"
222
- else :
223
- print "Creating card for issue " + str (issue ["number" ]) + " (\" " + issue ["title" ] + "\" )"
224
- # else add card in correct column linking to issue
225
- # create card in desired project and desired column
226
- # Note that you have to send the id of the issue, not the number!
227
- result = create_project_card (GITHUB_REPO ,GITHUB_TOKEN ,my_column_id ,issue ["id" ])
228
- # And try this ONLY ONCE!
229
- #pprint(result)
230
- pprint (result .json ())
231
- with open ("AddIssuesToProject.log" , "a" ) as logfile :
232
- logfile .write (pformat (result .json ()))
233
- #file.write(pformat(result.json()))
234
- #sys.exit(1)
235
-
236
- file .close ()
191
+ # Since this is a one off script and we don't really care, we just request 5 pages of issues
192
+ for page in range (6 ):
193
+ print "Retrieving all current issues from GitHub"
194
+ issues = get_open_issues_from_github (GITHUB_REPO ,GITHUB_TOKEN ,my_project_id ,page )
195
+ if issues .status_code == 200 :
196
+ #file = open("issues.txt","a")
197
+ #file.write(pformat(issues.json()))
198
+ #file.close()
199
+ with open ("issues.txt" , "a" ) as issuesfile :
200
+ issuesfile .write (pformat (issues .json ()))
201
+ # Read all project cards from GitHub
202
+ # print "Retrieving all current cards from GitHub"
203
+ # cards=get_project_cards_from_github(GITHUB_REPO,GITHUB_TOKEN,my_column_id)
204
+ # if cards.status_code==200:
205
+ # file = open("cards.txt","w")
206
+ # file.write(pformat(cards.json()))
207
+ # file.close()
208
+
209
+ # We now have everything to find out what needs to be done.
210
+
211
+ #pprint(card_index)
212
+
213
+ print "About to start adding " + str (len (issues .json ())) + " issues to the project."
214
+ print "Adding cards linked to issues"
215
+ issue_counter = 0
216
+ #file = open("AddIssuesToProject.log","a")
217
+ for issue in issues .json ():
218
+ issue_counter += 1
219
+ print "Doing issue: " + str (issue_counter )
220
+ # if issue already in cards do nothing
221
+ if str (issue ["number" ]) in card_index :
222
+ print "Card for issue " + str (issue ["number" ]) + " exists"
223
+ else :
224
+ print "Creating card for issue " + str (issue ["number" ]) + " (\" " + issue ["title" ] + "\" )"
225
+ # else add card in correct column linking to issue
226
+ # create card in desired project and desired column
227
+ # Note that you have to send the id of the issue, not the number!
228
+ result = create_project_card (GITHUB_REPO ,GITHUB_TOKEN ,my_column_id ,issue ["id" ])
229
+ # And try this ONLY ONCE!
230
+ #pprint(result)
231
+ pprint (result .json ())
232
+ with open ("AddIssuesToProject.log" , "a" ) as logfile :
233
+ logfile .write (pformat (result .json ()))
234
+ #file.write(pformat(result.json()))
235
+ #sys.exit(1)
236
+
237
+ #file.close()
237
238
238
239
else :
239
240
print "ERROR: Getting columns"
0 commit comments