diff --git a/gawk.py b/gawk.py index 1916bd3..71042fd 100755 --- a/gawk.py +++ b/gawk.py @@ -9,8 +9,7 @@ def main(): eig = mfp.require("exception").ignore print("Loading addons ...") - addonList = eig([],config.readList,eig(None,config.find,mfp.p("addon","addons.txt"))) - for addonName in addonList: + for addonName in config.readList(config.find(mfp.p("addon","addons.txt"))): print("> " +addonName) try: addonFile = config.find(mfp.p("addon",addonName,"_main.py")) diff --git a/module/config.py b/module/config.py index d233623..0a718aa 100644 --- a/module/config.py +++ b/module/config.py @@ -19,22 +19,22 @@ def findAll(path,method = os.path.isfile): if method(fp): rtn.append(fp) return rtn +def parseListLine(line,parseComments = True): + line = line.replace("\r","").strip("\n") + if parseComments: line = line.split("#",1)[0] + line = line.strip("\t ") + return line + def readList(path,parseComments = True): with open(path,encoding="utf-8") as f: - content = f.read().replace("\r","").strip("\n").split("\n") - index = 0 - length = len(content) - while index < length: - line = content[index] - if parseComments: line = line.split("#",1)[0] - line.strip("\t ") - if line == "": - del content[index] - length -= 1 - continue - content[index] = line - index += 1 - return content + line = f.readline() + while line: + line = parseListLine(line) + if line == "": + line = f.readline() + continue + yield line + line = f.readline() def readIni(path,config = None): if config == None: