當前位置: 首頁>>代碼示例>>Python>>正文


Python Path.mkdir方法代碼示例

本文整理匯總了Python中src.tools.path.Path.mkdir方法的典型用法代碼示例。如果您正苦於以下問題:Python Path.mkdir方法的具體用法?Python Path.mkdir怎麽用?Python Path.mkdir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在src.tools.path.Path的用法示例。


在下文中一共展示了Path.mkdir方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_single_html_book

# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import mkdir [as 別名]
 def create_single_html_book(self, book_package):
     title = book_package.get_title()
     if not title:
         # 電子書題目為空時自動跳過
         # 否則會發生『rm -rf / 』的慘劇
         return
     Path.reset_path()
     Path.chdir(Path.result_path)
     Path.rmdir(u'./' + title)
     Path.mkdir(u'./' + title)
     Path.chdir(u'./' + title)
     page = []
     for book in book_package.book_list:
         page += book.page_list
     content = u' \r\n '.join([Match.html_body(x.content) for x in page]).replace(u'../images/', u'./images/')
     with open(TemplateConfig.content_base_uri) as html:
         content = html.read().format(title=title, body=content).replace(u'../style/', u'./')
     with open(title + u'.html', 'w') as html:
         html.write(content)
     Path.copy(Path.html_pool_path + u'/../{}/OEBPS/images'.format(title), u'./images')
     Path.copy(Path.www_css + u'/customer.css', u'./customer.css')
     Path.copy(Path.www_css + u'/markdown.css', u'./markdown.css')
     Path.copy(Path.www_css + u'/normalize.css', u'./normalize.css')
     Path.reset_path()
     return
開發者ID:HowieWang,項目名稱:jianshu2e-book,代碼行數:27,代碼來源:book.py

示例2: init_epub_path

# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import mkdir [as 別名]
 def init_epub_path(work_path):
     u"""
     設置工作地址,根據該路徑進行創建文件夾,生成epub,壓縮等操作
     """
     EpubPath.set_work_path(work_path)
     Path.mkdir(EpubPath.meta_inf_path)
     Path.mkdir(EpubPath.oebps_path)
     Path.chdir(EpubPath.oebps_path)
     Path.mkdir(EpubPath.html_path)
     Path.mkdir(EpubPath.image_path)
     Path.mkdir(EpubPath.style_path)
     return
開發者ID:gitter-badger,項目名稱:EE-Book,代碼行數:14,代碼來源:epub_path.py

示例3: create_single_html_book

# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import mkdir [as 別名]
 def create_single_html_book(self):
     title = '_'.join([book.epub.title for book in self.book_list])
     title = title.strip()[:128] # 避開window文件名長度限製
     title = ExtraTools.fix_filename(title) # 移除特殊字符
     Path.reset_path()
     Path.chdir(Path.result_path)
     Path.rmdir(u'./' + title)
     Path.mkdir(u'./' + title)
     Path.chdir(u'./' + title)
     page = []
     for book in self.book_list:
         page += book.page_list
     content = ' \r\n<hr /> \r\n '.join([Match.html_body(x.content) for x in page]).replace('../images/', './images/')
     with open(Path.base_path + '/src/template/content/single_html.html') as html:
         template = html.read().format(title=title, content=content)
     with open(title + u'.html', 'w') as html:
         html.write(template)
     shutil.copytree(Path.html_pool_path + u'/../{}/OEBPS/images'.format(title), './images')
     shutil.copy(Path.www_css + '/front.css' , './front.css')
     shutil.copy(Path.www_css + '/markdown.css' , './markdown.css')
     Path.reset_path()
     return
開發者ID:GTagent,項目名稱:ZhihuHelp__Python,代碼行數:24,代碼來源:epub_creator.py

示例4: add_book

# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import mkdir [as 別名]
    def add_book(self):
        u"""
        打開已經在文件係統的電子書到電子書管理器中
        :return:
        """
        # Get filename and show only .epub files    Mac 係統下返回的是native fiel dialog
        book_path = QtGui.QFileDialog.getOpenFileName(self, u'打開Epub格式電子書', ".", "(*.epub)")

        if str(book_path) is '':
            # 沒有選中電子書
            return

        if os.path.dirname(str(book_path))+os.sep != str(LIBRARY_DIR):
            shutil.copy(str(book_path), LIBRARY_DIR)

        file_name = os.path.basename(str(book_path))
        book_id = file_name.split('.epub')[0]
        bookdata_book_catalog = LIBRARY_DIR+book_id

        Path.mkdir(bookdata_book_catalog)

        Debug.logger.debug(u"移入bookdata中的是:" + str(LIBRARY_DIR+file_name))
        Debug.logger.debug(u"bookdata中的書:" + str(bookdata_book_catalog))
        Debug.logger.debug(u"book_path:" + os.path.dirname(str(book_path)))
        if os.path.dirname(str(book_path)) != bookdata_book_catalog:
            try:
                shutil.move(LIBRARY_DIR+file_name, bookdata_book_catalog)
            except shutil.Error:
                Debug.logger.debug(u"TODO:添加過這個書,刪除原來的書")
                pass
        else:
            Debug.logger.debug(u"是相同文件夾, 添加的是bookdata中的書")
        os.remove(LIBRARY_DIR+file_name)
        book = Book(book_id)
        book.date = time.strftime(ISOTIMEFORMAT, time.localtime())
        insert_library(book)
        self.update_library()
開發者ID:bindx,項目名稱:EE-Book,代碼行數:39,代碼來源:ui.py

示例5: download_button_clicked

# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import mkdir [as 別名]
    def download_button_clicked(self):
        tags = str(self.custom_tags.text())

        # url_id = self.recipes.model.data(1, QtCore.Qt.UserRole)    # TODO: 獲得選中的recipes
        url_id = str(self.row_clicked(self.recipes.currentIndex()))

        if url_id == 'None':
            QtGui.QMessageBox.information(self, u"Error", u"選擇需要爬取的網站!")
            return

        readlist_content = self.plainTextEdit.toPlainText()

        if readlist_content == '':
            QtGui.QMessageBox.information(self, u"Error", u"請在文本框中輸入網址")
            return

        read_list_path = Path.read_list_path

        readList_file = open(read_list_path, 'w')
        readList_file.write(readlist_content)

        readList_file.close()

        game = EEBook(recipe_kind=url_id)

        progress_dlg = QProgressDialog(self)        # TODO: 設置大小, 區域
        progress_dlg.setWindowModality(Qt.WindowModal)
        progress_dlg.setMinimumDuration(5)
        progress_dlg.setWindowTitle(u"請等待")
        progress_dlg.setLabelText(u"製作中...請稍候")
        progress_dlg.setCancelButtonText(u"取消")
        progress_dlg.resize(350, 250)
        progress_dlg.show()
        progress_dlg.setRange(0, 20)

        for i in range(0, 15):
            progress_dlg.setValue(i)
            QThread.msleep(100)

        for i in range(15, 20):
            progress_dlg.setValue(i)
            QThread.msleep(100)
            if progress_dlg.wasCanceled():
                QtGui.QMessageBox.information(self, u"Error", u"電子書製作失敗, 請重新操作")
                return

            try:
                filename = game.begin()      # TODO: 一次隻能生成一本書
            except TypeError:
                QtGui.QMessageBox.information(self, u"Error", u"第一次使用請登錄")
                progress_dlg.close()
                return
            progress_dlg.close()

            info_filename = ','.join(filename)
            QtGui.QMessageBox.information(self, u"info", u"電子書"+str(info_filename)+u"製作成功")

            for item in filename:
                file_path = EPUBSTOR_DIR + '/' + item
                Path.copy(str(file_path+'.epub'), LIBRARY_DIR)
                file_name = os.path.basename(str(file_path))
                book_id = file_name.split('.epub')[0]

                Path.mkdir(LIBRARY_DIR + book_id)
                shutil.move(LIBRARY_DIR+book_id+'.epub', LIBRARY_DIR+book_id)

                book = Book(str(book_id))
                book.date = time.strftime(ISOTIMEFORMAT, time.localtime())
                book.tags += tags.replace(' ', '')
                book.tags += ','+str(self.now_url)
                if self.add_title_tag.isChecked():
                    book.tags += ','+str(book.title)
                insert_library(book)
            return
開發者ID:bindx,項目名稱:EE-Book,代碼行數:76,代碼來源:download.py

示例6: init_path

# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import mkdir [as 別名]
 def init_path(self):
     Path.rmdir(u'./' + self.title)
     Path.mkdir(u'./' + self.title)
     Path.chdir(u'./' + self.title)
     EpubPath.init_epub_path(Path.get_pwd())
     return
開發者ID:HowieWang,項目名稱:jianshu2e-book,代碼行數:8,代碼來源:epub.py


注:本文中的src.tools.path.Path.mkdir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。