3 # Extract comments from source files
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
)
16 if 'Copyright' in match
:
20 if 'automatically generated' in match
:
23 # print '---------------------'
25 def extract_from_st (contents
):
26 matches
= rx_st
.findall (contents
)
28 if 'Copyright' in match
:
32 for dirpath
, dirnames
, filenames
in os
.walk("."):
33 if '.svn' in dirpath
or 'sconf' in dirpath
:
36 for filename
in filenames
:
37 root
, ext
= os
.path
.splitext (filename
)
39 if ext
not in ('.c', '.st', '.py'):
42 filename
= os
.path
.join (dirpath
, filename
)
43 dump_filename (filename
)
48 extract_from_c (contents
)
50 extract_from_st (contents
)