Skip to content

Commit 24df4ec

Browse files
committed
scripts: entry points moved to scripts
1 parent 2dacbf3 commit 24df4ec

File tree

5 files changed

+50
-57
lines changed

5 files changed

+50
-57
lines changed

analyzer/bear.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
import pkg_resources
3333
import itertools
3434
from analyzer import duplicate_check, tempdir
35-
from analyzer.decorators import to_logging_level, trace, entry
36-
from analyzer.options import create_parser
35+
from analyzer.decorators import trace
3736
from analyzer.command import classify_parameters
3837
from analyzer.command import Action
3938

39+
4040
if 'darwin' == sys.platform:
4141
ENVIRONMENTS = [("ENV_OUTPUT", "BEAR_OUTPUT"),
4242
("ENV_PRELOAD", "DYLD_INSERT_LIBRARIES"),
@@ -46,25 +46,6 @@
4646
("ENV_PRELOAD", "LD_PRELOAD")]
4747

4848

49-
@entry
50-
def bear():
51-
""" Entry point for 'bear'.
52-
53-
This part initializes some parts and forwards to the main method. """
54-
55-
parser = create_parser('bear')
56-
args = parser.parse_args()
57-
58-
logging.getLogger().setLevel(to_logging_level(args.verbose))
59-
logging.debug(args)
60-
61-
if args.help or 0 == len(args.build):
62-
parser.print_help()
63-
return 0
64-
65-
return main(args)
66-
67-
6849
def main(args):
6950
""" The reusable entry point of 'bear'.
7051

analyzer/beye.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,13 @@
2121
import tempfile
2222
import multiprocessing
2323
from analyzer import tempdir
24-
from analyzer.options import create_parser
25-
from analyzer.decorators import to_logging_level, trace, entry
24+
from analyzer.decorators import to_logging_level, trace
2625
from analyzer.command import generate_commands
2726
from analyzer.runner import run
2827
from analyzer.report import document
2928
from analyzer.clang import get_checkers
3029

3130

32-
@entry
33-
def scanbuild():
34-
""" Entry point for 'scan-build' command.
35-
36-
This method combines the 'bear' and 'beye' commands to imitate the
37-
original Perl implementation of 'scan-build' command. """
38-
39-
from analyzer.bear import main as run_bear
40-
parser = create_parser('scan-build')
41-
return main(parser, run_bear)
42-
43-
44-
@entry
45-
def beye():
46-
""" Entry point for 'beye' command.
47-
48-
It takes a compilation database as input and run analyzer against each
49-
files. The logic to run analyzer against a single file is implemented in
50-
several modules. """
51-
52-
parser = create_parser('beye')
53-
return main(parser, lambda x: 0)
54-
55-
5631
def main(parser, intercept):
5732
""" The reusable entry point of 'beye'.
5833

bin/bear

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,25 @@
66
# License. See LICENSE.TXT for details.
77

88
import sys
9-
from analyzer.bear import bear
9+
import logging
10+
from analyzer.decorators import to_logging_level, entry
11+
from analyzer.options import create_parser
12+
from analyzer.bear import main as run_bear
13+
14+
15+
@entry
16+
def main():
17+
parser = create_parser('bear')
18+
args = parser.parse_args()
19+
20+
logging.getLogger().setLevel(to_logging_level(args.verbose))
21+
logging.debug(args)
22+
23+
if args.help or 0 == len(args.build):
24+
parser.print_help()
25+
return 0
26+
return run_bear(args)
27+
1028

1129
if __name__ == '__main__':
12-
sys.exit(bear())
30+
sys.exit(main())

bin/beye

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@
66
# License. See LICENSE.TXT for details.
77

88
import sys
9-
from multiprocessing import freeze_support
10-
from analyzer.beye import beye
9+
import multiprocessing
10+
from analyzer.options import create_parser
11+
from analyzer.decorators import entry
12+
from analyzer.beye import main as run_beye
13+
14+
15+
@entry
16+
def main():
17+
parser = create_parser('beye')
18+
return run_beye(parser, lambda x: 0)
19+
1120

1221
if __name__ == '__main__':
13-
freeze_support()
14-
sys.exit(beye())
22+
multiprocessing.freeze_support()
23+
sys.exit(main())

bin/scan-build

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@
66
# License. See LICENSE.TXT for details.
77

88
import sys
9-
from multiprocessing import freeze_support
10-
from analyzer.beye import scanbuild
9+
import multiprocessing
10+
from analyzer.options import create_parser
11+
from analyzer.decorators import entry
12+
from analyzer.bear import main as run_bear
13+
from analyzer.beye import main as run_beye
14+
15+
16+
@entry
17+
def main():
18+
parser = create_parser('scan-build')
19+
return run_beye(parser, run_bear)
20+
1121

1222
if __name__ == '__main__':
13-
freeze_support()
14-
sys.exit(scanbuild())
23+
multiprocessing.freeze_support()
24+
sys.exit(main())

0 commit comments

Comments
 (0)