66from github import Github , Repository , GithubException , PullRequest
77
88EMPTY_FIELD = 'Empty field'
9-
9+ timezone = 'Europe/Moscow'
1010
1111def login (token ):
1212 client = Github (login_or_token = token )
@@ -69,17 +69,17 @@ def log_commit_to_stdout(info):
6969def log_repository_commits (repository : Repository , csv_name , start , finish ):
7070 for commit in repository .get_commits ():
7171 if commit .commit .author .date .astimezone (
72- pytz .timezone ('Europe/Moscow' )) < start or commit .commit .author .date .astimezone (
73- pytz .timezone ('Europe/Moscow' )) > finish :
72+ pytz .timezone (timezone )) < start or commit .commit .author .date .astimezone (
73+ pytz .timezone (timezone )) > finish :
7474 continue
7575 if commit .commit is not None :
7676 info = {'repository name' : repository .full_name ,
7777 'author name' : commit .commit .author .name ,
7878 'author login' : EMPTY_FIELD ,
7979 'author email' : EMPTY_FIELD ,
80- 'date and time' : commit .commit .author .date .astimezone (pytz .timezone ('Europe/Moscow' )),
80+ 'date and time' : commit .commit .author .date .astimezone (pytz .timezone (timezone )),
8181 'changed files' : '; ' .join ([file .filename for file in commit .files ]),
82- 'commit id' : commit .commit .sha }}
82+ 'commit id' : commit .commit .sha }
8383
8484 if commit .author is not None :
8585 info ['author login' ] = commit .author .login
@@ -169,13 +169,13 @@ def get_connected_pulls(issue_number, repo_owner, repo_name, token):
169169
170170def log_repository_issues (repository : Repository , csv_name , token , start , finish ):
171171 for issue in repository .get_issues (state = 'all' ):
172- if issue .created_at .astimezone (pytz .timezone ('Europe/Moscow' )) < start or issue .created_at .astimezone (
173- pytz .timezone ('Europe/Moscow' )) > finish :
172+ if issue .created_at .astimezone (pytz .timezone (timezone )) < start or issue .created_at .astimezone (
173+ pytz .timezone (timezone )) > finish :
174174 continue
175175 info_tmp = {
176176 'repository name' : repository .full_name , 'number' : issue .number , 'title' : issue .title ,
177177 'state' : issue .state , 'task' : issue .body ,
178- 'created at' : issue .created_at .astimezone (pytz .timezone ('Europe/Moscow' )),
178+ 'created at' : issue .created_at .astimezone (pytz .timezone (timezone )),
179179 'creator name' : EMPTY_FIELD ,
180180 'creator login' : EMPTY_FIELD ,
181181 'creator email' : EMPTY_FIELD if issue .user .email is None else issue .user .email ,
@@ -284,8 +284,8 @@ def get_related_issues(pull_request_number, repo_owner, repo_name, token):
284284
285285def log_repositories_pr (repository : Repository , csv_name , token , start , finish ):
286286 for pull in repository .get_pulls (state = 'all' ):
287- if pull .created_at .astimezone (pytz .timezone ('Europe/Moscow' )) < start or pull .created_at .astimezone (
288- pytz .timezone ('Europe/Moscow' )) > finish :
287+ if pull .created_at .astimezone (pytz .timezone (timezone )) < start or pull .created_at .astimezone (
288+ pytz .timezone (timezone )) > finish :
289289 continue
290290 info_tmp = {
291291 'repository name' : repository .full_name ,
@@ -294,7 +294,7 @@ def log_repositories_pr(repository: Repository, csv_name, token, start, finish):
294294 'state' : pull .state ,
295295 'commit into' : pull .base .label ,
296296 'commit from' : pull .head .label ,
297- 'created at' : pull .created_at .astimezone (pytz .timezone ('Europe/Moscow' )),
297+ 'created at' : pull .created_at .astimezone (pytz .timezone (timezone )),
298298 'creator name' : EMPTY_FIELD if pull .user .name is None else pull .user .name ,
299299 'creator login' : pull .user .login ,
300300 'creator email' : pull .user .email ,
0 commit comments