def safepath(value):
 if (os.name == 'nt'):
  (unt, value) = os.path.splitunc(value)
 else:
  unt = ''
 (drive, filename) = os.path.splitdrive(value)
 filename = os.path.join((os.sep if os.path.isabs(filename) else ''), *map(safename, filename.split(os.sep)))
 path = ((unt + drive) + filename)
 try:
  if (os.name != 'nt'):
   return
  length = (len(path) - 259)
  if (length < 1):
   return
  (dirname, basename) = os.path.split(filename)
  (name, ext) = os.path.splitext(basename)
  path = ((((unt + drive) + dirname) + truncate(name, length)) + ext)
 finally:
  return path

def safepath ( value ) : if ( os . name == 'nt' ) : ( unt , value ) = os . path . splitunc ( value ) else : unt = '' ( drive , filename ) = os . path . splitdrive ( value ) filename = os . path . join ( ( os . sep if os . path . isabs ( filename ) else '' ) , * map ( safename , filename . split ( os . sep ) ) ) path = ( ( unt + drive ) + filename ) try : if ( os . name != 'nt' ) : return length = ( len ( path ) - 259 ) if ( length < 1 ) : return ( dirname , basename ) = os . path . split ( filename ) ( name , ext ) = os . path . splitext ( basename ) path = ( ( ( ( unt + drive ) + dirname ) + truncate ( name , length ) ) + ext ) finally : return path
helper function to make cross-platform safe paths .