You've already forked hexagon-dsp-binaries
mirror of
https://github.com/linux-msm/hexagon-dsp-binaries.git
synced 2026-02-25 13:14:28 -08:00
Add missing License tags and copyrights. The scripts were written by a Linaro employee, so that company owns initial copyrights. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
53 lines
1.5 KiB
Python
Executable File
53 lines
1.5 KiB
Python
Executable File
#! /usr/bin/python3
|
|
# SPDX-License-Identifier: MIT
|
|
# Copyright (c) 2024 Linaro Ltd.
|
|
|
|
import os, re, sys
|
|
|
|
def load_config(cfg):
|
|
with open(cfg, encoding="utf-8") as config:
|
|
pattern_inst = re.compile("^Install: ([^ \t]+)[ \t]+([^ \t]+)[ \t]+([^ \t]+)\n$")
|
|
for line in config:
|
|
match = pattern_inst.match(line)
|
|
if match:
|
|
yield os.path.join(match.group(1), match.group(3))
|
|
|
|
def filter_whence(whence, cfg):
|
|
with open(whence, encoding="utf-8") as file:
|
|
pattern_dir = re.compile("^Dir: (.*)\n$")
|
|
pattern_break = re.compile("^----")
|
|
matched = True # output file header until the first section
|
|
|
|
for line in file:
|
|
match = pattern_dir.match(line)
|
|
if match:
|
|
if match.group(1) in cfg:
|
|
matched = True
|
|
yield line
|
|
continue
|
|
|
|
match = pattern_break.match(line)
|
|
if match:
|
|
if matched:
|
|
matched = False
|
|
yield line
|
|
yield "\n"
|
|
continue
|
|
|
|
if matched:
|
|
yield line
|
|
|
|
|
|
def main(args):
|
|
if len(args) != 4:
|
|
print("Usage: %s config.txt WHENCE OUT" % args[0])
|
|
|
|
cfg = dict.fromkeys(load_config(args[1]))
|
|
|
|
with open(args[3], mode="wt", encoding="utf-8") as out:
|
|
for line in filter_whence(args[2], cfg):
|
|
out.write(line)
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv))
|