Return a list of Fortran f90 module names that given source file defines.
(source)
| 469 | f90_ext_match = re.compile(r'.*\.(f90|f95)\Z', re.I).match |
| 470 | f90_module_name_match = re.compile(r'\s*module\s*(?P<name>[\w_]+)', re.I).match |
| 471 | def _get_f90_modules(source): |
| 472 | """Return a list of Fortran f90 module names that |
| 473 | given source file defines. |
| 474 | """ |
| 475 | if not f90_ext_match(source): |
| 476 | return [] |
| 477 | modules = [] |
| 478 | with open(source) as f: |
| 479 | for line in f: |
| 480 | m = f90_module_name_match(line) |
| 481 | if m: |
| 482 | name = m.group('name') |
| 483 | modules.append(name) |
| 484 | # break # XXX can we assume that there is one module per file? |
| 485 | return modules |
| 486 | |
| 487 | def is_string(s): |
| 488 | return isinstance(s, str) |
no test coverage detected