Helper to format the platform string in a filename compatible format e.g. "system-version-machine".
(*args)
| 541 | ### Various internal helpers |
| 542 | |
| 543 | def _platform(*args): |
| 544 | |
| 545 | """ Helper to format the platform string in a filename |
| 546 | compatible format e.g. "system-version-machine". |
| 547 | """ |
| 548 | # Format the platform string |
| 549 | platform = '-'.join(x.strip() for x in filter(len, args)) |
| 550 | |
| 551 | # Cleanup some possible filename obstacles... |
| 552 | platform = platform.replace(' ', '_') |
| 553 | platform = platform.replace('/', '-') |
| 554 | platform = platform.replace('\\', '-') |
| 555 | platform = platform.replace(':', '-') |
| 556 | platform = platform.replace(';', '-') |
| 557 | platform = platform.replace('"', '-') |
| 558 | platform = platform.replace('(', '-') |
| 559 | platform = platform.replace(')', '-') |
| 560 | |
| 561 | # No need to report 'unknown' information... |
| 562 | platform = platform.replace('unknown', '') |
| 563 | |
| 564 | # Fold '--'s and remove trailing '-' |
| 565 | while 1: |
| 566 | cleaned = platform.replace('--', '-') |
| 567 | if cleaned == platform: |
| 568 | break |
| 569 | platform = cleaned |
| 570 | while platform[-1] == '-': |
| 571 | platform = platform[:-1] |
| 572 | |
| 573 | return platform |
| 574 | |
| 575 | def _node(default=''): |
| 576 |