Make readList yield instead of return
This commit is contained in:
parent
186ccb89d9
commit
169c5ad712
3
gawk.py
3
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"))
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue