elm.web.osti.OstiList
- class OstiList(url, n_pages=1)[source]
Bases:
list
Class to retrieve and handle multiple OSTI records from an API URL.
- Parameters:
url (str) –
- OSTI API URL to request, see this for details:
n_pages (int) – Number of pages to get from the API. Typical response has 20 entries per page. Default of 1 ensures that this class doesnt hang on a million responses.
Methods
append
(object, /)Append object to the end of the list.
clear
()Remove all items from list.
copy
()Return a shallow copy of the list.
count
(value, /)Return number of occurrences of value.
download
(out_dir)Download all PDFs from the records in this OSTI object into a directory.
extend
(iterable, /)Extend list by appending elements from the iterable.
from_osti_ids
(oids)Initialize OSTI records from one or more numerical IDS
index
(value[, start, stop])Return first index of value.
insert
(index, object, /)Insert object before index.
pop
([index])Remove and return item at index (default last).
remove
(value, /)Remove first occurrence of value.
reverse
()Reverse IN PLACE.
sort
(*[, key, reverse])Sort the list in ascending order and return None.
Attributes
Base OSTI API URL.
Get a meta dataframe with details on all of the OSTI records.
- BASE_URL = 'https://www.osti.gov/api/v1/records'
Base OSTI API URL. This can be appended with search parameters
- download(out_dir)[source]
Download all PDFs from the records in this OSTI object into a directory. PDFs will be given file names based on their OSTI record ID
- Parameters:
out_dir (str) – Directory to download PDFs to. This directory will be created if it does not already exist.
- property meta
Get a meta dataframe with details on all of the OSTI records.
- Returns:
pd.DataFrame
- __add__(value, /)
Return self+value.
- __mul__(value, /)
Return self*value.
- append(object, /)
Append object to the end of the list.
- clear()
Remove all items from list.
- copy()
Return a shallow copy of the list.
- count(value, /)
Return number of occurrences of value.
- extend(iterable, /)
Extend list by appending elements from the iterable.
- classmethod from_osti_ids(oids)[source]
Initialize OSTI records from one or more numerical IDS
- Parameters:
oids (list) – List of string or integer OSTI IDs which are typically 7 digit numbers
- Returns:
out (OstiList) – OstiList object with entries for each oid input.
- index(value, start=0, stop=9223372036854775807, /)
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)
Insert object before index.
- pop(index=-1, /)
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()
Reverse IN PLACE.
- sort(*, key=None, reverse=False)
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.