Skip to content

Commit

Permalink
Allow the dataset for loading to be a local file or a URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 12, 2025
1 parent 515f403 commit 63954d8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion distributions/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
Load distributions into the database.
"""

import pathlib
import urllib.parse

import tqdm
import typer
from jaraco.ui.main import main

from .. import pypi


def _make_url(url_or_path: str) -> str:
if not urllib.parse.urlparse(url_or_path).scheme:
return f'file://{pathlib.Path(url_or_path).expanduser().absolute()}'
return url_or_path


@main
def run(
url: str = pypi.top_8k,
url: str = typer.Argument(pypi.top_8k, callback=_make_url),
):
for dist in tqdm.tqdm(list(pypi.Distribution.query(url=url))):
dist.save()

0 comments on commit 63954d8

Please sign in to comment.