From bf42048ecc16702ab539aa15dcb61fa87249d1b8 Mon Sep 17 00:00:00 2001 From: Gosuto Inzasheru Date: Mon, 9 Dec 2024 20:25:58 +0700 Subject: [PATCH 1/2] style: end json dump files with newline --- action-scripts/gen_add_permissions_payload.py | 1 + action-scripts/merge_pr_jsons.py | 1 + action-scripts/multi_merge_pr_jsons.py | 1 + tools/python/aura_snapshot_voting/vote.py | 1 + tools/python/brownie/great_ape_safe/ape_api/badger.py | 1 + tools/python/brownie/great_ape_safe/ape_api/balancer.py | 1 + tools/python/brownie/great_ape_safe/ape_api/cow.py | 1 + tools/python/brownie/helpers/balancerGaugeInfo.py | 1 + .../brownie/scripts/balancer_reports/authorizier_roles.py | 1 + tools/python/brownie/scripts/csv_airdrop.py | 1 + .../brownie/scripts/maxi_operations/EulerPartialInteralWd.py | 1 + .../scripts/maxi_operations/bribe_txbuilder_with_rounds.py | 1 + tools/python/generate_new_chain_template.py | 1 + tools/python/mimicTestSweep.py | 5 ++--- tools/python/standardize_poolRateCache.py | 1 + tools/python/sweepFees.py | 1 + tools/python/sweepFeesNoJson.py | 1 + 17 files changed, 18 insertions(+), 3 deletions(-) diff --git a/action-scripts/gen_add_permissions_payload.py b/action-scripts/gen_add_permissions_payload.py index f9c3f3634..e525c15ac 100644 --- a/action-scripts/gen_add_permissions_payload.py +++ b/action-scripts/gen_add_permissions_payload.py @@ -192,6 +192,7 @@ def save_txbuilder_json(change_list, output_dir, filename_root=today): # Save tx builder json with open(f"{output_dir}/{filename_root}_{chain_name}.json", "w") as f: json.dump(dict(data), f, indent=2) + f.write("\n") def main( diff --git a/action-scripts/merge_pr_jsons.py b/action-scripts/merge_pr_jsons.py index f62647db7..ce9190ade 100644 --- a/action-scripts/merge_pr_jsons.py +++ b/action-scripts/merge_pr_jsons.py @@ -233,6 +233,7 @@ def main(): file_path = os.path.join(dir_name_batched_full, file_name) with open(file_path, "w") as new_file: json.dump(result, new_file, indent=2) + new_file.write("\n") if __name__ == "__main__": diff --git a/action-scripts/multi_merge_pr_jsons.py b/action-scripts/multi_merge_pr_jsons.py index 40ce1e6c4..477bcdea7 100644 --- a/action-scripts/multi_merge_pr_jsons.py +++ b/action-scripts/multi_merge_pr_jsons.py @@ -145,6 +145,7 @@ def main(): file_path = os.path.join(dir_name_batched_full, file_name) with open(file_path, "w") as new_file: json.dump(result, new_file, indent=2) + new_file.write("\n") if __name__ == "__main__": diff --git a/tools/python/aura_snapshot_voting/vote.py b/tools/python/aura_snapshot_voting/vote.py index e92b03b2a..3519ad591 100644 --- a/tools/python/aura_snapshot_voting/vote.py +++ b/tools/python/aura_snapshot_voting/vote.py @@ -205,6 +205,7 @@ def create_vote_payload(vote_choices, prop): with open(f"{output_dir}/payload.json", "w") as f: json.dump(data, f, indent=4) + f.write("\n") response = requests.post( "https://relayer.snapshot.org/", diff --git a/tools/python/brownie/great_ape_safe/ape_api/badger.py b/tools/python/brownie/great_ape_safe/ape_api/badger.py index 68bc54986..66f7ff549 100644 --- a/tools/python/brownie/great_ape_safe/ape_api/badger.py +++ b/tools/python/brownie/great_ape_safe/ape_api/badger.py @@ -264,6 +264,7 @@ def queue_timelock(self, target_addr, signature, data, dump_dir, delay_in_days=2 "eta": eta, } json.dump(tx_data, f, indent=4, sort_keys=True) + f.write("\n") def execute_timelock(self, queueTx_dir): """ diff --git a/tools/python/brownie/great_ape_safe/ape_api/balancer.py b/tools/python/brownie/great_ape_safe/ape_api/balancer.py index fa36bd485..c07d0eaa9 100644 --- a/tools/python/brownie/great_ape_safe/ape_api/balancer.py +++ b/tools/python/brownie/great_ape_safe/ape_api/balancer.py @@ -102,6 +102,7 @@ def get_pool_data(self, update_cache=False): ] with open("great_ape_safe/ape_api/helpers/balancer/pools.json", "w") as f: json.dump(pool_data_filtered, f) + f.write("\n") return pool_data_filtered with open("great_ape_safe/ape_api/helpers/balancer/pools.json") as f: diff --git a/tools/python/brownie/great_ape_safe/ape_api/cow.py b/tools/python/brownie/great_ape_safe/ape_api/cow.py index 47ba45fde..bc377f581 100644 --- a/tools/python/brownie/great_ape_safe/ape_api/cow.py +++ b/tools/python/brownie/great_ape_safe/ape_api/cow.py @@ -167,6 +167,7 @@ def _sell( os.makedirs(path, exist_ok=True) with open(f"{path}{order_uid}.json", "w+") as f: f.write(json.dumps(order_payload)) + f.write("\n") if origin != self.safe.address: # can only sign if origin is safe diff --git a/tools/python/brownie/helpers/balancerGaugeInfo.py b/tools/python/brownie/helpers/balancerGaugeInfo.py index bad68280a..c078a9c2e 100644 --- a/tools/python/brownie/helpers/balancerGaugeInfo.py +++ b/tools/python/brownie/helpers/balancerGaugeInfo.py @@ -96,6 +96,7 @@ def buildGaugesDictFromContract(): def write_gauge_outputs(gauges_dict): with open("output/gauges.json", "w") as jsonfile: json.dump(gauges_dict, jsonfile) + jsonfile.write("\n") with open("output/gauges.csv", "w") as csvfile: csvfile.write("name, address, isActive\n") for key, value in gauges_dict["active_gauges"].items(): diff --git a/tools/python/brownie/scripts/balancer_reports/authorizier_roles.py b/tools/python/brownie/scripts/balancer_reports/authorizier_roles.py index ba008f81a..19c1cc0e5 100644 --- a/tools/python/brownie/scripts/balancer_reports/authorizier_roles.py +++ b/tools/python/brownie/scripts/balancer_reports/authorizier_roles.py @@ -95,6 +95,7 @@ def getEvents(contract): def write_gauge_outputs(gauges_dict): with open("output/gauges.json", "w") as jsonfile: json.dump(gauges_dict, jsonfile) + jsonfile.write("\n") with open("output/gauges.csv", "w") as csvfile: csvfile.write("name, address, isActive\n") for key, value in gauges_dict["active_gauges"].items(): diff --git a/tools/python/brownie/scripts/csv_airdrop.py b/tools/python/brownie/scripts/csv_airdrop.py index 20777a561..dcd74a441 100644 --- a/tools/python/brownie/scripts/csv_airdrop.py +++ b/tools/python/brownie/scripts/csv_airdrop.py @@ -52,6 +52,7 @@ def main(): print(txlist) with open(JSON, "w") as output: json.dump(payload, output, indent=2) + output.write("\n") if __name__ == "__main__": diff --git a/tools/python/brownie/scripts/maxi_operations/EulerPartialInteralWd.py b/tools/python/brownie/scripts/maxi_operations/EulerPartialInteralWd.py index 1100893a7..0287e0a3e 100644 --- a/tools/python/brownie/scripts/maxi_operations/EulerPartialInteralWd.py +++ b/tools/python/brownie/scripts/maxi_operations/EulerPartialInteralWd.py @@ -105,3 +105,4 @@ with open("eulerBreakoutOutput.json", "w") as f: json.dump(endjson, f) + f.write("\n") diff --git a/tools/python/brownie/scripts/maxi_operations/bribe_txbuilder_with_rounds.py b/tools/python/brownie/scripts/maxi_operations/bribe_txbuilder_with_rounds.py index 8ebfa572f..08d5b88cf 100644 --- a/tools/python/brownie/scripts/maxi_operations/bribe_txbuilder_with_rounds.py +++ b/tools/python/brownie/scripts/maxi_operations/bribe_txbuilder_with_rounds.py @@ -232,5 +232,6 @@ def bribe_balancer(gauge, mantissa, amount, rounds): payload["transactions"] = tx_list with open(f"../../../BIPs/00rebateRecycling/{today}.json", "w") as f: json.dump(payload, f) + f.write("\n") print(f"USDC to Bribs: {total_mantissa}") print(f"USDC payments: {payments}") diff --git a/tools/python/generate_new_chain_template.py b/tools/python/generate_new_chain_template.py index b8d4fdb69..16df27db7 100644 --- a/tools/python/generate_new_chain_template.py +++ b/tools/python/generate_new_chain_template.py @@ -33,3 +33,4 @@ def lookup_caller(caller): with open("../../BIPs/00batched/authorizer/new-chain-template.json", "w") as f: json.dump(template, f, indent=2) + f.write("\n") diff --git a/tools/python/mimicTestSweep.py b/tools/python/mimicTestSweep.py index a45361881..39354877c 100644 --- a/tools/python/mimicTestSweep.py +++ b/tools/python/mimicTestSweep.py @@ -52,13 +52,12 @@ def generateSweepFile(sourcefile): list(sweeps.keys()) ).replace("'", "") tx_out_map.transactions[0].contractInputsValues.amounts = str(list(sweeps.values())) - tx_out_map.transactions[ - 0 - ].contractInputsValues.recipient = ( + tx_out_map.transactions[0].contractInputsValues.recipient = ( "0x7f4b5250C63E24360055342D2a4427079290F044" ## Mimic mock withdrawer (op) ) with open(f"{target_dir}/out/{today}-{chain}.json", "w") as f: json.dump(dict(tx_out_map), f) + f.write("\n") with open(f"{target_dir}/out/{today}-{chain}.report.txt", "w") as f: f.write(report) diff --git a/tools/python/standardize_poolRateCache.py b/tools/python/standardize_poolRateCache.py index 7b476b16b..5857bc435 100644 --- a/tools/python/standardize_poolRateCache.py +++ b/tools/python/standardize_poolRateCache.py @@ -125,6 +125,7 @@ def main(chain="mainnet"): with open(f"./rateChangeTxList.json", "w") as f: json.dump(tx_list, f) + f.write("\n") if __name__ == "__main__": diff --git a/tools/python/sweepFees.py b/tools/python/sweepFees.py index 36492d8b2..77bca0523 100644 --- a/tools/python/sweepFees.py +++ b/tools/python/sweepFees.py @@ -65,6 +65,7 @@ def generateSweepFile(sourcefile): tx_out_map.transactions[0].contractInputsValues.amounts = str(list(sweeps.values())) with open(f"{target_dir}/out/{today}-{chain}.json", "w") as f: json.dump(dict(tx_out_map), f) + f.write("\n") with open(f"{target_dir}/out/{today}-{chain}.report.txt", "w") as f: f.write(report) diff --git a/tools/python/sweepFeesNoJson.py b/tools/python/sweepFeesNoJson.py index d6b2fdaa7..a1980cb53 100644 --- a/tools/python/sweepFeesNoJson.py +++ b/tools/python/sweepFeesNoJson.py @@ -44,6 +44,7 @@ def generateSweepFile(tokenlist): tx_out_map.transactions[0].contractInputsValues.amounts = str(list(sweeps.values())) with open(f"{target_dir}/out/{today}-{chain}.json", "w") as f: json.dump(dict(tx_out_map), f) + f.write("\n") with open(f"{target_dir}/out/{today}-{chain}.report.txt", "w") as f: f.write(report) From 3e39a1083579c0453109ec3a096ed2353f1d1765 Mon Sep 17 00:00:00 2001 From: gosuto-inzasheru Date: Mon, 9 Dec 2024 13:34:40 +0000 Subject: [PATCH 2/2] style: ci lint with `black` --- tools/python/mimicTestSweep.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/python/mimicTestSweep.py b/tools/python/mimicTestSweep.py index 39354877c..6ba6b6005 100644 --- a/tools/python/mimicTestSweep.py +++ b/tools/python/mimicTestSweep.py @@ -52,7 +52,9 @@ def generateSweepFile(sourcefile): list(sweeps.keys()) ).replace("'", "") tx_out_map.transactions[0].contractInputsValues.amounts = str(list(sweeps.values())) - tx_out_map.transactions[0].contractInputsValues.recipient = ( + tx_out_map.transactions[ + 0 + ].contractInputsValues.recipient = ( "0x7f4b5250C63E24360055342D2a4427079290F044" ## Mimic mock withdrawer (op) ) with open(f"{target_dir}/out/{today}-{chain}.json", "w") as f: