本文整理汇总了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")