| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """Rebases relative paths in images.json from the assembly working directory |
| |
| into absolute paths. |
| """ |
| |
| import argparse |
| import json |
| import os |
| |
| |
| def parse_args(): |
| """Parses command-line arguments.""" |
| parser = argparse.ArgumentParser() |
| parser.add_argument( |
| "--image-json-path", |
| help="Path to image json", |
| required=True, |
| ) |
| parser.add_argument( |
| "--output", |
| help="Path to output images.json file", |
| required=True, |
| ) |
| return parser.parse_args() |
| |
| |
| def main(): |
| args = parse_args() |
| image_json_path = args.image_json_path |
| with open(image_json_path, "r") as f: |
| images = json.load(f) |
| |
| images_manifest = [] |
| for image in images: |
| newimage = image.copy() |
| newimage["path"] = os.path.abspath(newimage["path"]) |
| images_manifest.append(newimage) |
| with open(args.output, "w") as f: |
| json.dump(images_manifest, f, indent=2) |
| |
| |
| if __name__ == "__main__": |
| main() |