当前位置: 首页>>代码示例>>Python>>正文


Python TempFS.makedir方法代码示例

本文整理汇总了Python中fs.tempfs.TempFS.makedir方法的典型用法代码示例。如果您正苦于以下问题:Python TempFS.makedir方法的具体用法?Python TempFS.makedir怎么用?Python TempFS.makedir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fs.tempfs.TempFS的用法示例。


在下文中一共展示了TempFS.makedir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestImporter

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import makedir [as 别名]
class TestImporter (TestCase):

    def setUp(self):
        TestCase.setUp(self)
        self.fs = TempFS()
        self.importer = Importer()
        
    def test_finds_index_file_in_a_subdirectory(self):
        self.fs.makedir("directory")
        self.fs.setcontents("directory/file.txt", "test")
        index_file = self.importer._find_index_file(self.fs, ["*.txt"])
        assert_equals("directory/file.txt", index_file)
开发者ID:rblinzler,项目名称:openmemo,代码行数:14,代码来源:test_importer.py

示例2: TestFUSE

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import makedir [as 别名]
class TestFUSE(unittest.TestCase,FSTestCases):

    def setUp(self):
        self.temp_fs = TempFS()
        self.temp_fs.makedir("root")
        self.temp_fs.makedir("mount")
        self.mounted_fs = self.temp_fs.opendir("root")
        self.mount_point = self.temp_fs.getsyspath("mount")
        self.fs = OSFS(self.temp_fs.getsyspath("mount"))
        self.mount_proc = fuse.mount(self.mounted_fs,self.mount_point)

    def tearDown(self):
        self.mount_proc.unmount()
        self.temp_fs.close()

    def check(self,p):
        return self.mounted_fs.exists(p)
开发者ID:svn2github,项目名称:pyfilesystem,代码行数:19,代码来源:test_expose.py

示例3: test_remove_all

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import makedir [as 别名]
 def test_remove_all(self):
     """Test remove_all function"""
     fs = TempFS()
     fs.setcontents("f1", "file 1")
     fs.setcontents("f2", "file 2")
     fs.setcontents("f3", "file 3")
     fs.makedir("foo/bar", recursive=True)
     fs.setcontents("foo/bar/fruit", "apple")        
     fs.setcontents("foo/baz", "baz")
     
     utils.remove_all(fs, "foo/bar")
     self.assert_(not fs.exists("foo/bar/fruit"))
     self.assert_(fs.exists("foo/bar"))
     self.assert_(fs.exists("foo/baz"))
     utils.remove_all(fs,  "")
     self.assert_(not fs.exists("foo/bar/fruit"))
     self.assert_(not fs.exists("foo/bar/baz"))
     self.assert_(not fs.exists("foo/baz"))
     self.assert_(not fs.exists("foo"))
     self.assert_(not fs.exists("f1"))
     self.assert_(fs.isdirempty('/'))
开发者ID:pombreda,项目名称:agilepyfs,代码行数:23,代码来源:test_utils.py

示例4: TestFUSE

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import makedir [as 别名]
    class TestFUSE(unittest.TestCase,FSTestCases,ThreadingTestCases):

        def setUp(self):
            self.temp_fs = TempFS()            
            self.temp_fs.makedir("root")
            self.temp_fs.makedir("mount")
            self.mounted_fs = self.temp_fs.opendir("root")
            self.mount_point = self.temp_fs.getsyspath("mount")
            self.fs = OSFS(self.temp_fs.getsyspath("mount"))
            self.mount_proc = fuse.mount(self.mounted_fs,self.mount_point)

        def tearDown(self):
            self.mount_proc.unmount()
            try:
                self.temp_fs.close()
            except OSError:
                # Sometimes FUSE hangs onto the mountpoint if mount_proc is
                # forcibly killed.  Shell out to fusermount to make sure.
                fuse.unmount(self.mount_point)
                self.temp_fs.close()

        def check(self,p):
            return self.mounted_fs.exists(p)
开发者ID:anthonybishopric,项目名称:pyboxfs,代码行数:25,代码来源:test_expose.py

示例5: wrap_error

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import makedir [as 别名]
                    #write(wrap_prefix(prefix[:-1] + '       ') + wrap_error('max recursion levels reached'))
                else:
                    print_dir(fs, pathjoin(path, item), levels[:] + [is_last_item])
            else:
                write('%s %s' % (wrap_prefix(prefix + char_line), wrap_filename(item)))

        return len(dir_listing)

    print_dir(fs, path)
    return dircount[0], filecount[0]


if __name__ == "__main__":
    from fs.tempfs import TempFS
    from six import b
    t1 = TempFS()
    t1.setcontents("foo", b("test"))
    t1.makedir("bar")
    t1.setcontents("bar/baz", b("another test"))

    t1.tree()

    t2 = TempFS()
    print t2.listdir()
    movedir(t1, t2)

    print t2.listdir()
    t1.tree()
    t2.tree()

开发者ID:ctismer,项目名称:pyfilesystem,代码行数:31,代码来源:utils.py

