mirror of
https://github.com/firmai/financial-machine-learning.git
synced 2026-08-20 06:18:07 +00:00
handle empty repo
This commit is contained in:
@@ -12,6 +12,7 @@ from git_util import get_github_client, get_repo_attributes_dict
|
|||||||
def convert_repo_list_to_df(repo_list, category):
|
def convert_repo_list_to_df(repo_list, category):
|
||||||
df_list = []
|
df_list = []
|
||||||
for repo in repo_list:
|
for repo in repo_list:
|
||||||
|
print(repo)
|
||||||
attr_dict = get_repo_attributes_dict(repo)
|
attr_dict = get_repo_attributes_dict(repo)
|
||||||
attr_dict['name'] = repo.name
|
attr_dict['name'] = repo.name
|
||||||
attr_dict['comment'] = 'NEW'
|
attr_dict['comment'] = 'NEW'
|
||||||
|
|||||||
+23
-19
@@ -1,4 +1,4 @@
|
|||||||
from github import Github, Repository
|
from github import Github, Repository, GithubException
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
@@ -39,25 +39,29 @@ def get_last_commit_date(input_repo: Repository):
|
|||||||
|
|
||||||
|
|
||||||
def get_repo_attributes_dict(input_repo: Repository, last_commit_within_years: int = 2):
|
def get_repo_attributes_dict(input_repo: Repository, last_commit_within_years: int = 2):
|
||||||
result_dict = {
|
result_dict = {}
|
||||||
'repo_path': input_repo.full_name,
|
try:
|
||||||
'created_at': input_repo.created_at,
|
result_dict = {
|
||||||
'last_commit': get_last_commit_date(input_repo),
|
'repo_path': input_repo.full_name,
|
||||||
'last_update': input_repo.updated_at,
|
'created_at': input_repo.created_at,
|
||||||
'star_count': input_repo.stargazers_count,
|
'last_commit': get_last_commit_date(input_repo),
|
||||||
'fork_count': input_repo.forks_count,
|
'last_update': input_repo.updated_at,
|
||||||
'contributors_count': input_repo.get_contributors().totalCount
|
'star_count': input_repo.stargazers_count,
|
||||||
|
'fork_count': input_repo.forks_count,
|
||||||
|
'contributors_count': input_repo.get_contributors().totalCount
|
||||||
|
|
||||||
}
|
}
|
||||||
today = datetime.datetime.today()
|
today = datetime.datetime.today()
|
||||||
check_start_date = datetime.datetime(today.year - last_commit_within_years,
|
check_start_date = datetime.datetime(today.year - last_commit_within_years,
|
||||||
today.month,
|
today.month,
|
||||||
today.day)
|
today.day)
|
||||||
|
|
||||||
if result_dict['last_commit'] >= check_start_date:
|
if result_dict['last_commit'] >= check_start_date:
|
||||||
repo_status = 'active'
|
repo_status = 'active'
|
||||||
else:
|
else:
|
||||||
repo_status = 'inactive'
|
repo_status = 'inactive'
|
||||||
result_dict['repo_status'] = repo_status
|
result_dict['repo_status'] = repo_status
|
||||||
|
except GithubException as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
return result_dict
|
return result_dict
|
||||||
|
|||||||
Reference in New Issue
Block a user