]> git.ipfire.org Git - people/ms/libloc.git/blob - src/python/location-importer.in
1ced867db8cb6f7b3acaae4c1944be683af15d13
[people/ms/libloc.git] / src / python / location-importer.in
1 #!/usr/bin/python3
2 ###############################################################################
3 # #
4 # libloc - A library to determine the location of someone on the Internet #
5 # #
6 # Copyright (C) 2020 IPFire Development Team <info@ipfire.org> #
7 # #
8 # This library is free software; you can redistribute it and/or #
9 # modify it under the terms of the GNU Lesser General Public #
10 # License as published by the Free Software Foundation; either #
11 # version 2.1 of the License, or (at your option) any later version. #
12 # #
13 # This library is distributed in the hope that it will be useful, #
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
16 # Lesser General Public License for more details. #
17 # #
18 ###############################################################################
19
20 import argparse
21 import logging
22 import sys
23
24 # Load our location module
25 import location
26 import location.importer
27 from location.i18n import _
28
29 # Initialise logging
30 log = logging.getLogger("location.importer")
31 log.propagate = 1
32
33 class CLI(object):
34 def parse_cli(self):
35 parser = argparse.ArgumentParser(
36 description=_("Location Importer Command Line Interface"),
37 )
38
39 # Global configuration flags
40 parser.add_argument("--debug", action="store_true",
41 help=_("Enable debug output"))
42
43 # version
44 parser.add_argument("--version", action="version",
45 version="%(prog)s @VERSION@")
46
47 args = parser.parse_args()
48
49 # Enable debug logging
50 if args.debug:
51 log.setLevel(logging.DEBUG)
52
53 return args
54
55 def run(self):
56 # Parse command line arguments
57 args = self.parse_cli()
58
59 # Call function
60 ret = self.handle_import(args)
61
62 # Return with exit code
63 if ret:
64 sys.exit(ret)
65
66 # Otherwise just exit
67 sys.exit(0)
68
69 def handle_import(self, ns):
70 pass
71
72
73 def main():
74 # Run the command line interface
75 c = CLI()
76 c.run()
77
78 main()