diff options
Diffstat (limited to 'hercules/code/configutils.py')
-rw-r--r-- | hercules/code/configutils.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/hercules/code/configutils.py b/hercules/code/configutils.py index a20f3a0..6d9ddb2 100644 --- a/hercules/code/configutils.py +++ b/hercules/code/configutils.py @@ -8,20 +8,44 @@ def writeIntField(w, name, value): value = "0" w.write(" {0}: {1}\n".format(name, value)) +def writeIntField2(w, name, value): + if value == "": + value = "0" + w.write(" {0}: {1}\n".format(name, value)) + def writeStrField(w, name, value): w.write(" {0}: \"{1}\"\n".format(name, value)) +def writeCondField2(w, cond, name): + if cond != 0: + w.write(" {0}: true\n".format(name)) + def writeSubField(w, name, value): - w.write(" {0}: {1}\n".format(name, value)); + w.write(" {0}: {1}\n".format(name, value)) + +def writeFieldArr(w, name, value, value2): + w.write(" {0}: [{1}, {2}]\n".format(name, value, value2)) + +def writeFieldList(w, name, value, value2): + w.write(" {0}: ({1}, {2})\n".format(name, value, value2)) def writeStartBlock(w, text): - w.write(" {0}: {{\n".format(text)); + w.write(" {0}: {{\n".format(text)) def writeEndBlock(w): - w.write(" }\n"); + w.write(" }\n") def writeStartScript(w, name): w.write(" {0}: <\"\n".format(name)) def writeEndScript(w): w.write(" \">\n") + +def isHaveData(fields, start, cnt): + for f in range(0, cnt): + value = fields[start + f * 2] + chance = fields[start + f * 2] + if value == "" or value == "0" or chance == "" or chance == "0": + continue + return True + return False |