Created
February 24, 2025 15:53
-
-
Save joshmoore/a39a544ce167cdf8e316387422d643a2 to your computer and use it in GitHub Desktop.
Reproducer for zenodo [Ticket#332699]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
"""drafted within invensio_github.api""" | |
import os | |
import json | |
from abc import abstractmethod | |
from contextlib import contextmanager | |
from copy import deepcopy | |
from urllib.parse import urlparse | |
import github3 | |
import humanize | |
import requests | |
from flask import current_app | |
from invenio_access.permissions import authenticated_user | |
from invenio_access.utils import get_identity | |
from invenio_db import db | |
from invenio_oauth2server.models import Token as ProviderToken | |
from invenio_oauthclient.handlers import token_getter | |
from invenio_oauthclient.models import RemoteAccount, RemoteToken | |
from invenio_oauthclient.proxies import current_oauthclient | |
from sqlalchemy.orm.exc import NoResultFound | |
from werkzeug.local import LocalProxy | |
from werkzeug.utils import cached_property | |
from invenio_github.models import Release, ReleaseStatus, Repository | |
from invenio_github.proxies import current_github | |
from invenio_github.tasks import sync_hooks as sync_hooks_task | |
from invenio_github.utils import iso_utcnow, parse_timestamp, utcnow | |
# Copied from invenio_github.api::sync | |
class Test1118: | |
def __init__(self): | |
token = os.environ.get("GITHUB_TOKEN", "MISSING") | |
self.api = github3.login(token=token) | |
from datetime import datetime | |
github_repos = {} | |
count = 0 | |
for repo in self.api.repositories(): | |
# DEBUG | |
count +=1 | |
stamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] | |
status = "no" | |
if repo.permissions["admin"]: | |
status = "ok" | |
github_repos[repo.id] = { | |
"id": repo.id, | |
"full_name": repo.full_name, | |
"description": repo.description, | |
"default_branch": repo.default_branch, | |
} | |
print(status, stamp, f"{count:03}", repo) | |
if __name__ == "__main__": | |
t = Test1118() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment