Helper to format the platform string in a filename compatible format e.g. "system-version-machine".
(*args)
| 654 | ### Various internal helpers |
| 655 | |
| 656 | def _platform(*args): |
| 657 | |
| 658 | """ Helper to format the platform string in a filename |
| 659 | compatible format e.g. "system-version-machine". |
| 660 | """ |
| 661 | # Format the platform string |
| 662 | platform = '-'.join(x.strip() for x in filter(len, args)) |
| 663 | |
| 664 | # Cleanup some possible filename obstacles... |
| 665 | platform = platform.replace(' ', '_') |
| 666 | platform = platform.replace('/', '-') |
| 667 | platform = platform.replace('\\', '-') |
| 668 | platform = platform.replace(':', '-') |
| 669 | platform = platform.replace(';', '-') |
| 670 | platform = platform.replace('"', '-') |
| 671 | platform = platform.replace('(', '-') |
| 672 | platform = platform.replace(')', '-') |
| 673 | |
| 674 | # No need to report 'unknown' information... |
| 675 | platform = platform.replace('unknown', '') |
| 676 | |
| 677 | # Fold '--'s and remove trailing '-' |
| 678 | while True: |
| 679 | cleaned = platform.replace('--', '-') |
| 680 | if cleaned == platform: |
| 681 | break |
| 682 | platform = cleaned |
| 683 | while platform and platform[-1] == '-': |
| 684 | platform = platform[:-1] |
| 685 | |
| 686 | return platform |
| 687 | |
| 688 | def _node(default=''): |
| 689 |