-
Notifications
You must be signed in to change notification settings - Fork 4
/
linker.py
90 lines (73 loc) · 2.47 KB
/
linker.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python
"""
Goal: Implement the entry point for generating OneFlorda IDs
@authors:
Andrei Sura <sura.andrei@gmail.com>
"""
import time
import argparse
from datetime import timedelta
from onefl import logutils
from onefl.config import Config
from onefl.link_generator import LinkGenerator
from onefl.version import __version__
logger = logutils.get_a_logger(__file__)
# The config file is looked up relative to this "root" folder
ROOT_PATH = '.'
DEFAULT_SETTINGS_FILE = 'config/settings_linker.py'
def main():
"""
Configure the logger object and read the command line arguments
for invoking the generator.
.. seealso::
:meth:`LinkGenerator.generate`
"""
LinkGenerator.configure_logger(logger)
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--version",
default=False,
action='store_true',
help="Show the version number")
parser.add_argument("-c", "--config",
default=DEFAULT_SETTINGS_FILE,
help="Application config file")
parser.add_argument(
'-i', '--inputdir',
default='.',
help='input directory name')
parser.add_argument(
'-o', '--outputdir',
default='.',
help='output directory name')
parser.add_argument(
'-p', '--partner',
required=True,
help='output directory name')
parser.add_argument(
'-a', '--ask', action='store_true', default=False,
help='ask for confirmation to proceed')
args = parser.parse_args()
if args.version:
import sys
print("deduper, version {}".format(__version__))
sys.exit()
config = Config(root_path=ROOT_PATH, defaults={})
config.from_pyfile(args.config)
start = time.monotonic()
success = LinkGenerator.generate(config=config,
inputdir=args.inputdir,
outputdir=args.outputdir,
partner=args.partner,
ask=args.ask,
create_tables=False
)
success = True
end = time.monotonic()
elapsed = (end - start)
if success:
logger.info("Done. Process duration: {}"
.format(str(timedelta(seconds=elapsed))))
else:
logger.error("Failed!")
if __name__ == '__main__':
main()