26. Datalink: Related Infos

Datalink is a standard for “linking” files to datasets. Think previews, extracted objects, etc.

After a data discovery query on a datalink-enabled service, you can use the result’s iter_datalinks method:

for dl in result.iter_datalinks():
  for link in dl: # multiple links per dataset
    print link

Each link has a URL, a description, and machine-readable semantics. E.g., to load previews:

for dl in matches.iter_datalinks():
    prev_url = dl.bysemantics("#preview").next()["access_url"]
    im = Image.open(io.BytesIO(requests.get(prev_url).content))
    ...

[See datalink-previews.py]

Problems

(1)

Write a function get_available_semantics(dl) -> set returning a set of the semantics available for a given datalink.

What semantics do you get for the links coming from the datalink-previews program?

Files


Markus Demleitner, Hendrik Heinl