@@ -612,6 +612,9 @@ def system_alias(system, release, version):
612
612
613
613
### Various internal helpers
614
614
615
+ # Table for cleaning up characters in filenames.
616
+ _SIMPLE_SUBSTITUTIONS = str .maketrans (r' /\:;"()' , r'_-------' )
617
+
615
618
def _platform (* args ):
616
619
617
620
""" Helper to format the platform string in a filename
@@ -621,28 +624,13 @@ def _platform(*args):
621
624
platform = '-' .join (x .strip () for x in filter (len , args ))
622
625
623
626
# Cleanup some possible filename obstacles...
624
- platform = platform .replace (' ' , '_' )
625
- platform = platform .replace ('/' , '-' )
626
- platform = platform .replace ('\\ ' , '-' )
627
- platform = platform .replace (':' , '-' )
628
- platform = platform .replace (';' , '-' )
629
- platform = platform .replace ('"' , '-' )
630
- platform = platform .replace ('(' , '-' )
631
- platform = platform .replace (')' , '-' )
627
+ platform = platform .translate (_SIMPLE_SUBSTITUTIONS )
632
628
633
629
# No need to report 'unknown' information...
634
630
platform = platform .replace ('unknown' , '' )
635
631
636
632
# Fold '--'s and remove trailing '-'
637
- while True :
638
- cleaned = platform .replace ('--' , '-' )
639
- if cleaned == platform :
640
- break
641
- platform = cleaned
642
- while platform and platform [- 1 ] == '-' :
643
- platform = platform [:- 1 ]
644
-
645
- return platform
633
+ return re .sub (r'-{2,}' , '-' , platform ).rstrip ('-' )
646
634
647
635
def _node (default = '' ):
648
636
0 commit comments