-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmerge.py
executable file
·60 lines (46 loc) · 1.97 KB
/
merge.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
#: merge.py : merge data from different version into a big database
#
# Copyright (c) 2000,2001,2007-2019 Giacomo A. Catenazzi <[email protected]>
# This is free software, see GNU General Public License v2 (or later) for details
import argparse
import logging
import lkddb
import lkddb.linux
import lkddb.ids
logger = logging.getLogger(__name__)
def make(options):
lkddb.init(options)
linux_tree = lkddb.linux.LinuxKernelTree(lkddb.TASK_CONSOLIDATE, None, [])
ids_tree = lkddb.ids.IdsTree(lkddb.TASK_CONSOLIDATE, None, None, None, None)
storage = lkddb.Storage((linux_tree, ids_tree))
logger.info("=== Read files to consolidate")
for f in options.input_file:
storage.read_data(f)
logger.info("=== Write consolidate main file")
storage.write_data(filename=options.consolidated)
#
# main
#
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Merge different lkddb data (one per version) into a single file"
)
verbose_group = parser.add_mutually_exclusive_group()
verbose_group.add_argument("-v", "--verbose",
action="count", default=1,
help="increase output verbosity")
verbose_group.add_argument("-q", "--quiet",
action="store_const", const=0,
help="inhibit messages")
parser.add_argument("-o", "--output", dest="consolidated",
action="store", type=str,
help="base FILE name to read and write data", metavar="FILE")
parser.add_argument("-l", "--log", dest="log_filename",
action="store", type=str,
help="FILE to put log messages (default is stderr)", metavar="FILE")
parser.add_argument('input_file',
action='store', type=str, nargs='+',
help="original LKDDb file")
args = parser.parse_args()
make(args)