Join translated glob pattern parts. This is different from a simple join, as care need to be taken to allow ** to match ZERO or more directories.
(translated_parts, os_sep_class)
| 658 | |
| 659 | |
| 660 | def _join_translated(translated_parts, os_sep_class): |
| 661 | """Join translated glob pattern parts. |
| 662 | |
| 663 | This is different from a simple join, as care need to be taken |
| 664 | to allow ** to match ZERO or more directories. |
| 665 | """ |
| 666 | res = '' |
| 667 | for part in translated_parts[:-1]: |
| 668 | if part == '.*': |
| 669 | # drop separator, since it is optional |
| 670 | # (** matches ZERO or more dirs) |
| 671 | res += part |
| 672 | else: |
| 673 | res += part + os_sep_class |
| 674 | |
| 675 | if translated_parts[-1] == '.*': |
| 676 | # Final part is ** |
| 677 | res += '.+' |
| 678 | # Follow stdlib/git convention of matching all sub files/directories: |
| 679 | res += '({os_sep_class}?.*)?'.format(os_sep_class=os_sep_class) |
| 680 | else: |
| 681 | res += translated_parts[-1] |
| 682 | return res |
| 683 | |
| 684 | |
| 685 | def _translate_glob_part(pat): |