本文整理汇总了Python中synapseclient.File.fileNameOverride方法的典型用法代码示例。如果您正苦于以下问题:Python File.fileNameOverride方法的具体用法?Python File.fileNameOverride怎么用?Python File.fileNameOverride使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类synapseclient.File
的用法示例。
在下文中一共展示了File.fileNameOverride方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Entity
# 需要导入模块: from synapseclient import File [as 别名]
# 或者: from synapseclient.File import fileNameOverride [as 别名]
#.........这里部分代码省略.........
folder = syn.get(folder)
assert folder.name == 'Test Folder'
assert folder.parentId == project.id
assert folder.description == 'The rejects from the other folder'
assert folder.pi[0] == 3.14159265359
# Test CRUD on Files, check unicode
path = utils.make_bogus_data_file()
schedule_for_cleanup(path)
a_file = File(path, parent=folder, description=u'Description with funny characters: Déjà vu, ประเทศไทย, 中国',
contentType='text/flapdoodle',
foo='An arbitrary value',
bar=[33,44,55],
bday=Datetime(2013,3,15),
band=u"Motörhead",
lunch=u"すし")
a_file = syn.store(a_file)
assert a_file.path == path
a_file = syn.getEntity(a_file)
assert a_file.description == u'Description with funny characters: Déjà vu, ประเทศไทย, 中国', u'description= %s' % a_file.description
assert a_file['foo'][0] == 'An arbitrary value', u'foo= %s' % a_file['foo'][0]
assert a_file['bar'] == [33,44,55]
assert a_file['bday'][0] == Datetime(2013,3,15)
assert a_file.contentType == 'text/flapdoodle', u'contentType= %s' % a_file.contentType
assert a_file['band'][0] == u"Motörhead", u'band= %s' % a_file['band'][0]
assert a_file['lunch'][0] == u"すし", u'lunch= %s' % a_file['lunch'][0]
a_file = syn.downloadEntity(a_file)
assert filecmp.cmp(path, a_file.path)
assert_raises(ValueError,File,a_file.path,parent=folder,dataFileHandleId=56456)
b_file = File(name="blah",parent=folder,dataFileHandleId=a_file.dataFileHandleId)
b_file = syn.store(b_file)
assert b_file.dataFileHandleId == a_file.dataFileHandleId
# Update the File
a_file.path = path
a_file['foo'] = 'Another arbitrary chunk of text data'
a_file['new_key'] = 'A newly created value'
a_file = syn.updateEntity(a_file)
assert a_file['foo'][0] == 'Another arbitrary chunk of text data'
assert a_file['bar'] == [33,44,55]
assert a_file['bday'][0] == Datetime(2013,3,15)
assert a_file.new_key[0] == 'A newly created value'
assert a_file.path == path
assert a_file.versionNumber == 1, "unexpected version number: " + str(a_file.versionNumber)
#Test create, store, get Links
link = Link(a_file['id'],
targetVersion=a_file.versionNumber,
parent=project)
link = syn.store(link)
assert link['linksTo']['targetId'] == a_file['id']
assert link['linksTo']['targetVersionNumber'] == a_file.versionNumber
assert link['linksToClassName'] == a_file['concreteType']
testLink = syn.get(link)
assert testLink == link
link = syn.get(link,followLink= True)
assert link['foo'][0] == 'Another arbitrary chunk of text data'
assert link['bar'] == [33,44,55]
assert link['bday'][0] == Datetime(2013,3,15)
assert link.new_key[0] == 'A newly created value'
assert utils.equal_paths(link.path, path)
assert link.versionNumber == 1, "unexpected version number: " + str(a_file.versionNumber)
# Upload a new File and verify
new_path = utils.make_bogus_data_file()
schedule_for_cleanup(new_path)
a_file = syn.uploadFile(a_file, new_path)
a_file = syn.downloadEntity(a_file)
assert filecmp.cmp(new_path, a_file.path)
assert a_file.versionNumber == 2
# Make sure we can still get the older version of file
old_random_data = syn.get(a_file.id, version=1)
assert filecmp.cmp(old_random_data.path, path)
tmpdir = tempfile.mkdtemp()
schedule_for_cleanup(tmpdir)
## test file name override
a_file.fileNameOverride = "peaches_en_regalia.zoinks"
syn.store(a_file)
## TODO We haven't defined how filename override interacts with
## TODO previously cached files so, side-step that for now by
## TODO making sure the file is not in the cache!
syn.cache.remove(a_file.dataFileHandleId, delete=True)
a_file_retreived = syn.get(a_file, downloadLocation=tmpdir)
assert os.path.basename(a_file_retreived.path) == a_file.fileNameOverride, os.path.basename(a_file_retreived.path)
## test getting the file from the cache with downloadLocation parameter (SYNPY-330)
a_file_cached = syn.get(a_file.id, downloadLocation=tmpdir)
assert a_file_cached.path is not None
assert os.path.basename(a_file_cached.path) == a_file.fileNameOverride, a_file_cached.path
print("\n\nList of files in project:\n")
syn._list(project, recursive=True)