本文整理汇总了Python中FileUtils.readzip方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.readzip方法的具体用法?Python FileUtils.readzip怎么用?Python FileUtils.readzip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.readzip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readzip [as 别名]
#.........这里部分代码省略.........
print("Now proceeding to process the files.\n")
def subtract_counts (token, adict, tosubtract):
'''Adjusts a dictionary by subtracting tosubtract instances of token.'''
if token in adict:
adict[token] = adict[token] - tosubtract
if adict[token] < 0:
del adict[token]
elif adict[token] < 1:
del adict[token]
return adict
def add_counts (token, adict, toadd):
'''Adjusts a dictionary by adding toadd instances of token.'''
if token in adict:
adict[token] = adict[token] + toadd
else:
adict[token] = toadd
return adict
# Here's where we BEGIN THE ACTUAL CORRECTION OF FILES.
processedmeta = list()
errorlog = list()
longSfiles = list()
count = 0
for filename in filelist:
try:
if suffix == ".zip":
lines = FileUtils.readzip(filename)
successflag = True
else:
with open(filename, encoding='utf-8') as file:
lines = file.readlines()
successflag = True
except IOError as e:
successflag = False
if not successflag:
print(filename + " is missing.")
errorlog.append(filename + '\t' + "missing")
continue
tokens, pre_matched, pre_english = Volume2.as_stream(lines, verbose=debug)
tokencount = len(tokens)
if len(tokens) < 10:
print(filename, "has only tokencount", len(tokens))
errorlog.append(filename + '\t' + 'short')
correct_tokens, pages, post_matched, post_english = Volume2.correct_stream(tokens, verbose = debug)
# Combine page dictionaries into a master dictionary.
# If you ask, why didn't you just produce one in the first place? ...
# answer has to do with flexibility of the Volume module for other purposes.
pagecounter = 0
masterdict = dict()
for page in pages:
for item in page:
if item in masterdict: