本文整理汇总了Python中hs_restclient.HydroShare.getScienceMetadata方法的典型用法代码示例。如果您正苦于以下问题:Python HydroShare.getScienceMetadata方法的具体用法?Python HydroShare.getScienceMetadata怎么用?Python HydroShare.getScienceMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hs_restclient.HydroShare
的用法示例。
在下文中一共展示了HydroShare.getScienceMetadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_scimeta_json
# 需要导入模块: from hs_restclient import HydroShare [as 别名]
# 或者: from hs_restclient.HydroShare import getScienceMetadata [as 别名]
def test_get_scimeta_json(self):
hs = HydroShare(prompt_auth=False)
scimeta = hs.getScienceMetadata('511debf8858a4ea081f78d66870da76c')
self.assertEqual(scimeta['title'], 'Great Salt Lake Level and Volume')
self.assertEqual(len(scimeta['creators']), 2)
self.assertEqual(len(scimeta['contributors']), 1)
self.assertEqual(len(scimeta['coverages']), 1)
self.assertEqual(len(scimeta['dates']), 2)
self.assertEqual(scimeta['description'], 'Time series of level, area and volume in the Great Salt Lake. Volume and area of the Great Salt Lake are derived from recorded levels')
self.assertEqual(scimeta['formats'][0]['value'], 'image/tiff')
self.assertEqual(len(scimeta['funding_agencies']), 1)
self.assertEqual(len(scimeta['identifiers']), 1)
self.assertEqual(scimeta['language'], 'eng')
self.assertEqual(scimeta['rights'], 'This resource is shared under the Creative Commons Attribution CC BY. http://creativecommons.org/licenses/by/4.0/')
self.assertEqual(scimeta['type'], 'http://www.hydroshare.org/terms/GenericResource')
self.assertEqual(scimeta['publisher'], None)
self.assertEqual(len(scimeta['sources']), 0)
self.assertEqual(len(scimeta['relations']), 0)
self.assertEqual(len(scimeta['subjects']), 2)
示例2: hydroshare
# 需要导入模块: from hs_restclient import HydroShare [as 别名]
# 或者: from hs_restclient.HydroShare import getScienceMetadata [as 别名]
#.........这里部分代码省略.........
"""
if not os.path.exists(self.auth_path):
print('\nThe hs_utils library requires a secure connection to '
'your HydroShare account.')
if username is None:
username = input('Please enter your HydroShare username: ') \
.strip()
p = getpass.getpass('Enter the HydroShare password for user '
'\'%s\': ' % username)
auth = HydroShareAuthBasic(username=username, password=p)
if self.cache:
with open(self.auth_path, 'wb') as f:
pickle.dump(auth, f, protocol=2)
else:
with open(self.auth_path, 'rb') as f:
auth = pickle.load(f)
return auth
def getResourceMetadata(self, resid):
"""Gets metadata for a specified resource.
args:
-- resid: hydroshare resource id
returns:
-- resource metadata object
"""
science_meta = self.hs.getScienceMetadata(resid)
system_meta = self.hs.getSystemMetadata(resid)
return resource.ResourceMetadata(system_meta, science_meta)
def createHydroShareResource(self, abstract, title, derivedFromId=None,
keywords=[], resource_type='GenericResource',
content_files=[], public=False):
"""Creates a hydroshare resource.
args:
-- abstract: abstract for resource (str, required)
-- title: title of resource (str, required)
-- derivedFromId: id of parent hydroshare resource (str, default=>None)
-- keywords: list of subject keywords (list, default=>[])
-- resource_type: type of resource to create (str, default=>
'GenericResource')
-- content_files: data to save as resource content (list, default=>[])
-- public: resource sharing status (bool, default=>False)
returns:
-- None
"""
# query the hydroshare resource types and make sure that
# resource_type is valid
restypes = {r.lower(): r for r in self.hs.getResourceTypes()}
try:
res_type = restypes[resource_type]
except KeyError:
display(HTML('<b style="color:red;">[%s] is not a valid '
'HydroShare resource type.</p>' % resource_type))
return None
示例3: test_get_scimeta
# 需要导入模块: from hs_restclient import HydroShare [as 别名]
# 或者: from hs_restclient.HydroShare import getScienceMetadata [as 别名]
def test_get_scimeta(self):
hs = HydroShare()
scimeta = hs.getScienceMetadata('6dbb0dfb8f3a498881e4de428cb1587c')
self.assertTrue(scimeta.find("""<rdf:Description rdf:about="http://www.hydroshare.org/resource/6dbb0dfb8f3a498881e4de428cb1587c">""") != -1)