本文整理汇总了Python中fs.osfs.OSFS.setcontents方法的典型用法代码示例。如果您正苦于以下问题:Python OSFS.setcontents方法的具体用法?Python OSFS.setcontents怎么用?Python OSFS.setcontents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs.osfs.OSFS
的用法示例。
在下文中一共展示了OSFS.setcontents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _decode
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import setcontents [as 别名]
if path.lower().startswith("_autorun."):
path = path[1:]
return path
def _decode(self,path):
path = relpath(normpath(path))
path = path.replace("__colon__",":")
if not self.allow_autorun:
if path.lower().startswith("autorun."):
path = "_" + path
return path
if __name__ == "__main__":
import os, os.path
import tempfile
from fs.osfs import OSFS
from fs.memoryfs import MemoryFS
path = tempfile.mkdtemp()
try:
fs = OSFS(path)
#fs = MemoryFS()
fs.setcontents("test1.txt","test one")
flags = DOKAN_OPTION_DEBUG|DOKAN_OPTION_STDERR|DOKAN_OPTION_REMOVABLE
mount(fs, "Q", foreground=True, numthreads=1, flags=flags)
fs.close()
finally:
OSFS(path).removedir("/",force=True)
示例2: _decode
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import setcontents [as 别名]
return path
def _decode(self,path):
path = relpath(normpath(path))
path = path.replace("__colon__",":")
if not self.allow_autorun:
if path.lower().startswith("autorun."):
path = "_" + path
return path
if __name__ == "__main__":
import os, os.path
import tempfile
from fs.osfs import OSFS
from fs.memoryfs import MemoryFS
from shutil import rmtree
from six import b
path = tempfile.mkdtemp()
try:
fs = OSFS(path)
#fs = MemoryFS()
fs.setcontents("test1.txt",b("test one"))
flags = DOKAN_OPTION_DEBUG|DOKAN_OPTION_STDERR|DOKAN_OPTION_REMOVABLE
mount(fs, "Q", foreground=True, numthreads=1, flags=flags)
fs.close()
finally:
rmtree(path)