挪威国家图书馆urn-pid服务的python客户机
NbUrnClient的Python项目详细描述
这是一个库和一组用于与 挪威国家图书馆提供的soap id服务。
有关该服务的更多信息(挪威语):*关于URN: http://www.nb.no/idtjeneste/about_urn.jsf*关于soap api: http://www.nb.no/idtjeneste/about_urn_webservice.jsf
安装
图书馆可作为 NbUrnClient在pypi上。到 将其安装到所需的python环境中: pip install NbUrnClient
不包括命令行实用程序。只要你有 nburnclient库已安装,您只需下载 bin和config目录,并按照下面的说明操作 配置。
配置
config目录包含yaml配置文件的一个示例 由客户端使用(config.yml.example)。把这个拷贝到e.g. config.yml并用 从国家图书馆收到的。
命令行工具
bin目录包含一组命令行工具,它们使用 图书馆的。
用法示例:
注意:这些示例中的大多数(除了find_urn和 find_urns_for_url)需要有效的用户帐户。
若要保留某个系列中的下一个可用骨灰盒,请使用 reserve_next_urn:
./bin/reserve_next_urn --series-code urn:series:code
服务将返回有关新生成的urn的信息。到 向新生成的urn添加一个url(其中foo是新的urn 上一步返回的地址),使用add_url:
./bin/add_url --urn foo --url http://www.someurl.com
可以将多个URL添加到URN。将其中一个注册为 urn的默认url,使用set_default_url:
./bin/set_default_url --urn foo --url http://www.someurl.com
您可以使用create_urn:
组合前面的步骤./bin/create_urn --series-code urn:series:code --url http://www.someurl.com/
服务将返回已创建的urn,其中包含指定的url 已注册并设置为默认值。
您可以使用 find_urn:
./bin/find_urn --urn foo
您还可以请求包含特定url的所有urn的信息 使用find_urns_for_url:
./bin/find_urns_for_url --url http://www.someurl.com
库
nb_urn_client目录包含用于通信的库 使用soap api。它是soap api调用的瘦包装。到 看看它是如何使用的,看看bin目录中的命令。
库使用示例:
下面的示例使用库或多或少地 与命令行工具中的示例相同:
importnb_urn_client# Instantiate a client with some config filec=nb_urn_client.NbUrnClient(config_file="config.yml")# You need to login firstc.login()# Reserve the next available URN in the given seriesnew_urn=c.reserve_next_urn('urn:series:code')# Register some valid URL for the newly created URNc.add_url(new_urn.URN,"http://www.someurl.com/")# Register another URL for the same URNc.add_url(new_urn.URN,"http://www.someotherurl.com/")# Set one of the registered URLs to be the default URLc.set_default_url(new_urn.URN,"http://www.someurl.com/")##################################################### ALTERNATIVE: Using create_urn:# new_urn = c.create_urn('urn:series:code', 'http://www.someurl.com/')# c.add_url(new_urn.URN, 'http://www.someotherurl.com/')##################################################### Retrieve the URN you just created and have a lookprintc.find_urn(new_urn.URN)# Retrieve all URNs containing some URL and have a lookprintc.find_urns_for_url("http://www.someurl.org")# Logout when you're donec.logout()