-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added flag -c contributors logging #35
base: master
Are you sure you want to change the base?
Changes from 4 commits
3c70cc8
21c15af
40ba8f5
a315196
e61a9e4
03e3b0b
5f3028e
a384896
b3b5662
8ba5d54
9302525
dfb71f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,3 +488,59 @@ def log_commits(client: Github, repositories, csv_name, start, finish, branch): | |
sleep(timedelta) | ||
except Exception as e: | ||
print(e) | ||
|
||
def log_contributors_to_csv(info, csv_name): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. может стоит добавить тайп хинты?) |
||
fieldnames = ['repository name', 'login', 'name', 'email', 'url', 'permissions', 'id', 'node_id', 'type', 'bio', | ||
'site_admin'] | ||
with open(csv_name, 'a', newline='') as file: | ||
writer = csv.DictWriter(file, fieldnames=fieldnames) | ||
writer.writerow(info) | ||
|
||
|
||
def log_repository_contributors(repository: Repository, csv_name): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тайп хинты это здорово |
||
contributors = repository.get_contributors() | ||
for contributor in contributors: | ||
contributor_permissons = repository.get_collaborator_permission(contributor) | ||
info_tmp = { | ||
'repository name': repository.full_name, | ||
'login': contributor.login, | ||
'name': EMPTY_FIELD if contributor.name is None else contributor.name, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. в оракле есть функция nvl https://oracleplsql.ru/nvl-function.html |
||
'email': EMPTY_FIELD if contributor.email is None else contributor.email, | ||
'url': contributor.html_url, | ||
'permissions': EMPTY_FIELD if contributor_permissons is None else contributor_permissons, | ||
'id': contributor.id, | ||
'node_id': contributor.node_id, | ||
'type': contributor.type, | ||
'bio': EMPTY_FIELD if contributor.bio is None else contributor.bio, | ||
'site_admin': contributor.site_admin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. лучше в конце ставить запятую объясняю почему было так
стало так
по диффу изменилось 2 строки. 1 добавилась, а другая изменилась, хотя мы только добавили строку. преждевременная запятая способствует более чистому диффу) |
||
} | ||
log_contributors_to_csv(info_tmp, csv_name) | ||
print(info_tmp) | ||
sleep(timedelta) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. это из-за ограничений апи нужно? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +посмотрел по коду и понял, что это константа, может стоит капсом назвать её? |
||
|
||
|
||
def log_contributors(client: Github, repositories, csv_name): | ||
with open(csv_name, 'w', newline='') as file: | ||
writer = csv.writer(file) | ||
writer.writerow( | ||
( | ||
'repository name', | ||
'login', | ||
'name', | ||
'email', | ||
'url', | ||
'permissions', | ||
'id', | ||
'node_id', | ||
'type', | ||
'bio', | ||
'site_admin' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. про запятую подумайте :) |
||
) | ||
) | ||
for repo in get_next_repo(client, repositories): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. удалить? |
||
try: | ||
log_repository_contributors(repo, csv_name) | ||
sleep(timedelta) | ||
except Exception as e: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а нам точно все исключение нужно перехватывать? |
||
print(e) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ def parse_args(): | |
parser.add_argument("--invites", help="print pending invites", action="store_true") | ||
parser.add_argument("-p", help="log pull requests", action="store_true") | ||
parser.add_argument("-i", help="log issues", action="store_true") | ||
parser.add_argument("-c", help="log contributors", action="store_true") | ||
parser.add_argument("-e", help="export table to google sheets", action="store_true") | ||
parser.add_argument('-t', '--token', type=str, required=True, help='token github account') | ||
parser.add_argument('-l', '--list', type=str, required=True, help='repos names file') | ||
|
@@ -59,7 +60,7 @@ def main(): | |
start = parse_time(args.start.split('-')) | ||
if args.finish: | ||
finish = parse_time(args.finish.split('-')) | ||
if not args.p and not args.i and not args.invites: | ||
if not args.p and not args.i and not args.invites and not args.c: | ||
git_logger.log_commits(client, repositories, csv_name, start, finish, args.branch) | ||
if (args.e): | ||
export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id) | ||
|
@@ -71,8 +72,11 @@ def main(): | |
git_logger.log_issues(client, repositories, csv_name, token, start, finish) | ||
if (args.e): | ||
export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id) | ||
if args.invites: | ||
git_logger.log_invitations(client, repositories, csv_name) | ||
if (args.c): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. скобки не нужны тут if args.c: |
||
git_logger.log_contributors(client, repositories, csv_name) | ||
if (args.e): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. скобки не нужны тут if args.e: |
||
export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в ридми нет инфы про то, как должен выглядеть список репозиториев
я по дурости сунул туда ссылки на репозитории
а надо не ссылки
так надо
thehighestmath/python-code-check-system
а так не надо
https://github.com/thehighestmath/python-code-check-system
можете, пожалуйста, добавить это в ридми?