Simple matching of version numbers, for use in CCompiler and FCompiler. Parameters ---------- pat : str, optional A regular expression matching version numbers. Default is ``r'[-.\\d]+'``. ignore : str, optional A regular expression matching patterns to
(pat=r'[-.\d]+', ignore='', start='')
| 560 | replace_method(CCompiler, 'customize', CCompiler_customize) |
| 561 | |
| 562 | def simple_version_match(pat=r'[-.\d]+', ignore='', start=''): |
| 563 | """ |
| 564 | Simple matching of version numbers, for use in CCompiler and FCompiler. |
| 565 | |
| 566 | Parameters |
| 567 | ---------- |
| 568 | pat : str, optional |
| 569 | A regular expression matching version numbers. |
| 570 | Default is ``r'[-.\\d]+'``. |
| 571 | ignore : str, optional |
| 572 | A regular expression matching patterns to skip. |
| 573 | Default is ``''``, in which case nothing is skipped. |
| 574 | start : str, optional |
| 575 | A regular expression matching the start of where to start looking |
| 576 | for version numbers. |
| 577 | Default is ``''``, in which case searching is started at the |
| 578 | beginning of the version string given to `matcher`. |
| 579 | |
| 580 | Returns |
| 581 | ------- |
| 582 | matcher : callable |
| 583 | A function that is appropriate to use as the ``.version_match`` |
| 584 | attribute of a `CCompiler` class. `matcher` takes a single parameter, |
| 585 | a version string. |
| 586 | |
| 587 | """ |
| 588 | def matcher(self, version_string): |
| 589 | # version string may appear in the second line, so getting rid |
| 590 | # of new lines: |
| 591 | version_string = version_string.replace('\n', ' ') |
| 592 | pos = 0 |
| 593 | if start: |
| 594 | m = re.match(start, version_string) |
| 595 | if not m: |
| 596 | return None |
| 597 | pos = m.end() |
| 598 | while True: |
| 599 | m = re.search(pat, version_string[pos:]) |
| 600 | if not m: |
| 601 | return None |
| 602 | if ignore and re.match(ignore, m.group(0)): |
| 603 | pos = m.end() |
| 604 | continue |
| 605 | break |
| 606 | return m.group(0) |
| 607 | return matcher |
| 608 | |
| 609 | def CCompiler_get_version(self, force=False, ok_status=[0]): |
| 610 | """ |
no outgoing calls
no test coverage detected