@sudo_support
def get_new_command(command):
 dest = command.script_parts[1].split(os.sep)
 if (dest[(-1)] == ''):
  dest = dest[:(-1)]
 if six.PY2:
  cwd = os.getcwdu()
 else:
  cwd = os.getcwd()
 for directory in dest:
  if (directory == '.'):
   continue
  elif (directory == '..'):
   cwd = os.path.split(cwd)[0]
   continue
  best_matches = get_close_matches(directory, _get_sub_dirs(cwd), cutoff=MAX_ALLOWED_DIFF)
  if best_matches:
   cwd = os.path.join(cwd, best_matches[0])
  else:
   return cd_mkdir.get_new_command(command)
 return u'cd "{0}"'.format(cwd)

@ sudo_support def get_new_command ( command ) : dest = command . script_parts [ 1 ] . split ( os . sep ) if ( dest [ ( - 1 ) ] == '' ) : dest = dest [ : ( - 1 ) ] if six . PY2 : cwd = os . getcwdu ( ) else : cwd = os . getcwd ( ) for directory in dest : if ( directory == '.' ) : continue elif ( directory == '..' ) : cwd = os . path . split ( cwd ) [ 0 ] continue best_matches = get_close_matches ( directory , _get_sub_dirs ( cwd ) , cutoff = MAX_ALLOWED_DIFF ) if best_matches : cwd = os . path . join ( cwd , best_matches [ 0 ] ) else : return cd_mkdir . get_new_command ( command ) return u'cd "{0}"' . format ( cwd )
attempt to rebuild the path string by spellchecking the directories .