本文整理汇总了Python中plugin.Plugin.terminate方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.terminate方法的具体用法?Python Plugin.terminate怎么用?Python Plugin.terminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin.Plugin
的用法示例。
在下文中一共展示了Plugin.terminate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import terminate [as 别名]
def execute(self, data):
Plugin.init(self, data)
self.target = data.get('in')
out = '%s.reduced' %(self.target)
io = open(self.target, 'r')
oio = open(out, 'w')
for i, l in enumerate(io):
ss = l.strip().split(self.mr_delimiter)
try:
k = ss[0]
v = ss[1]
except:
continue
oio.write('%s%s%s\n' %(v, self.mr_delimiter, k))
io.close()
oio.close()
data['in'] = out
Plugin.terminate(self, data)
return data
示例2: execute
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import terminate [as 别名]
def execute(self, data):
Plugin.init(self, data)
self.target = data.get('in')
if not self.target:
return data
out = '%s.%s' %(self.target, self.suffix)
data['in'] = out
oio = open(out, 'w')
io = open(self.target, 'r')
for i, l in enumerate(io):
ss = l.strip().split(self.mr_delimiter)
k = ss[0]
vs = ss[1]
oio.write('%s%s1\n' %(vs, self.mr_delimiter))
io.close()
Plugin.terminate(self, data)
return data
示例3: execute
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import terminate [as 别名]
def execute(self, data):
Plugin.init(self, data)
self.target = data.get('in')
output = '%s.%s' %(self.target, self.suffix)
data['in'] = output
if self.skip:
return data
io = open(self.target, 'r')
oo = open(output, 'w')
for i, l in enumerate(io):
ss = l.strip().split(self.mr_delimiter)
try:
k = ss[0]
v = ss[1]
except:
continue
oo.write('%s%s%s\n' %(v, self.mr_delimiter, k))
oo.close()
io.close()
Plugin.terminate(self, data)
return data
示例4: execute
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import terminate [as 别名]
def execute(self, data):
t = time.time()
print 'reducing...',
Plugin.init(self, data)
self.target = data.get('in')
out = '%s.reduced' %(self.target)
data['in'] = out
if self.skip:
return data
io = open(self.target, 'r')
oio = open(out, 'w')
pk = None
pv = 0
for i, l in enumerate(io):
ss = l.strip().split(self.mr_delimiter)
try:
k = ss[0]
v = int(ss[1])
except:
continue
if pk and pk != k:
oio.write('%s%s%d\n' %(pk, self.mr_delimiter, pv))
pv = v
else:
pv += v
pk = k
# last
oio.write('%s%s%d\n' %(pk, self.mr_delimiter, pv))
io.close()
oio.close()
data['in'] = out
Plugin.terminate(self, data)
t = time.time() - t
print ' .done ', t, '[ms]'
return data
示例5: execute
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import terminate [as 别名]
def execute(self, data):
Plugin.init(self, data)
self.target = data.get('in')
sorted = '%s.%s' %(self.target, self.suffix)
# add to data
data['sorted'] = sorted
data['in'] = sorted
if self.skip:
return data
t = time.time()
stdout.write('# process split sort ...')
j = 0
io = open(self.target, 'r')
# tmp dirをクリア
stderr.write('# clear temp files ... ')
if self.temp_clean and os.path.exists(self.temp_dir):
for f in os.listdir(self.temp_dir):
os.remove(os.path.join(self.temp_dir, f))
stderr.write(' .done\n')
#
# ここをワーカースレッドで並列化
#
workers = []
for i in range(self.num_threads):
w = OnMemorySortWorker(self, i, self.target, self.num_threads)
workers.append(w)
for w in workers:
w.start()
for w in workers:
w.join()
t = time.time() - t
stdout.write(' done. %f [s]\n' %(t))
# merge
t = time.time()
sorted = '%s.%s' %(self.target, self.suffix)
stdout.write('# process merge sort and output to %s ...' %(sorted))
# new merge sort
fs = os.listdir(self.temp_dir)
num_tmp_files = len(fs)
while True:
self._merge_sort(sorted, num_tmp_files)
fs = os.listdir(self.temp_dir)
if len(fs) == 1:
break
# sortedを
if os.path.exists(sorted):
os.remove(sorted)
#print fs[0]
os.rename('%s/%s' %(self.temp_dir, fs[0]), sorted)
t = time.time() - t
stdout.write(' done. %f [s]\n' %(t))
# add to data
data['sorted'] = sorted
data['in'] = sorted
Plugin.terminate(self, data)
return data