Source code for arxiv_post.arxiv

__all__ = ["search"]


# standard library
from logging import getLogger
from typing import List, Sequence


# dependencies
from arxiv import Search
from dateparser import parse


# submodules
from .article import Article
from .consts import CATEGORIES, KEYWORDS, START_DATE, END_DATE


# constants
ARXIV_DATE_FORMAT = "%Y%m%d%H%M%S"


# logger
logger = getLogger(__name__)


# runtime functions



def format_date(date_like: str) -> str:
    """Parse and format a date-like string."""
    if (dt := parse(date_like)) is not None:
        return dt.strftime(ARXIV_DATE_FORMAT)

    raise ValueError(f"Could not parse {date_like!r}.")