示例6: TestSuperMemoQAImport

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import makedir [as 别名]

#.........这里部分代码省略.........
        assert_equals(u"question\nend of question", self.cos[0]['question'])
        assert_equals(u"answer\nend of answer", self.cos[0]['answer'])            
        
    def test_multiline_question_and_answer_lines_are_rtrimmed(self):
        data = "Q: question  \nQ: end of question  \nA: answer  \nA: end of answer  "
        self.fs.setcontents('cards.txt', data)
        self.importer()
        assert_equals(1, len(self.cos))
        assert_equals(u"question\nend of question", self.cos[0]['question'])
        assert_equals(u"answer\nend of answer", self.cos[0]['answer'])            
 
    def test_custom_encoding(self):
        data = (u"Q: być szczerym\nA: to be frank").encode('cp1250')
        self.fs.setcontents('cards.txt', data)
        self.importer.encoding = 'cp1250'
        self.importer()        
        assert_equals(1, len(self.cos))
        assert_equals(unicode, type(self.cos[0]['question']))
        assert_equals(unicode, type(self.cos[0]['answer']))
        assert_equals(u"być szczerym", self.cos[0]['question'])
        assert_equals(u"to be frank", self.cos[0]['answer']) 
               
    def test_html_tags_are_preserved(self):
        data = """Q: hist: When did we <b>land on the moon</b>?
A: 1969 <i>(July 20)</i>"""
        self.fs.setcontents('cards.txt', data)
        self.importer()
        assert_equals(u"hist: When did we <b>land on the moon</b>?", self.cos[0]['question'])
        assert_equals(u"1969 <i>(July 20)</i>", self.cos[0]['answer'])
        
    def test_card_with_image(self):
        data = u"""Q: <img src="image.jpg" />
A: answer"""
        self.fs.setcontents('index.txt', data)
        image_data = self.data.getcontents('small.jpg')
        self.fs.setcontents('image.jpg', image_data)
        self.importer()

        assert_equals(1, len(self.cos))
        assert_equals(u'<img src="/images/image.jpg"/>', self.cos[0]['question'])
        assert_equals(u"answer", self.cos[0]['answer'])

        assert_equals(1, len(self.images))
        assert_equals('image.jpg', self.images[0]['filename'])
        assert_equals('image/jpeg', self.images[0]['mime_type'])
        assert_true(image_data == self.images[0]['data'])
        
    def test_card_with_index_in_subdirectory_and_image(self):
        data = u'Q: <img src="image.jpg" />\nA: answer'
        self.fs.makedir('dir')
        self.fs.setcontents('dir/index.txt', data)
        image_data = self.data.getcontents('small.jpg')
        self.fs.setcontents('dir/image.jpg', image_data)
        self.importer()

        assert_equals(1, len(self.cos))
        assert_equals(u'<img src="/images/image.jpg"/>', self.cos[0]['question'])
        assert_equals(u"answer", self.cos[0]['answer'])

        assert_equals(1, len(self.images))
        assert_equals('image.jpg', self.images[0]['filename'])
        assert_equals('image/jpeg', self.images[0]['mime_type'])
        assert_true(image_data == self.images[0]['data'])     
        
    def test_card_with_audio(self):
        data = u"""Q: <span class="audio autoplay"><a href="button.mp3" /></span>
A: answer"""
        self.fs.setcontents('index.txt', data)
                
        sound_data = self.data.getcontents('button.mp3')
        self.fs.setcontents('button.mp3', sound_data)

        self.importer()

        assert_equals(1, len(self.cos))
        assert_equals(u'<span class="audio autoplay"><a href="/sounds/button.mp3"/></span>', self.cos[0]['question'])
        assert_equals(u"answer", self.cos[0]['answer'])

        assert_equals(1, len(self.sounds))
        assert_equals('button.mp3', self.sounds[0]['filename'])
        assert_equals('audio/mpeg', self.sounds[0]['mime_type'])
        assert_true(sound_data == self.sounds[0]['data'])
                       
    def test_byte_order_mark_in_utf8_files_is_removed(self):
        data = u'\ufeffQ: \uac00\uac8c\r\nA: store'
        self.fs.setcontents('index.txt', data.encode('utf8'))
        self.importer()
        assert_equals(1, len(self.cos))
        assert_equals(u"\uac00\uac8c", self.cos[0]['question'])
        assert_equals(u"store", self.cos[0]['answer'])   
        
    def test_invalid_xml_results_in_input_error(self):
        data = u'Q: <b>question\nA: answer'
        self.fs.setcontents('index.txt', data)
        assert_raises(ConversionFailure, self.importer)        
        
    def test_invalid_fields_number_in_input_error(self):
        data = u'Q: question'
        self.fs.setcontents('index.txt', data)
        assert_raises(ConversionFailure, self.importer)                                
开发者ID:rblinzler,项目名称:openmemo,代码行数:104,代码来源:test_sm_qa_import.py


注:本文中的fs.tempfs.TempFS.makedir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。