本文整理匯總了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")