1.1. igsn_lib Package¶
Methods
|
Return the value part of an IGSN. |
|
|
|
Resolve an IGSN value |
|
Use N2T to resolve the identifier |
Detail
Utility methods for working with IGSNs and dates.
-
igsn_lib.DEFAULT_RESOLVE_HEADERS= {'Accept': 'application/json, application/ld+json;q=0.9, text/json;q=0.8; text/xml;q=0.7, text/html;q=0.5', 'Accept-Language': 'en-US, en;q=0.9', 'User-Agent': 'igsn_lib/0.1.0'}¶ Default headers for talking to the resolver
-
igsn_lib.IGSN_RESOLVER_URL= 'http://igsn.org/'¶ Resolver URL.
Note that this seems to always delegate to hdl.handle.net
-
igsn_lib.N2T_RESOLVER_URL= 'https://n2t.net/'¶ N2T Resolver URL.
N2T will resolve many types of identifiers, including IGSNs
-
igsn_lib.normalize(igsn_str)[source]¶ Return the value part of an IGSN.
Note this method does not verify the prefix. The returned value may or may not be an actual IGSN.
- Parameters:
igsn_str – IGSN string
- Returns:
string, value part of IGSN.
Examples
import igsn_lib # Variants of the fictitious IGSN "ABCD123" print(igsn_lib.normalize("10273/AbCd123")) print(igsn_lib.normalize("http://hdl.handle.net/10273/ABCD123")) print(igsn_lib.normalize("IGSN: abcd123")) print(igsn_lib.normalize("info:hdl/10273/ABCD123")) print(igsn_lib.normalize("http://some.url/with/perhaps/igsn/ABCD123")) print(igsn_lib.normalize("http://igsn.org/ABCD123")) # Not an IGSN: print(igsn_lib.normalize("info:hdl/20.1000/ABCD123"))
ABCD123 ABCD123 ABCD123 ABCD123 ABCD123 ABCD123 None
-
igsn_lib.resolve(igsn_value, include_body=False, headers=None)[source]¶ Resolve an IGSN value
#TODO: add support for link headers
- Parameters:
igsn_value – pre-normalized IGSN string
include_body – (bool) If True then return response body, otherwise only HEAD request is made
headers – (dict) Optional headers to send in request
- Returns:
list of requests.Response objects
Examples
import pprint import json import igsn_lib res = igsn_lib.resolve('PRR047915', include_body=True) print(json.dumps(res[-1].json(), indent=2))
{ "sample": { "qrcode_img_src": "https://app.geosamples.org/qrimage.php?igsn=PRR047915", "user_code": "PRR", "igsn": "PRR047915", "name": "PRR-47915", "sample_type": "Dredge", "publish_date": "2020-09-29", "external_urls": { "external_url": { "url": "http://research.bpcrc.osu.edu/rr/collection/object/93847", "description": [], "url_type": "regular URL" } }, "collection_method": "Manual", "latitude": "-73.36667", "longitude": "177.6133", "elevation_unit": [], "collector": "Florida State University", "current_archive": "Polar Rock Repository, Byrd Polar and Climate Research Center, Ohio State University", "current_archive_contact": "Curator" } }
-
igsn_lib.resolveN2T(identifier, include_body=False, headers=None, callback=None)[source]¶ Use N2T to resolve the identifier
- Parameters:
identifier – pre-normalized IGSN string
include_body – (bool) If True then return response body, otherwise only HEAD request is made
headers – (dict) Optional headers to send in request
callback – (method) Optional method to call after completion of each step of the resolve chain
Returns: