1#!/usr/bin/env python 2""" 3sym_match - Match all symbols in a list against a list of regexes. 4""" 5from argparse import ArgumentParser 6import sys 7from sym_check import util, match, extract 8 9 10def main(): 11 parser = ArgumentParser( 12 description='Extract a list of symbols from a shared library.') 13 parser.add_argument( 14 '--blacklist', dest='blacklist', 15 type=str, action='store', default=None) 16 parser.add_argument( 17 'symbol_list', metavar='symbol_list', type=str, 18 help='The file containing the old symbol list') 19 parser.add_argument( 20 'regexes', metavar='regexes', default=[], nargs='*', 21 help='The file containing the new symbol list or a library') 22 args = parser.parse_args() 23 24 if not args.regexes and args.blacklist is None: 25 sys.stderr.write('Either a regex or a blacklist must be specified.\n') 26 sys.exit(1) 27 if args.blacklist: 28 search_list = util.read_blacklist(args.blacklist) 29 else: 30 search_list = args.regexes 31 32 symbol_list = util.extract_or_load(args.symbol_list) 33 34 matching_count, report = match.find_and_report_matching( 35 symbol_list, search_list) 36 sys.stdout.write(report) 37 if matching_count != 0: 38 print('%d matching symbols found...' % matching_count) 39 40 41if __name__ == '__main__': 42 main() 43