How to use the arxiv.taxonomy.ARCHIVES function in arxiv

To help you get started, we’ve selected a few arxiv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arXiv / arxiv-search / tests / test_advanced_search.py View on Github external
def test_archive_shortcut(self):
        """User requests a sub-path with classification archive."""
        for archive in taxonomy.ARCHIVES.keys():
            response = self.client.get(f'/advanced/{archive}')
            self.assertEqual(response.status_code, status.HTTP_200_OK,
                             "Should support shortcut for archive {archive}")
github arXiv / arxiv-browse / tests / test_external_refs_cits.py View on Github external
def test_dblp_config(self):
        """Ensure DBLP_ARCHIVES archives are valid."""
        for archive in DBLP_ARCHIVES:
            self.assertIn(archive, ARCHIVES)
github arXiv / arxiv-search / search / converters.py View on Github external
def to_python(self, value: str) -> Optional[List[str]]:
        """Parse URL path part to Python rep (str)."""
        valid_archives = []
        for archive in value.split(','):
            if archive not in taxonomy.ARCHIVES:
                continue
            # Support old archives.
            if archive in taxonomy.ARCHIVES_SUBSUMED:
                cat = taxonomy.CATEGORIES[taxonomy.ARCHIVES_SUBSUMED[archive]]
                archive = cat['in_archive']
            valid_archives.append(archive)
        if not valid_archives:
            raise ValidationError()
        return valid_archives
github arXiv / arxiv-browse / browse / controllers / list_page / __init__.py View on Github external
month = request.args.get('month', None)
        if month and month != 'all':
            time_period = time_period + request.args.get('month')  # type: ignore

    if (not subject_or_category or
            not (time_period and
                 (time_period.isdigit() or
                  time_period in ['new', 'current', 'pastweek', 'recent']))):
        raise BadRequest

    if subject_or_category in taxonomy.CATEGORIES:
        list_type = 'category'
        list_ctx_name = taxonomy.CATEGORIES[subject_or_category]['name']
        list_ctx_id = subject_or_category
        list_ctx_in_archive = taxonomy.CATEGORIES[subject_or_category]['in_archive']
    elif subject_or_category in taxonomy.ARCHIVES:
        list_type = 'archive'
        list_ctx_id = subject_or_category
        list_ctx_name = taxonomy.ARCHIVES[subject_or_category]['name']
        list_ctx_in_archive = list_ctx_name
    else:
        raise BadRequest

    listing_service = get_listing_service()
    if not listing_service:
        raise ServiceUnavailable

    if not skip or not skip.isdigit():
        skipn = 0
    else:
        skipn = int(skip)
github arXiv / arxiv-search / search / controllers / advanced / __init__.py View on Github external
def group_search(args: MultiDict, groups_or_archives: str) -> Response:
    """
    Short-cut for advanced search with group or archive pre-selected.

    Note that this only supports options supported in the advanced search
    interface. Anything else will result in a 404.
    """
    logger.debug("Group search for %s", groups_or_archives)
    valid_archives = []
    for archive in groups_or_archives.split(","):
        if archive not in taxonomy.ARCHIVES:
            logger.debug("archive %s not found in taxonomy", archive)
            continue
        # Support old archives.
        if archive in taxonomy.ARCHIVES_SUBSUMED:
            category = taxonomy.CATEGORIES[taxonomy.ARCHIVES_SUBSUMED[archive]]
            archive = category["in_archive"]
        valid_archives.append(archive)

    if len(valid_archives) == 0:
        logger.debug("No valid archives in request")
        raise NotFound("No such archive.")

    logger.debug("Request for %i valid archives", len(valid_archives))
    args = args.copy()
    for archive in valid_archives:
        fld = dict(forms.ClassificationForm.ARCHIVES).get(archive)
github arXiv / arxiv-browse / browse / domain / metadata.py View on Github external
def __post_init__(self) -> None:
        """Get the full archive name."""
        super().__post_init__()
        if self.id in taxonomy.ARCHIVES:
            self.name = taxonomy.ARCHIVES[self.id]['name']
