Merge pull request #3207 from techee/glob_removal
[geany-mirror.git] / scripts / update-ctags.py
blob9dac9efb297ef6816528da5c4b61871b1499d0a8
1 #!/usr/bin/env python3
3 import glob
4 import os
5 import shutil
6 import sys
8 if len(sys.argv) != 3:
9 print('Usage: update-ctags.py <universal ctags directory> <geany ctags directory>')
10 sys.exit(1)
12 srcdir = os.path.abspath(sys.argv[1])
13 dstdir = os.path.abspath(sys.argv[2])
15 os.chdir(dstdir + '/parsers')
16 parser_dst_files = glob.glob('*.c') + glob.glob('*.h')
17 parser_dst_files = list(filter(lambda x: not x.startswith('geany_'), parser_dst_files))
18 cxx_parser_dst_files = glob.glob('cxx/*.c') + glob.glob('cxx/*.h')
19 for f in cxx_parser_dst_files:
20 os.remove(f)
22 os.chdir(srcdir + '/parsers')
23 print('Copying parsers... ({} files)'.format(len(parser_dst_files)))
24 for f in parser_dst_files:
25 shutil.copy(f, dstdir + '/parsers')
27 cxx_parser_src_files = glob.glob('cxx/*.c') + glob.glob('cxx/*.h')
28 print('Copying cxx parser files... ({} files)'.format(len(cxx_parser_src_files)))
29 for f in cxx_parser_src_files:
30 shutil.copy(f, dstdir + '/parsers/cxx')
32 print('Copying dsl files...')
33 for f in ['dsl/es.c', 'dsl/es.h', 'dsl/optscript.c', 'dsl/optscript.h']:
34 shutil.copy(srcdir + '/' + f, dstdir + '/' + f)
36 os.chdir(srcdir)
37 main_src_files = glob.glob('main/*.c') + glob.glob('main/*.h')
38 os.chdir(dstdir)
39 main_dst_files = glob.glob('main/*.c') + glob.glob('main/*.h')
41 for f in main_dst_files:
42 os.remove(f)
43 os.chdir(srcdir)
44 print('Copying main... ({} files)'.format(len(main_src_files)))
45 for f in main_src_files:
46 shutil.copy(f, dstdir + '/main')
48 main_diff = set(main_dst_files) - set(main_src_files)
49 if main_diff:
50 print('Files removed from main: ' + str(main_diff))
51 main_diff = set(main_src_files) - set(main_dst_files)
52 if main_diff:
53 print('Files added to main: ' + str(main_diff))