Created
May 11, 2023 10:39
-
-
Save johnnieskywalker/8ab96276b9afd0e8a5ee0030030f92ab to your computer and use it in GitHub Desktop.
Script for sleaning spdx from flat .sol files, except the first one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
flattened_dir = "./flattened" | |
for filename in os.listdir(flattened_dir): | |
file_path = os.path.join(flattened_dir, filename) | |
if os.path.isfile(file_path) and filename.endswith("_flattened.sol"): | |
with open(file_path, "r") as f: | |
lines = f.readlines() | |
first_spdx_line = next((line for line in lines if "SPDX-License-Identifier" in line), None) | |
updated_lines = [first_spdx_line] + [line for line in lines if "SPDX-License-Identifier" not in line] | |
with open(file_path, "w") as f: | |
f.writelines(updated_lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment