[git fast commit] 02. Feb 2019 - 15:34:59

This commit is contained in:
Yannik Schmidt
2019-02-02 15:34:59 +01:00
parent 59e5816b06
commit c7fe5e8f17
7 changed files with 60 additions and 44 deletions

View File

@@ -1,11 +1,11 @@
import TrueSkillWrapper as TS
import time
import threading
import insurgencyParsing as iparse
def readfile(filename, start_at_end=True, exit_on_eof=False, parsingBackend=None):
def readfile(filename, start_at_end=True, exit_on_eof=False, parsingBackend=iparse, cpus=1):
f = open(filename)
if start_at_end:
f.seek(0,2)
@@ -14,15 +14,15 @@ def readfile(filename, start_at_end=True, exit_on_eof=False, parsingBackend=None
raise NotImplementedError("Multiprocessing not implemeted yet")
else:
if callable(parsingBackend):
parsingBackend(f)
parsingBackend(f, exit_on_eof, start_at_end)
else:
parsingBackend.parse(f)
parsingBackend.parse(f, exit_on_eof, start_at_end)
except TypeError:
raise RuntimeError("parsingBackend musst be callable or have .parse() callable")
f.close()
def readfiles(filenames, parsingBackend, start_at_end=True, nofollow=False):
def readfiles(filenames, start_at_end=True, nofollow=False, parsingBackend=iparse ):
for f in filenames:
threading.Thread(target=readfile,args=\
(f, start_at_end, nofollow, parsingBackend)).start()