diff --git a/actions/ost-compare-structures b/actions/ost-compare-structures index 41f1080ce1db8d16b5134344e6a74205733f89fb..e884b7bad667b43500f34a660f5f242f6b43a756 100644 --- a/actions/ost-compare-structures +++ b/actions/ost-compare-structures @@ -513,7 +513,7 @@ def _RevertChainNames(ent): used_names[original_name] += 1 for chain in ent.chains: editor.RenameChain(chain, reverted_chains[chain.name[:-len(suffix)]]) - rev_out = ["%s -> %s" % (on, nn) for on, nn in reverted_chains.items()] + rev_out = ["%s -> %s" % (on, nn) for on, nn in list(reverted_chains.items())] ost.LogInfo("Reverted chains: %s" % ", ".join(rev_out)) @@ -989,9 +989,20 @@ def _Main(): with open(opts.output, "w") as outfile: json.dump(result, outfile, indent=4, sort_keys=True) +class _Unbuffered(object): + # https://stackoverflow.com/questions/45263064/how-can-i-fix-this-valueerror-cant-have-unbuffered-text-i-o-in-python-3/45263101 + def __init__(self, stream): + self.stream = stream + def write(self, data): + self.stream.write(data) + self.stream.flush() + def writelines(self, datas): + self.stream.writelines(datas) + self.stream.flush() + def __getattr__(self, attr): + return getattr(self.stream, attr) if __name__ == '__main__': # make script 'hot' - unbuffered = os.fdopen(sys.stdout.fileno(), 'w', 0) - sys.stdout = unbuffered + sys.stdout = _Unbuffered(sys.stdout) _Main()