From 788bfd99d6e30c88b63781da66c6e4101f3fa727 Mon Sep 17 00:00:00 2001 From: Brett Graham Date: Tue, 27 Feb 2024 10:22:42 -0500 Subject: [PATCH] add if __main__ to changelog filter (#338) --- .github/changelog_filter.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/changelog_filter.py b/.github/changelog_filter.py index 296d0b97..beb07d63 100644 --- a/.github/changelog_filter.py +++ b/.github/changelog_filter.py @@ -6,16 +6,17 @@ import sys import json -input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') -source = input_stream.read() -doc = json.loads(source) +if __name__ == '__main__': + input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') + source = input_stream.read() + doc = json.loads(source) -output_blocks = [] -for block in doc["blocks"]: - if output_blocks and block["t"] == "Header" and block["c"][0] == 1: - break - print(block["c"], file=sys.stderr) - output_blocks.append(block) + output_blocks = [] + for block in doc["blocks"]: + if output_blocks and block["t"] == "Header" and block["c"][0] == 1: + break + print(block["c"], file=sys.stderr) + output_blocks.append(block) -doc["blocks"] = output_blocks -sys.stdout.write(json.dumps(doc)) + doc["blocks"] = output_blocks + sys.stdout.write(json.dumps(doc))