Commit 220c6ef9 authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

Improvements due to the poor performance in terms of memory usage of the

This is a legacy commit from before 2015-05-18.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.
readlines function.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 4151
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 709b00d6
......@@ -100,13 +100,17 @@ class Processor():
try:
if self.__verbose:
print("csback2cron: Reading CONFIGFILE ... ")
lines = []
configfile = open(self.__configfile)
lines = configfile.readlines()
configfile.close()
# strip comment lines and empty lines
lines = list(filter((lambda x: x[0] != '#' and x.rstrip() != ''), lines))
try:
for line in configfile:
# strip eol
tmp_line = line.rstrip()
if tmp_line != '' and tmp_line[0] != '#':
lines.append(tmp_line)
finally:
configfile.close()
# strip eol
lines = [l.rstrip() for l in lines]
if len(lines) == 0:
raise Error("CONFIGFILE not readable.")
# get mail= line
......@@ -122,9 +126,9 @@ class Processor():
raise Error("No setting lines in CONFIGFILE given.")
for line in lines:
l = line.split(" ")
if not self.__isdir(l[1]):
if not os.path.isdir(l[1]):
raise Error(l[1] + " is not a directory.")
if len(l) == 3 and self.__isdir(l[2]):
if len(l) == 3 and os.path.isdir(l[2]):
l.insert(2,'')
d = dict(zip(self.__keylist, l))
self.__sLines.append(d)
......@@ -212,12 +216,6 @@ class Processor():
res[self.__flags[3]] = res[self.__flags[3]].rstrip()
return res
def __isdir(self, dir):
if os.path.isdir(str(dir)):
return True
else:
return False
__flags = ['-c', '-t', '-b', '-e']
__keylist = ['cronexpr', 'source', 'flags', 'target']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment