Skip to main content

Construct a proper BibTeX file to use with the Hugo Academic theme from ADS export

Project description

academic-ads-bibtex

PyPI - Python Version PyPI License GitHub Workflow Status

PyPI - Downloads Hits

Overview

The Hugo Academic admin tool allows for the ingestion of BibTeX records to add to the publication list. One easy solution is to use the NASA ADS to retrieve such records from a NASA ADS Library. However, such records often contain LaTeX \newcommand. For example:

@ARTICLE{2016ApJS..226....5L,
   author = {{Ly}, C. and {Malhotra}, S. and {Malkan}, M.~A. and {Rigby}, J.~R. and 
        {Kashikawa}, N. and {de los Reyes}, M.~A. and {Rhoads}, J.~E.
        },
    title = "{The Metal Abundances across Cosmic Time (MACT) Survey. I. Optical Spectroscopy in the Subaru Deep Field}",
  journal = {\apjs},
archivePrefix = "arXiv",
   eprint = {1602.01089},
 keywords = {galaxies: abundances, galaxies: distances and redshifts, galaxies: evolution, galaxies: ISM, galaxies: photometry, galaxies: star formation},
     year = 2016,
    month = sep,
   volume = 226,
      eid = {5},
    pages = {5},
      doi = {10.3847/0067-0049/226/1/5},
   adsurl = {https://ui.adsabs.harvard.edu/abs/2016ApJS..226....5L},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Here, the journal name is simplified to "\apjs". This ends up propagating into Hugo Academic sites. To fix this, this simple pure Python script will convert such aliases into the full journal names. It uses a journal database to conduct the replacement.

Installation

There are two ways to get the code:

  1. From PyPi
  2. From source

But first, we recommend creating a separate (virtual) environment to avoid any possible conflicts with existing software that you used. Instructions are provided for conda and virtualenv.

From PyPi

Using conda:

(base) $ (sudo) conda create -n bibtex python=3.7
(base) $ conda activate bibtex
(bibtex) $ (sudo) pip install academic-ads-bibtex

Using virtualenv:

(base) $ (sudo) conda install virtualenv  # if not installed
(base) $ mkdir academic-ads-bibtex
(base) $ cd academic-ads-bibtex
(base) $ virtualenv venv
(base) $ source venv/bin/activate
(venv) $ pip install academic-ads-bibtex

From source:

Using conda:

(base) $ (sudo) conda create -n bibtex python=3.7
(base) $ conda activate bibtex
(bibtex) $ git clone https://github.com/astrochun/academic-ads-bibtex.git
(bibtex) $ cd academic-ads-bibtex
(bibtex) $ (sudo) python setup.py install

Using virtualenv:

(base) $ (sudo) conda install virtualenv  # if not installed
(base) $ git clone https://github.com/astrochun/academic-ads-bibtex.git
(base) $ cd academic-ads-bibtex
(base) $ virtualenv venv
(base) $ source venv/bin/activate
(venv) $ python setup.py install

Examples

The primary script to execute is academic_ads_bibtex. The above installation will include this executable in your python environment paths.

Execution requires only one argument, which is the full path to the BibTeX file. It can be provided with the -f or --filename command-line flags.

$ academic_ads_bibtex -f /full/path/to/my_pubs.bbl

By default:

  1. The code uses the repository-based journal database, bibtex_journals.db. This can be changed by specifying the -d or --db_filename command-line flag.
  2. The revised BibTeX file will be based on the input filename with the prefix changed to include _revised. For example, for the above case, the output file will be /full/path/to/my_pubs_revised.bbl. This can be changed by specifying the -o or --out_filename command-line flag.

A log file is constructed: /full/path/to/academic_ads_bibtex.YYYY-MM-DD.log

Versioning

We use SemVer for versioning. For the versions available, see the releases on this repository.

Authors

License

This project is licensed under the GNU GPLv3 License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

academic-ads-bibtex-0.2.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

academic_ads_bibtex-0.2.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file academic-ads-bibtex-0.2.0.tar.gz.

File metadata

  • Download URL: academic-ads-bibtex-0.2.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for academic-ads-bibtex-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8b287e79d228892e7feb7fca6462958f33d9f7d9420be4602cc2f0501a7458a3
MD5 b57ba4a9925453fa1fd7b4a73a5592ae
BLAKE2b-256 c18d7cb87fc6efa990e12197c028e30281d5739e5f05ff79e22379fc6d49d55c

See more details on using hashes here.

File details

Details for the file academic_ads_bibtex-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: academic_ads_bibtex-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for academic_ads_bibtex-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7929e8c64d0d10c2d5d99dc0c42e9331a40c6f5e4f5d50cb0eed319740d73fc8
MD5 0d8e98493170f0a05fdfd2cff892cc51
BLAKE2b-256 cb978caa872e03a45457ca12a38c2a7d01302c4f172d4743f5b19f50ef5d0df1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page