Fix plugins with MSVC, thanks to Gulam Faruque.
[syx.git] / scripts / excm.py
blob8dd78f3113463a22628dcd006badf9654eff20f8
1 #!/usr/bin/env python
3 # Extract comments from source files
5 import os, re
7 def dump_filename (filename):
8 print "==== %s ====" % filename
10 rx_c = re.compile ("/\*(.+?)\*/", re.M | re.S)
11 rx_st = re.compile ("\"(.+?)\"", re.M | re.S)
13 def extract_from_c (contents):
14 matches = rx_c.findall (contents)
15 for match in matches:
16 if 'Copyright' in match:
17 continue
18 if match.isupper ():
19 continue
20 if 'automatically generated' in match:
21 continue
22 print match
23 # print '---------------------'
25 def extract_from_st (contents):
26 matches = rx_st.findall (contents)
27 for match in matches:
28 if 'Copyright' in match:
29 continue
30 print match
32 for dirpath, dirnames, filenames in os.walk("."):
33 if '.svn' in dirpath or 'sconf' in dirpath:
34 continue
36 for filename in filenames:
37 root, ext = os.path.splitext (filename)
39 if ext not in ('.c', '.st', '.py'):
40 continue
42 filename = os.path.join (dirpath, filename)
43 dump_filename (filename)
45 f = file (filename)
46 contents = f.read()
47 if ext == '.c':
48 extract_from_c (contents)
49 elif ext == '.st':
50 extract_from_st (contents)
51 f.close ()