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


Python SimilarSizeWriter.max_line_change方法代碼示例

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


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

示例1: assert

# 需要導入模塊: from Cerebrum.utils.atomicfile import SimilarSizeWriter [as 別名]
# 或者: from Cerebrum.utils.atomicfile.SimilarSizeWriter import max_line_change [as 別名]
        assert(os.access(outFilePath, os.W_OK))  # Is output writable?
    except IOError, err:
        logger.error(err)
        raise err

    logger.info("Reading from: %s (%s bytes)",
                inFilePath, os.path.getsize(inFilePath))
    logger.info("Comparing to: %s (%s bytes)",
                outFilePath, os.path.getsize(outFilePath))

    if limit_percentage:
        ssw = SimilarSizeWriter(outFilePath, mode='w')
        ssw.max_pct_change = limit_percentage
    else:
        ssw = SimilarLineCountWriter(outFilePath, mode='w')
        ssw.max_line_change = limit_lines

    # read from input, write to temporary output file
    for line in inFile:
        ssw.write(line)

    try:
        # close() checks that changes are within limits
        ssw.close()
    except FileChangeTooBigError as err:
        logger.error(
            "Changes are too big, leaving behind temporary file %s",
            ssw._tmpname)
        raise err

    logger.info("Changes are within limits, file replaced")
開發者ID:unioslo,項目名稱:cerebrum,代碼行數:33,代碼來源:copy_with_size_check.py


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