MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _platform

Function _platform

tools/python-3.11.9-amd64/Lib/platform.py:543–573  ·  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

541### Various internal helpers
542
543def _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
575def _node(default=''):
576

Callers 1

platformFunction · 0.85

Calls 4

stripMethod · 0.80
filterFunction · 0.70
joinMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected