1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3""" 4Copyright (c) 2024 Huawei Device Co., Ltd. 5Licensed under the Apache License, Version 2.0 (the "License"); 6you may not use this file except in compliance with the License. 7You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11Unless required by applicable law or agreed to in writing, software 12distributed under the License is distributed on an "AS IS" BASIS, 13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14See the License for the specific language governing permissions and 15limitations under the License. 16 17Description: metadata.json generate 18""" 19import argparse 20import os 21from shutil import copyfile 22 23 24def parse_args(): 25 parser = argparse.ArgumentParser() 26 parser.add_argument('--metadata', 27 type=str, 28 required=True, 29 help='metadata folder path') 30 parser.add_argument('--outputs', 31 type=str, 32 required=True, 33 help='copy destination') 34 args = parser.parse_args() 35 return args 36 37 38def copy_metadata(input_path, output_path): 39 if not os.path.exists(output_path): 40 os.makedirs(output_path, 0o777, True) 41 for file_name in os.listdir(input_path): 42 if os.path.isfile(os.path.join(input_path, file_name)) and file_name.endswith('.json'): 43 copyfile(os.path.join(input_path, file_name), os.path.join(output_path, file_name)) 44 45 46if __name__ == '__main__': 47 arguments = parse_args() 48 copy_metadata(arguments.metadata, arguments.outputs) 49