def fetch_plist(uri, key='', fallback=None):
    import io, plistlib, urllib.request

    with urllib.request.urlopen(uri) as response:
        data = response.read()

    plist = plistlib.loads(data)

    yield valentina.TableHeader([
        ('key', str),
        ('value', str)
    ])

    if key:
        yield key, plist.get(key, fallback)
    else:
        for k, v in plist.items():
            yield k, v


def valentina_extension_init(db):
    valentina.create_procedure('fetch_plist', fetch_plist)
