本文整理汇总了Python中Tribler.Core.API.TorrentDef.save方法的典型用法代码示例。如果您正苦于以下问题:Python TorrentDef.save方法的具体用法?Python TorrentDef.save怎么用?Python TorrentDef.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Core.API.TorrentDef
的用法示例。
在下文中一共展示了TorrentDef.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ns_metadata
# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import save [as 别名]
def test_ns_metadata(self):
dummydata = "HalloWereld"
t = TorrentDef()
t.set_metadata(dummydata)
fn = os.path.join(os.getcwd(),"file.wmv")
t.add_content(fn)
t.set_tracker(TRACKER)
t.finalize()
[handle,filename] = tempfile.mkstemp()
os.close(handle)
t.save(filename)
t2 = TorrentDef.load(filename)
self.assert_(t2.get_metadata() == dummydata)
示例2: subtest_add_content_file_save
# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import save [as 别名]
def subtest_add_content_file_save(self,merkle=True):
""" Add a single file to a TorrentDef and save the latter"""
t = TorrentDef()
t.set_create_merkle_torrent(merkle)
fn = os.path.join(os.getcwd(),"file.wmv")
t.add_content(fn)
t.set_tracker(TRACKER)
t.finalize()
tfn = os.path.join(os.getcwd(),"gen.torrent")
t.save(tfn)
f = open(tfn,"rb")
bdata = f.read()
f.close()
os.remove(tfn)
data = bdecode(bdata)
metainfo = t.get_metainfo()
self.general_check(metainfo)
self.assert_(metainfo == data)