本文整理匯總了Python中fs.memoryfs.MemoryFS.walk方法的典型用法代碼示例。如果您正苦於以下問題:Python MemoryFS.walk方法的具體用法?Python MemoryFS.walk怎麽用?Python MemoryFS.walk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fs.memoryfs.MemoryFS
的用法示例。
在下文中一共展示了MemoryFS.walk方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: check_property
# 需要導入模塊: from fs.memoryfs import MemoryFS [as 別名]
# 或者: from fs.memoryfs.MemoryFS import walk [as 別名]
def check_property(self, descriptor):
xmodule_api_fs = MemoryFS()
xblock_api_fs = MemoryFS()
descriptor.runtime.export_fs = xblock_api_fs
xblock_node = etree.Element('unknown')
descriptor.add_xml_to_node(xblock_node)
xmodule_node = etree.fromstring(descriptor.export_to_xml(xmodule_api_fs))
self.assertEquals(list(xmodule_api_fs.walk()), list(xblock_api_fs.walk()))
self.assertEquals(etree.tostring(xmodule_node), etree.tostring(xblock_node))
示例2: TestWalk
# 需要導入模塊: from fs.memoryfs import MemoryFS [as 別名]
# 或者: from fs.memoryfs.MemoryFS import walk [as 別名]
class TestWalk(unittest.TestCase):
def setUp(self):
self.fs = MemoryFS()
self.fs.setcontents('a.txt', 'hello')
self.fs.setcontents('b.txt', 'world')
self.fs.makeopendir('foo').setcontents('c', '123')
self.fs.makeopendir('.svn').setcontents('ignored', '')
def test_wildcard(self):
for dir_path, paths in self.fs.walk(wildcard='*.txt'):
for path in paths:
self.assert_(path.endswith('.txt'))
for dir_path, paths in self.fs.walk(wildcard=lambda fn:fn.endswith('.txt')):
for path in paths:
self.assert_(path.endswith('.txt'))
def test_dir_wildcard(self):
for dir_path, paths in self.fs.walk(dir_wildcard=lambda fn:not fn.endswith('.svn')):
for path in paths:
self.assert_('.svn' not in path)