def rename_ep_file(cur_path, new_path, old_path_length=0):
 if ((old_path_length == 0) or (old_path_length > len(cur_path))):
  (cur_file_name, cur_file_ext) = os.path.splitext(cur_path)
 else:
  cur_file_ext = cur_path[old_path_length:]
  cur_file_name = cur_path[:old_path_length]
 if (cur_file_ext[1:] in subtitleExtensions):
  sublang = os.path.splitext(cur_file_name)[1][1:]
  from sickrage.core.searchers import subtitle_searcher
  if subtitle_searcher.isValidLanguage(sublang):
   cur_file_ext = ((u'.' + sublang) + cur_file_ext)
 new_path += cur_file_ext
 make_dirs(os.path.dirname(new_path))
 try:
  sickrage.srCore.srLogger.info((u'Renaming file from %s to %s' % (cur_path, new_path)))
  moveFile(cur_path, new_path)
 except (OSError, IOError) as e:
  sickrage.srCore.srLogger.error((u'Failed renaming %s to %s : %r' % (cur_path, new_path, e)))
  return False
 delete_empty_folders(os.path.dirname(cur_path))
 return True

def rename_ep_file ( cur_path , new_path , old_path_length = 0 ) : if ( ( old_path_length == 0 ) or ( old_path_length > len ( cur_path ) ) ) : ( cur_file_name , cur_file_ext ) = os . path . splitext ( cur_path ) else : cur_file_ext = cur_path [ old_path_length : ] cur_file_name = cur_path [ : old_path_length ] if ( cur_file_ext [ 1 : ] in subtitleExtensions ) : sublang = os . path . splitext ( cur_file_name ) [ 1 ] [ 1 : ] from sickrage . core . searchers import subtitle_searcher if subtitle_searcher . isValidLanguage ( sublang ) : cur_file_ext = ( ( u'.' + sublang ) + cur_file_ext ) new_path += cur_file_ext make_dirs ( os . path . dirname ( new_path ) ) try : sickrage . srCore . srLogger . info ( ( u'Renaming file from %s to %s' % ( cur_path , new_path ) ) ) moveFile ( cur_path , new_path ) except ( OSError , IOError ) as e : sickrage . srCore . srLogger . error ( ( u'Failed renaming %s to %s : %r' % ( cur_path , new_path , e ) ) ) return False delete_empty_folders ( os . path . dirname ( cur_path ) ) return True
creates all folders needed to move a file to its new location .