mirror of
https://github.com/satwikkansal/wtfpython
synced 2024-12-22 12:50:23 +01:00
Commit insert_ids script
This commit is contained in:
parent
6223715725
commit
fc491c5dd6
24
irrelevant/insert_ids.py
Normal file
24
irrelevant/insert_ids.py
Normal file
@ -0,0 +1,24 @@
|
||||
import uuid
|
||||
|
||||
new_file = []
|
||||
original_file = []
|
||||
|
||||
fname = "../README.md"
|
||||
|
||||
|
||||
def generate_random_id_comment():
|
||||
random_id = uuid.uuid4()
|
||||
return f"<!-- Example ID: {random_id} --!>"
|
||||
|
||||
|
||||
with open(fname, "r") as f:
|
||||
original_file = f.readlines()
|
||||
|
||||
|
||||
for line in original_file:
|
||||
new_file.append(line)
|
||||
if line.strip().startswith("### "):
|
||||
new_file.append(generate_random_id_comment())
|
||||
|
||||
with open(fname, "w") as f:
|
||||
f.write("".join(new_file))
|
Loading…
x
Reference in New Issue
Block a user