def process_repo(repo, etag=None):
    if "organization" in repo:
        process_user(repo["organization"])
    if "parent" in repo:
        process_repo(repo["parent"])
    if "source" in repo:
        process_repo(repo["source"])

    # Get the owner.
    if "owner" in repo:
        name = repo["name"]
        owner = process_user(repo["owner"])
        fullname = "{0}/{1}".format(owner.login, name)
    else:
        fullname = repo["name"]
        name = fullname.split("/")[-1]
        owner = None

    # Get the language entry.
    lang = repo.get("language")
    if lang is not None:
        lang = Language.query.filter_by(name=lang).first()
        if lang is None:
            lang = Language(name=repo["language"])

    # Parse the date.
    updated = parse_datetime(repo.get("updated_at"))

    repo_obj = Repo.query.filter_by(id=repo["id"]).first()
    if repo_obj is None:
        repo_obj = Repo(
            id=repo["id"],
            owner=owner,
            name=name,
            fullname=fullname,
            description=repo.get("description"),
            star_count=repo.get("stargazers_count"),
            watcher_count=repo.get("subscribers_count"),
            fork_count=repo.get("forks_count"),
            issues_count=repo.get("open_issues_count"),
            last_updated=updated,
            language=lang,
            etag=etag,
        )
        db.session.add(repo_obj)
    else:
        repo_obj.name = name
        repo_obj.fullname = fullname
        repo_obj.owner = owner
        repo_obj.description = repo.get("description", repo_obj.description)
        repo_obj.star_count = repo.get("stargazers_count", repo_obj.star_count)
        repo_obj.watcher_count = repo.get("subscribers_count",
                                          repo_obj.watcher_count)
        repo_obj.fork_count = repo.get("forks_count", repo_obj.fork_count)
        repo_obj.issues_count = repo.get("open_issues_count",
                                         repo_obj.issues_count)
        if updated is not None:
            repo_obj.last_updated = updated
        if lang is not None:
            repo_obj.language = lang
        if etag is not None:
            repo_obj.etag = etag
    return repo_obj
dataset/ETHPy150Open dfm/osrc/osrc/process.py/process_repo/original