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
|
eig = mfp.require("exception").ignore
|
||||||
|
|
||||||
print("Loading addons ...")
|
print("Loading addons ...")
|
||||||
addonList = eig([],config.readList,eig(None,config.find,mfp.p("addon","addons.txt")))
|
for addonName in config.readList(config.find(mfp.p("addon","addons.txt"))):
|
||||||
for addonName in addonList:
|
|
||||||
print("> " +addonName)
|
print("> " +addonName)
|
||||||
try:
|
try:
|
||||||
addonFile = config.find(mfp.p("addon",addonName,"_main.py"))
|
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)
|
if method(fp): rtn.append(fp)
|
||||||
return rtn
|
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):
|
def readList(path,parseComments = True):
|
||||||
with open(path,encoding="utf-8") as f:
|
with open(path,encoding="utf-8") as f:
|
||||||
content = f.read().replace("\r","").strip("\n").split("\n")
|
line = f.readline()
|
||||||
index = 0
|
while line:
|
||||||
length = len(content)
|
line = parseListLine(line)
|
||||||
while index < length:
|
if line == "":
|
||||||
line = content[index]
|
line = f.readline()
|
||||||
if parseComments: line = line.split("#",1)[0]
|
continue
|
||||||
line.strip("\t ")
|
yield line
|
||||||
if line == "":
|
line = f.readline()
|
||||||
del content[index]
|
|
||||||
length -= 1
|
|
||||||
continue
|
|
||||||
content[index] = line
|
|
||||||
index += 1
|
|
||||||
return content
|
|
||||||
|
|
||||||
def readIni(path,config = None):
|
def readIni(path,config = None):
|
||||||
if config == None:
|
if config == None:
|
||||||
|
|
Loading…
Reference in New Issue