Extracting bibliographic information from web services
Project description
Introduction
This package presents a number of methods for querying webservices for bibliographic information, and includes two scripts for querying and renaming files by ISBN.
Installation
biblio.webquery [1] can be installed in a number of ways. setuptools [2] is preferred, but a manual installation will suffice.
Via setuptools / easy_install
From the commandline call:
% easy_install biblio.webquery
Superuser privileges may be required.
Via setup.py
Download a source tarball, unpack it and call setup.py to install:
% tar zxvf biblio.webquery.tgz % cd biblio.webquery % python setup.py install
Superuser privileges may be required.
Usage
Depending on your platform, the scripts may be installed as .py scripts, or some form of executable, or both.
queryisbn
Return bibliographic information from webservices for supplied ISBNs.
queryisbn.py [options] ISBNs ...
with the options:
- --version
show program’s version number and exit
- -h, --help
show this help message and exit
- --debug
For errors, issue a full traceback instead of just a message.
- -s SERVICE, --service=SERVICE
The webservice to query. Choices are xisbn (WorldCat xISBN), isbndb (ISBNdb). The default is xisbn.
- -k KEY, --key=KEY
The access key for the webservice, if one is required.
For example:
% queryisbn.py 1568385048 1564145026 1568385048: title: Drop the rock : removing character defects authors: [Bill Pittman, Todd Weber] publisher: Hazelden year: 1999 lang: eng 1564145026: title: Stop clutter from stealing your life : discover why you clutter and how you can stop authors: [Mike Nelson] publisher: New Page Books year: 2001 lang: eng % /queryisbn.py --debug -s isbndb -k OPNH8HG2 1568385048 1564145026 1568385048: title: Drop the Rock: Removing Character Defects authors: [Bill Pittman, Todd Weber] 1564145026: authors: [Mike Nelson]
renamebyisbn
Extract an ISBN from a file name, look up the associated bibliographic information in a webservice and rename the file appropriately.
renamebyisbn.py [options] FILES ...
with the options:
- --version
show program’s version number and exit
- -h, --help
show this help message and exit
- --debug
For errors, issue a full traceback instead of just a message.
- -s SERVICE, --service=SERVICE
The webservice to query. Choices are xisbn (WorldCat xISBN), isbndb (ISBNdb). The default is xisbn.
- -k KEY, --key=KEY
The access key for the webservice, if one is required.
- -c CASE, --case=CASE
Case conversion of the new file name. Choices are orig, upper, lower.The default is orig.
- --leave_whitespace
Leave excess whitespace. By default, consecutive spaces in names are compacted
- --replace_whitespace=REPLACE_WHITESPACE
Replace whitespace in the new name with this string.
- --strip_chars=STRIP_CHARS
Remove these characters from the new name. By default this are ‘:!,’”.?()’.
- --overwrite
Overwrite existing files.
- --dryrun
Check function and without renaming files.
- --template=TEMPLATE
The form to use for renaming the file. The fields recognised are auth (primary authors family name), title (full title of the book), short_title (abbreviated title), isbn, year (year of publication). The default is ‘%(auth)s%(year)s_%(short_title)s_(isbn%(isbn)s)’.
- --unknown=UNKNOWN
Use this string if value is undefined.
The new name is generated first before the various processing options are applied. In order, characters are stripped from the name, excess whitespace is collapsed and then the case conversion is applied. We suggest you try a dryrun before renaming any files. The file extension, if any, is removed before renaming and re-applied afterwards.
For example, working with 4 files called ‘0763718165.Jones Course.djvu’, ‘helm_0671708821 (orig).pdf’, ‘tutor_9780198568322.rar’, ‘unce.9783540237730.27380.pdf’:
% renamebyisbn.py --dryrun books/* Original books/0763718165.Jones Course.djvu ... ~ extracted ISBN 0763718165 ... ~ found Andersen - Data structures in Java : a laboratory course ~ new name Andersen2001_Data structures in Java_isbn0763718165. ~ new path books/Andersen2001_Data structures in Java_isbn0763718165.djvu. Original books/helm_0671708821 (orig).pdf ... ~ extracted ISBN 0671708821 ... ~ found Helmstetter - What to say when you talk about yourself. ~ new name Helmstetter1990_What to say when you talk about yourself_isbn0671708821. ~ new path books/Helmstetter1990_What to say when you talk about yourself_isbn0671708821.pdf. Original books/tutor_9780198568322.rar ... ~ extracted ISBN 9780198568322 ... ~ found Skilling - Data analysis : a Bayesian tutorial ; [for scientists and engineers] ~ new name Skilling2006_Data analysis_isbn9780198568322. ~ new path books/Skilling2006_Data analysis_isbn9780198568322.rar. Original books/unce.9783540237730.27380.pdf ... ~ extracted ISBN 9783540237730 ... ~ found McDaniel - Uncertainty and surprise in complex systems questions on working with the unexpected ~ new name McDaniel2005_Uncertainty and surprise in complex systems questions on working with the unexpected_isbn9783540237730. ~ new path books/McDaniel2005_Uncertainty and surprise in complex systems questions on working with the unexpected_isbn9783540237730.pdf. % renamebyisbn.py --case lower --replace_whitespace ' ' --template '%(auth)s%(year)s_%(short_title)s_isbn%(isbn)s' books/* Original books/0763718165.Jones Course.djvu ... ~ extracted ISBN 0763718165 ... ~ found Andersen - Data structures in Java : a laboratory course ~ new name andersen2001_data-structures-in-java_isbn0763718165. ~ new path books/andersen2001_data-structures-in-java_isbn0763718165.djvu. ~ renaming file Original books/helm_0671708821 (orig).pdf ... ~ extracted ISBN 0671708821 ... ~ found Helmstetter - What to say when you talk about yourself. ~ new name helmstetter1990_what-to-say-when-you-talk-about-yourself_isbn0671708821. ~ new path books/helmstetter1990_what-to-say-when-you-talk-about-yourself_isbn0671708821.pdf. ~ renaming file Original books/tutor_9780198568322.rar ... ~ extracted ISBN 9780198568322 ... ~ found Skilling - Data analysis : a Bayesian tutorial ; [for scientists and engineers] ~ new name skilling2006_data-analysis_isbn9780198568322. ~ new path books/skilling2006_data-analysis_isbn9780198568322.rar. ~ renaming file Original books/unce.9783540237730.27380.pdf ... ~ extracted ISBN 9783540237730 ... ~ found McDaniel - Uncertainty and surprise in complex systems questions on working with the unexpected ~ new name mcdaniel2005_uncertainty-and-surprise-in-complex-systems-questions-on-working-with-the-unexpected_isbn9783540237730. ~ new path books/mcdaniel2005_uncertainty-and-surprise-in-complex-systems-questions-on-working-with-the-unexpected_isbn9783540237730.pdf. ~ renaming file
Developer notes
biblio.webquery presents several classes that may be useful to other developers:
* BaseWebQuery, a simple class for encapsulating queries to webservices * BaseKeyedWebQuery, ditto except allowing for access keys * XisbnQuery and IsbndbQuery, for fetching bibliographic information from Worldcat xISBN and ISBNdb services respectively * QueryThrottle, for limiting the frequency or total number of service queries. * BibRecord, a general class for holding bibliographic information * PersonalName, a class for holding a name along functions for parsing names into this class.
Consult the API documentation and scripts for further information.
Thanos Vassilakis has posted what looks like a very useful module for querying by ISBN. However it seems to have disappeared from its home website.
The biblio namespace is open to other developers.
References
History
v0.4.3b, 2009-05-07
Include documentation in source distribution.
v0.4b, 2009-05-06
First public release.
v0.2, 2009-02-10
Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file biblio.webquery-0.4.3b.tar.gz
.
File metadata
- Download URL: biblio.webquery-0.4.3b.tar.gz
- Upload date:
- Size: 652.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2216f11630598de7fb3e22c1eafb8f1eff5e25472ba47e91cf07c87cf75f27cb |
|
MD5 | 4a48b59089007c365d4c114d4424e298 |
|
BLAKE2b-256 | 66750df78030d654586af94586880ce2f3918b6e721b047e347ff8ec4539e14f |
File details
Details for the file biblio.webquery-0.4.3b-py2.5.egg
.
File metadata
- Download URL: biblio.webquery-0.4.3b-py2.5.egg
- Upload date:
- Size: 62.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78505d8452afde5cde0d21f080ca1b736751ac87640e3cc6583da34241d7d7b1 |
|
MD5 | 488bf2d53a67285033d89033206e0329 |
|
BLAKE2b-256 | 537353951e0c77927e96bdd0d42a70363545133bc69c5994ab5c57ab27a43ef1 |