github arXiv / arxiv-browse / browse / services / document / metadata.py View on Github external
raw_safe = re.sub(RE_FROM_FIELD, r'\g\g', raw, 1)

        return DocMetadata(
            raw_safe=raw_safe,
            arxiv_id=arxiv_id,
            arxiv_id_v=arxiv_id_v,
            arxiv_identifier=Identifier(arxiv_id=arxiv_id),
            title=fields['title'],
            abstract=fields['abstract'],
            authors=AuthorList(fields['authors']),
            submitter=Submitter(name=name, email=email),
            categories=fields['categories'] if 'categories' in fields else None,
            primary_category=primary_category,
            primary_archive=primary_archive,
            primary_group=Group(
                taxonomy.ARCHIVES[primary_archive.id]['in_group']),
            secondary_categories=[
                Category(x) for x in category_list[1:]
                if (category_list and len(category_list) > 1)
            ],
            journal_ref=None if 'journal_ref' not in fields
            else fields['journal_ref'],
            report_num=None if 'report_num' not in fields
            else fields['report_num'],
            doi=None if 'doi' not in fields else fields['doi'],
            acm_class=None if 'acm_class' not in fields else
            fields['acm_class'],
            msc_class=None if 'msc_class' not in fields else
            fields['msc_class'],
            proxy=None if 'proxy' not in fields else fields['proxy'],
            comments=fields['comments'] if 'comments' in fields else None,
            version=version,
github arXiv / arxiv-browse / browse / controllers / year.py View on Github external
thisYear = date.today().year

    if year is None:
        year = thisYear

    if year > thisYear:
        # 307 because year might be valid in the future
        return {}, status.HTTP_307_TEMPORARY_REDIRECT, {'Location': '/'}

    if year < 100:
        if year >= 91:
            year = 1900 + year
        else:
            year = 2000 + year

    if archive_id not in taxonomy.ARCHIVES:
        raise BadRequest("Unknown archive.")
    else:
        archive = taxonomy.ARCHIVES[archive_id]

    listing_service = get_listing_service()
    month_listing = listing_service.monthly_counts(archive_id, year)

    for month in month_listing['month_counts']:
        month['art'] = ascii_art_month(archive_id, month)  # type: ignore
        month['yymm'] = f"{month['year']}-{month['month']:02}"  # type: ignore
        month['url'] = url_for('browse.list_articles',  # type: ignore
                               context=archive_id,
                               subcontext=f"{month['year']}{month['month']:02}")

    response_data: Dict[str, Any] = {
        'archive_id': archive_id,
github arXiv / arxiv-browse / browse / controllers / abs_page / __init__.py View on Github external
Parameters
    ----------
    arxiv_identifier : :class:`Identifier`
    primary_category : :class: `Category`

    Returns
    -------
    Dict of values to add to response_data

    """
    # Set up the context
    context = None
    if ('context' in request.args and (
            context == 'arxiv'
            or context in taxonomy.CATEGORIES
            or context in taxonomy.ARCHIVES)):
        context = request.args['context']
    elif primary_category:
        pc = primary_category.canonical or primary_category
        if not arxiv_identifier.is_old_id:  # new style IDs
            context = pc.id
        else:  # Old style id
            if pc.id in taxonomy.ARCHIVES:
                context = pc.id
            else:
                context = arxiv_identifier.archive
    else:
        context = None

    response_data['browse_context'] = context

    if arxiv_identifier.is_old_id or context == 'arxiv':
github arXiv / arxiv-browse / browse / domain / category.py View on Github external
def display_str(self)->str:
        """String to use in display of a category.

        Ex:
        Earth and Planetary Astrophysics (astro-ph.EP)
        """
        if self.id in taxonomy.CATEGORIES:
            catname = taxonomy.CATEGORIES[self.id]['name']
            return f'{catname} ({self.id})'
        sp = _split_cat_str(self.id)
        hassub = len(sp) == 2
        if hassub:
            (arc, _) = sp
            if arc in taxonomy.ARCHIVES:
                arcname = taxonomy.ARCHIVES[arc]['name']
                return f'{arcname} ({self.id})'
            else:
                return self.id
        else:
            return self.id