Fix registry dumb creating invalid csv file

This commit is contained in:
DBotThePony 2024-01-04 23:18:36 +07:00
parent 486c9b00c9
commit 028d03b147
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -1611,6 +1611,22 @@ object MatterManager {
val stream2 = stream.map { it to get(it.value) }
fun writeValue(a: String, b: String, c: String, commentary: Collection<String>) {
if (commentary.size < 2) {
writer.write(arrayOf(a, b, c, commentary.firstOrNull() ?: "").joinToString(";", transform = ::transformQuotes))
writer.write("\n")
} else {
val iterator = commentary.iterator()
writer.write(arrayOf(a, b, c, iterator.next()).joinToString(";", transform = ::transformQuotes))
writer.write("\n")
for (v in iterator) {
writer.write(arrayOf("", "", "", v).joinToString(";", transform = ::transformQuotes))
writer.write("\n")
}
}
}
for ((entry, value) in filter.filter(stream2)) {
val (key, item) = entry
val isBlacklisted: Boolean
@ -1624,16 +1640,14 @@ object MatterManager {
}
if (isBlacklisted) {
writer.write(arrayOf(key.location().toString(), "---", "---", "Item is blacklisted from having matter value").joinToString(";", transform = ::transformQuotes))
writeValue(key.location().toString(), "---", "---", listOf("Item is blacklisted from having matter value"))
} else {
if (!value.hasMatterValue) {
writer.write(arrayOf(key.location().toString(), "", "", commentary[item]?.joinToString("\n", transform = { transformQuotes(it.string) }) ?: "").joinToString(";", transform = ::transformQuotes))
writeValue(key.location().toString(), "", "", commentary[item]?.map { it.string } ?: listOf())
} else {
writer.write(arrayOf(key.location().toString(), value.matter.toString(), value.complexity.toString(), commentary[item]?.joinToString("\n", transform = { transformQuotes(it.string) }) ?: "").joinToString(";", transform = ::transformQuotes))
writeValue(key.location().toString(), value.matter.toString(), value.complexity.toString(), commentary[item]?.map { it.string } ?: listOf())
}
}
writer.write("\n")
}
writer.close()