Files
rtl-manifest/src/rtl_manifest/rtl_manifest.py
2024-06-06 18:31:57 -07:00

39 lines
1.0 KiB
Python

import argparse
from typing import List
import pathlib
def rtl_manifest_main():
parser = argparse.ArgumentParser(
prog='rtl-manifest',
description='Read in sources.list files and return a string of all source files',
epilog='Made by Byron Lathi')
parser.add_argument("source")
args = parser.parse_args()
files = read_sources(args.source)
for file in files:
print(file, end = " ")
pass
def read_sources(source_file: str) -> List[str]:
files = []
base_dir = pathlib.Path(source_file).parent
with open(source_file, "r") as file:
for line in file:
path = line.strip()
if (path.endswith("sources.list")):
new_path = pathlib.Path(base_dir) / path
for recursive_path in read_sources(new_path):
files.append(recursive_path)
else:
abs_path = pathlib.Path(base_dir / path).absolute()
files.append(str(abs_path))
return files