-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathconvert_dump.py
executable file
·46 lines (32 loc) · 979 Bytes
/
convert_dump.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
#
# SPDX-FileCopyrightText: 2024 The LineageOS Project
# SPDX-License-Identifier: Apache-2.0
#
import argparse
import os
import shutil
from os import path
from extract_utils.extract import move_alternate_partition_paths
parser = argparse.ArgumentParser(
description='Convert extract dump from bash extract_utils'
'to python extract_utils structure',
)
parser.add_argument(
'dump_dir',
help='dump directory',
nargs='*',
)
def convert_dump(dump_dir: str):
dump_output_dir = path.join(dump_dir, 'output')
if path.isdir(dump_output_dir):
for file in os.scandir(dump_output_dir):
shutil.move(file.path, dump_dir)
shutil.rmtree(dump_output_dir)
move_alternate_partition_paths(dump_dir)
def convert_dumps(dump_dirs: str):
for dump_dir in dump_dirs:
convert_dump(dump_dir)
if __name__ == '__main__':
parser_args = parser.parse_args()
convert_dumps(parser_args.dump_dir)