diff --git a/add-metadata.py b/add-metadata.py index 500a8b9..2537132 100755 --- a/add-metadata.py +++ b/add-metadata.py @@ -43,16 +43,24 @@ def retrieve_repo(name): except Exception: warn(f"Error occured while getting {name} repo") raise - print('.', file=sys.stderr, end='', flush=True) - check_freshness(repo) + + # print('.', file=sys.stderr, end='', flush=True) + + if is_stale(repo): + raise Exception("Repo is too old or inactive") + return repo -def check_freshness(repo): +def is_stale(repo): if repo.archived: warn(f"Repo {repo.full_name} is archived") - elif repo.pushed_at < datetime.utcnow() - timedelta(days=180): + return True + elif repo.pushed_at < datetime.utcnow() - timedelta(days=365): warn(f"Repo {repo.full_name} has not been pushed to since {repo.pushed_at}") + return True + + return False def parse(line): @@ -62,7 +70,7 @@ def parse(line): try: row = github_table_row(retrieve_repo(repo_name)) except Exception: - row = '' + row = False return row else: return line.rstrip() @@ -71,7 +79,9 @@ def parse(line): def run(): print('') for line in fileinput.input(): - print(parse(line)) + parsed = parse(line) + if parsed: + print(parsed) run()