From 16889bc63886f1e2de401ab661c57296f525a24d Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Mon, 16 Dec 2019 14:11:11 +0100 Subject: [PATCH] port compare-structures action --- actions/ost-compare-structures | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/actions/ost-compare-structures b/actions/ost-compare-structures index 41f1080ce..e884b7bad 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() -- GitLab