A program to create archives of articles from microPublication.org for sending to Portico.
Authors: Michael Hucka, Tom Morrell
Repository: https://github.com/caltechlibrary/microarchiver
License: BSD/MIT derivative – see the LICENSE file for more information
- Introduction
- Installation
- Usage
- Known issues and limitations
- Getting help and support
- Contributing
- License
- Authors and history
- Acknowledgments
The Caltech Library is the publisher of the online journal microPublication and provides services to the journal that include archiving the journal in a dark archive (specifically, Portico). The archiving process involves pulling down articles from microPublication and packaging them up in a format suitable for sending to Portico. Microarchiver
is a program to automate this process.
On Linux, macOS, and Windows operating systems, you should be able to install Microarchiver directly from the GitHub repository using pip. If you don't have the pip
package or are uncertain if you do, first run the following command in a terminal command line interpreter:
sudo python3 -m ensurepip
Then, install this software by running the following command on your computer:
python3 -m pip install git+https://github.com/caltechlibrary/microarchiver.git --user --upgrade
Alternatively, you can clone this GitHub repository and then run setup.py
:
git clone https://github.com/caltechlibrary/microarchiver.git
cd microarchiver
python3 -m pip install . --user --upgrade
Microarchiver is a command-line program. The installation process should put a program named microarchiver
in a location normally searched by your shell interpreter. For help with usage at any time, run microarchiver
with the option -h
(or /h
on Windows).
microarchiver -h
The simplest use of microarchiver
involves running it without any arguments. It will contact microPublication.org to get a list of current articles, and create an archive of all the articles in a subdirectory of the current directory.
microarchiver
If given the argument -o
(or /o
on Windows), the output will be written to the directory named after the -o
. (If no -o
is given, the output will be written to the current directory instead.) For example:
microarchiver -o /tmp/micropublication-archive
If the option -d
is given, microarchiver
will download only articles whose publication dates are after the given date. Valid date descriptors are those accepted by the Python dateparser library. Make sure to enclose descriptions within single or double quotes. Examples:
microarchiver -d "2014-08-29" ....
microarchiver -d "12 Dec 2014" ....
microarchiver -d "July 4, 2013" ....
microarchiver -d "2 weeks ago" ....
As it works, microarchiver
writes information to the terminal about the archives it puts into the archive, including whether any problems are encountered. To save this info to a file, use the argument -r
(or /r
on Windows), which will make microarchiver
write a report file in CSV format.
The following is a screen recording of an actual run of microarchiver
:
If given the argument -p
(or /p
on Windows), microarchiver
will only print a list of articles it will archive and stop short of creating the archive. This is useful to see what would be produced without actually doing it. However, note that because it does not attempt to download the articles and associated files, it will not be able to report on errors that might occur when not operating in preview mode. Consequently, do not use the output of -p
as a prediction of eventual success or failure.
If given the argument -g
(or /g
on Windows), microarchiver
will only write a file named article-list.xml
containing the complete current article list from the micropublication.org server, and exit without doing anything else. This is useful as a starting point for creating the file used by option -a
. It's probably a good idea to redirect the output to a file; e.g.,
microarchiver -g > article-list.xml
The output will be written to the directory indicated by the value of the argument -o
(or /o
on Windows). If no -o
is given, the output will be written to the directory in which microarchiver
was started. Each article will be written to a subsubdirecory named after the DOI of the article. The output for each article will consist of an XML metadata file describing the article, the article itself in PDF format, and a subdirectory named jats
containing the article in JATS XML format along with any image that may appear in the article. The image is always converted to uncompressed TIFF format (because it is considered a good preservation format).
The output will be put into a single-file archive in ZIP format unless the argument -Z
(or /Z
on Windows) is given to prevent creation of the compressed archive file.
If given the argument -a
(or /a
on Windows) followed by a file name, the given file will be read for the list of articles instead of getting the list from the server. The contents of the file can be either a list of DOIs, or article data in the same XML format as the list obtained from micropublication.org. (See option -g
above for a way to get an article list in XML from the server.)
Microarchiver always downloads the JATS XML version of articles from micropublication.org (in addition to downloading the PDF version), and by default, microarchiver validates the XML content against the JATS DTD. To skip the XML validation step, use the option -X
(/X
on Windows).
microarchiver
will print informational messages as it works. To reduce messages to only warnings and errors, use the argument -q
(or /q
on Windows). Also, output is color-coded by default unless the -C
argument (or /C
on Windows) is given; this argument can be helpful if the color control sequences create problems for your terminal emulator.
If given the -@
argument (/@
on Windows), this program will output a detailed trace of what it is doing, and will also drop into a debugger upon the occurrence of any errors. The debug trace will be written to the given destination, which can be a dash character (-
) to indicate console output, or a file path.
If given the -V argument (/V on Windows), this program will print version information and exit without doing anything else.
This program exits with a return code of 0
if no problems are encountered while fetching data from the server. It returns a nonzero value otherwise, following conventions for use in shells such as bash which only understand return code values of 0
to 255
. If it is interrupted (e.g., using ctrl-c
) it returns a value of 1
; if it encounters a fatal error, it returns a value of 2
. If it encounters any non-fatal problems (such as a missing PDF file or JATS validation error), it returns a nonzero value equal to 100 + the number of articles that had failures. Summarizing the possible return codes:
Return value | Meaning |
---|---|
0 |
No errors were encountered – success |
1 |
No network detected – cannot proceed |
2 |
The user interrupted program execution |
3 |
An exception or fatal error occurred |
100 + n |
Encountered non-fatal problems on a total of n articles |
The following table summarizes all the command line options available. (Note: on Windows computers, /
must be used as the prefix character instead of -
):
Short | Long form opt | Meaning | Default | |
---|---|---|---|---|
-a A |
--articles A |
Get list of articles from file A | Get list from server | |
-C |
--no-color |
Don't color-code the output | Use colors in the terminal output | |
-d D |
--after-date D |
Only get articles published after date D | Get all articles | ⬥ |
-g |
--get-xml |
Print the server's article list & exit | Do other actions instead | |
-o O |
--output-dir O |
Write output in directory O | Write in current dir | |
-p |
--preview |
Preview what would be obtained | Obtain the articles | |
-q |
--quiet |
Only print important messages | Be chatty while working | |
-r R |
--report R |
Write list of article & results in file R | Don't write a report | |
-V |
--version |
Print program version info and exit | Do other actions instead | |
-X |
--no-check |
Don't validate JATS XML files | Validate JATS XML | |
-Z |
--no-zip |
Don't put output into one ZIP archive | ZIP up the output | |
-@ OUT |
--debug OUT |
Debugging mode; write trace to OUT | Normal mode | ⚑ |
⬥ Enclose the date in quotes if it contains space characters; e.g., "12 Dec 2014"
.
⚑ To write to the console, use the character -
(a single dash) as the value of OUT; otherwise, OUT must be the name of a file where the output should be written.
Currently, the only way to indicate that a subset of articles should be obtained from microPublication.org is to use the argument -a
in combination with a file that contains the list of desired articles, or the -d
option to indicate a cut-off for the article publication date.
If you find an issue, please submit it in the GitHub issue tracker for this repository.
We would be happy to receive your help and participation with enhancing microarchiver
! Please visit the guidelines for contributing for some tips on getting started.
Copyright © 2019-2020, Caltech. This software is freely distributed under a BSD/MIT type license. Please see the LICENSE file for more information.
Tom Morrell developed the original algorithm for extracting metadata from DataCite and creating XML files for use with Portico submissions of microPublication.org articles. Mike Hucka created the much-expanded second version now known as Microarchiver.
The vector artwork used as a starting point for the logo for this repository was created by Thomas Helbig for the Noun Project. It is licensed under the Creative Commons Attribution 3.0 Unported license. The vector graphics was modified by Mike Hucka to change the color.
Microarchiver makes use of numerous open-source packages, without which it would have been effectively impossible to develop Microarchiver with the resources we had. We want to acknowledge this debt. In alphabetical order, the packages are:
- colorama – makes ANSI escape character sequences work under MS Windows terminals
- dateparser – parser for human-readable dates
- humanize – make numbers more easily readable by humans
- ipdb – the IPython debugger
- lxml – an XML parsing library for Python
- Pillow – a fork of the Python Imaging Library
- plac – a command line argument parser
- recordclass – a mutable version of Python named tuples
- requests – an HTTP library for Python
- setuptools – library for
setup.py
- termcolor – ANSI color formatting for output in terminal
- urllib3 – a powerful HTTP library for Python
- xmltodict – a module to make working with XML feel like working with JSON
Finally, we are grateful for computing & institutional resources made available by the California Institute of Technology.