39 lines
994 B
Python
39 lines
994 B
Python
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
|
|
path: str = "forgejo_10.0.0"
|
|
out_filename: str = "10.0.0"
|
|
|
|
with open("changes.txt", "r") as file_handle:
|
|
data = file_handle.readlines()
|
|
|
|
for idx in range(0, len(data)):
|
|
data[idx] = data[idx][:-1]
|
|
|
|
files = list(Path(path).rglob("*"))
|
|
|
|
for idx, search_string in enumerate(data):
|
|
|
|
os.makedirs(f"data/{idx}", exist_ok=True)
|
|
result: str | None = None
|
|
|
|
if len(search_string) > 0:
|
|
|
|
found: list[str] = []
|
|
for file in files:
|
|
if str(file).endswith(search_string):
|
|
found.append(str(file))
|
|
|
|
if len(found) != 1:
|
|
for elements in found:
|
|
if elements == f"{path}/{search_string}":
|
|
result = elements
|
|
else:
|
|
result = found[0]
|
|
|
|
if result is None:
|
|
print(f"{idx} :{found} , {search_string}")
|
|
else:
|
|
print(f"{idx} :{result}")
|
|
shutil.copy2(result, f"data/{idx}/{out_filename}")
|