def short_platform(r=None, p=None):
 if (r is None):
  r = platform.release()
 if (p is None):
  p = platform.platform()
 sp = r.split('-')
 if (len(sp) < 2):
  return p
 kernel_version = sp[0].split('.')
 if (len(kernel_version) <= 2):
  return p
 sp[0] = '.'.join(kernel_version[:2])
 rest = sp[1].split('.')
 while len(rest):
  if rest[0].isdigit():
   del rest[0]
  else:
   break
 sp[1] = '.'.join(rest)
 sr = '-'.join(sp)
 p = p.replace(r, sr)
 return p

def short_platform ( r = None , p = None ) : if ( r is None ) : r = platform . release ( ) if ( p is None ) : p = platform . platform ( ) sp = r . split ( '-' ) if ( len ( sp ) < 2 ) : return p kernel_version = sp [ 0 ] . split ( '.' ) if ( len ( kernel_version ) <= 2 ) : return p sp [ 0 ] = '.' . join ( kernel_version [ : 2 ] ) rest = sp [ 1 ] . split ( '.' ) while len ( rest ) : if rest [ 0 ] . isdigit ( ) : del rest [ 0 ] else : break sp [ 1 ] = '.' . join ( rest ) sr = '-' . join ( sp ) p = p . replace ( r , sr ) return p
return a safe shorter version of platform .