Debian Codegraph @

libs/CCAppCommon/QDarkStyleSheet/qdarkstyle/__main__.py

raw
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Standard library imports
5 import argparse
6 import sys
7 from os.path import abspath, dirname
8
9 # Local imports
10 import qdarkstyle
11
12 sys.path.insert(0, abspath(dirname(abspath(__file__)) + '/..'))
13
14
15 def main():
16 """Execute QDarkStyle helper."""
17 parser = argparse.ArgumentParser(description="QDarkStyle helper. Use the option --all to report bugs (requires 'helpdev')",
18 formatter_class=argparse.RawDescriptionHelpFormatter)
19 parser.add_argument('-i', '--information', action='store_true',
20 help="Show information about environment")
21 parser.add_argument('-b', '--bindings', action='store_true',
22 help="Show available bindings for Qt")
23 parser.add_argument('-a', '--abstractions', action='store_true',
24 help="Show available abstraction layers for Qt bindings")
25 parser.add_argument('-d', '--dependencies', action='store_true',
26 help="Show information about dependencies")
27
28 parser.add_argument('--all', action='store_true',
29 help="Show all information options at once")
30
31 parser.add_argument('--version', '-v', action='version',
32 version='v{}'.format(qdarkstyle.__version__))
33
34 # parsing arguments from command line
35 args = parser.parse_args()
36 no_args = not len(sys.argv) > 1
37 info = {}
38
39 if no_args:
40 parser.print_help()
41
42 try:
43 import helpdev
44
45 except (ModuleNotFoundError, ImportError):
46 print("You need to install the package helpdev to retrieve detailed information (e.g pip install helpdev)")
47
48 else:
49 if args.information or args.all:
50 info.update(helpdev.check_os())
51 info.update(helpdev.check_python())
52
53 if args.bindings or args.all:
54 info.update(helpdev.check_qt_bindings())
55
56 if args.abstractions or args.all:
57 info.update(helpdev.check_qt_abstractions())
58
59 if args.dependencies or args.all:
60 info.update(helpdev.check_python_packages(packages='helpdev,qdarkstyle'))
61
62 helpdev.print_output(info)
63
64
65 if __name__ == "__main__":
66 sys.exit(main())