MCPcopy Index your code
hub / github.com/RustPython/RustPython / _platform

Function _platform

Lib/platform.py:656–686  ·  view source on GitHub ↗

Helper to format the platform string in a filename compatible format e.g. "system-version-machine".

(*args)

Source from the content-addressed store, hash-verified

654### Various internal helpers
655
656def _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
688def _node(default=''):
689

Callers 1

platformFunction · 0.85

Calls 4

filterFunction · 0.85
joinMethod · 0.45
stripMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected