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


Python Book.format方法代码示例

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


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

示例1: insert_data

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import format [as 别名]
    def insert_data(self, data):
        """
        Will handle inserting data into the database
        """
        try:
            # Check if book is in database, if so update else create
            try:
                book = db_session.query(Book).filter(Book.book_id == data.get('book_id')).one()
            except NoResultFound:
                book = Book()

            book.title = data.get('title')
            book.subtitle = data.get('subtitle')
            book.author = data.get('author')
            book.year = data.get('year')
            book.pages = data.get('pages')
            book.language = data.get('language')
            book.publisher = data.get('publisher')
            book.isbn = data.get('isbn')
            book.format = data.get('format')
            book.description = data.get('description')
            book.file_source = data.get('file_source')
            book.file_cover_source = data.get('file_cover_source')
            book.file_location = data.get('file_location')
            book.file_cover_location = data.get('file_cover_location')
            book.book_id = data.get('book_id')
            book.time_collected = data.get('time_collected')

            db_session.add(book)
            db_session.commit()
            # self.track_stat('rows_added_to_db', rows_affected)

        except Exception:
            db_session.rollback()
            logger.exception("Error adding to db {data}".format(data=data))
开发者ID:xtream1101,项目名称:scrape-itebooks,代码行数:37,代码来源:it-ebooks.py

示例2: Book

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import format [as 别名]
    fileText.remove('')

para_lengths = []
sentences_complete = []
num_paragraphs = 0
for paragraph in fileText:
    sentences = sent_detector.tokenize(paragraph.strip())
    para_lengths.append(len(sentences))
    num_paragraphs += 1

    sentences_complete.extend(sentences)

theWizard = Book('The Wizard of Oz', ':. Frank Baum', 'adventure', sentences_complete)
theWizard.estimate_pulpiness_fuzzy()

theWizard.format()

print("Paragraph Breaks\nOriginal: {0}, Formated: {1}".format(
    num_paragraphs,
    len(theWizard.paragraphs)
))


# Keneth Robeson book:
print("\nDoc Savage: ")

with open('Doc Savage - 001 - The Man of Bronze(1933)(Dent, Lester).txt', 'rb') as file:
    fileText = file.read()

fileText = fileText.replace("\n", "")
fileText = fileText.split("\r")
开发者ID:seanbraley,项目名称:ebook-fixer,代码行数:33,代码来源:run.py


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