Skip to content

Commit 62dcaec

Browse files
committed
timezone variable added
1 parent 9718116 commit 62dcaec

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

git_logger.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from github import Github, Repository, GithubException, PullRequest
77

88
EMPTY_FIELD = 'Empty field'
9-
9+
timezone = 'Europe/Moscow'
1010

1111
def login(token):
1212
client = Github(login_or_token=token)
@@ -69,17 +69,17 @@ def log_commit_to_stdout(info):
6969
def 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

170170
def 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

285285
def 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,

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def parse_time(datetime_str):
2323
start = [int(i) for i in start]
2424
start_datetime = datetime(year=start[0], month=start[1], day=start[2], hour=start[3], minute=start[4],
2525
second=start[5])
26-
return start_datetime.astimezone(pytz.timezone('Europe/Moscow'))
26+
return start_datetime.astimezone(pytz.timezone(git_logger.timezone))
2727

2828

2929
def main():

0 commit comments

Comments
 (0)