GithubHelp home page GithubHelp logo

gerw / mathbin Goto Github PK

View Code? Open in Web Editor NEW
9.0 8.0 6.0 87 KB

Binaries for mathematicians

License: GNU General Public License v3.0

Shell 73.09% PHP 17.45% Python 1.63% Perl 7.54% Dockerfile 0.28%

mathbin's Introduction

mathbin

This repository contains some shell scripts for e.g.

  • Fetching bibliography entries from mathscinet (msc), zentralblatt (zentralblatt), arXiv (arxiv2bibtex)
  • Fetching pdf from DOI (doi2pdf, bibtex2pdf, also arxiv2pdf)
  • Preparing LaTeX files for submission (used_...)

Usage with Mac OS

Most of the scripts and tools provided here work directly with Mac OS. This is tested with Mac OS 11 Big Sur, but should work with Mac OS 10.15 Catalina as well, maybe even earlier; just note that with Catalina zsh got the default shell. The issue is, that two tools are missing/wrong

  • grep is different from the GNU grep used here (especially the option -P is not available on Mac OS)
  • curl is missing

You can install these using your favourite package manager, here's how to solve both points with homebrew.

switch from grep to GNU grep

Install GNU grep using

brew install grep

which makes the GNU grep available as ggrep. To then exchange both, i.e. make GNU grep the default, add the line PATH="$(brew --prefix)/opt/grep/libexec/gnubin:$PATH" to your .zshrc for example using

echo '\nexport PATH="$(brew --prefix)/opt/grep/libexec/gnubin:$PATH"' >> ~/.zshrc

Install curl

curl is available as a brew formula, so it can be installed using

brew install curl

use docker to run the scripts

first build the container by running

docker build -t mathbin .

from this folder. That creates an image with the name mathbin. Afterwards you can use that image like

docker run --rm -v $(pwd):/data mathbin doi2pdf 10.1007/978-1-4612-2972-8

The option --rm removes the container after downloading the pdf (not the image!), whereas -v binds your working directory on the host to the folder /data on the container.

mathbin's People

Contributors

gerw avatar kellertuer avatar rolandherzog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mathbin's Issues

Error for some special characters when running `doi2pdf`

On my machine when running doi2pdf 10.1137/0803026

I get

usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]
Traceback (most recent call last):
  File "/Users/ronnber/Repositories/numapde/numapde-bibliography/mathbin/doi2pdfname.py", line 7, in <module>
    tree = etree.parse(sys.argv[1])
  File "src/lxml/etree.pyx", line 3521, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1859, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1885, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1789, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1177, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
  File "/tmp/368219713", line 32
lxml.etree.XMLSyntaxError: Entity 'nbsp' not defined, line 32, column 60

which for me looks like an &nbsp; (nonbreaking space in html) is not properly handled/escaped when trying to generate the name?

Use bibtool to change the key in arxive2bib

The arxive2bib tool provides a bib entry with the arxive number as key. We can use bibtool to extract the author names and year automatically. The tool is available as packages on the major distributions Debian, Ubuntu, Fedora and Suse.

The code

#if we have bibtool (https://ctan.org/pkg/bibtool) we can use it to format the key
if [ -x "$(command -v bibtool)" ] ; then
        wget -O - $URL -q | xmllint  --xpath '//div[@id="biblatex"]/textarea/text()' - | bibtool -f "%n(author):%4d(year)" -- "new.entry.type {online}"
else
        wget -O - $URL -q | xmllint  --xpath '//div[@id="biblatex"]/textarea/text()' -
fi

also checks if the tool is available and then formats the bibfile accordingly. Please note the new entry type at the very end. The arxive-api provides the entry type "online", which is not known to bibtool.

Problems with `doi2pdf` on Mac OS

I am having trouble using doi2pdf on Mac OS. With the python version

> python --version
Python 3.6.6 :: Anaconda, Inc.

I had to change line 50 of doi2pdfnames.py to

print(filename.encode("utf8"))

to make it work with python3, but then I get

Traceback (most recent call last):
  File "~/Work/Software/mathbin/doi2pdfname.py", line 3, in <module>
    from lxml import etree
ModuleNotFoundError: No module named 'lxml'

even before it fetches the pdf; still it stops after storing the temporary file without renaming.

Error with lxml on Mac OS Big Sur

I get an error when using doi2pdf on Mac OS Big Sur (Python 3.9.2, lxml installed via pip3,

  File "mathbin/doi2pdfname.py", line 9, in <module>
    tree = etree.parse(sys.argv[1], parser=parser)
  File "src/lxml/etree.pyx", line 3521, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1859, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1885, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1789, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1177, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
  File "/tmp/81657250", line 47
lxml.etree.XMLSyntaxError: Entity 'nbsp' not defined, line 47, column 93

Also I get a print of the usage for grep (installed grep via homebrew) - is that intended?

My example call is doi2pdf 10.1016/j.cam.2016.07.018.

Prohibited characters in filenames

The colon (:) should be also replaced in doi2pdfname.py (and probably other files?)
to be compatible with Mac OS Classic.

For Windows also these characters should be replaced:

< (less than)
> (greater than)
: (colon - sometimes works, but is actually NTFS Alternate Data Streams)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.