Skip to content
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

Collect existing datapackages #21

Open
davidgasquez opened this issue Apr 19, 2023 · 1 comment
Open

Collect existing datapackages #21

davidgasquez opened this issue Apr 19, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@davidgasquez
Copy link
Member

Basically, get these files: https://github.com/search?q=path%3A**%2Fdatapackage.json&type=code

@davidgasquez davidgasquez added the enhancement New feature or request label Apr 19, 2023
@davidgasquez davidgasquez self-assigned this Apr 19, 2023
@davidgasquez
Copy link
Member Author

Some quick code to do that. 👇

import requests

def search_code(query, page=0):
    url = "https://api.github.com/search/code"
    headers = {
        "Accept": "application/vnd.github+json",
        "Authorization": f"Bearer {os.getenv("BEARER")}"
    }

    # Define the query parameters
    params = {
        "q": query,
        "page": page
    }

    # Make the GET request
    response = requests.get(url, headers=headers, params=params)
    response.raise_for_status()
    return response.json()

data = search_code("filename:datapackage.yaml")

all_items = []
page = 1

while page:
    items = search_code("filename:datapackage.yaml", page)['items']
    all_items.extend(items)
    if not items:
        page = None
    else:
        page = page + 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

1 participant