def preview_pipes(folder_path): if context.ids_roi(context.roitp): for pipe_path in common.pipes_paths(folder_path): if context.ids_ignorable(pipe_path): pass elif context.ids_replaceable_last(pipe_path): shower.show_red_tipped(pipe_path) shower.show_green_tipped( common.replacement_last(pipe_path, context.regex, context.token))
def preview_link(link_path): headed = False if context.ids_roi(context.roitk): if context.ids_replaceable_last(link_path): shower.show_red_tipped(link_path) shower.show_green_tipped( common.replacement_last(link_path, context.regex, context.token)) headed = True preview_terl(link_path, headed)
def replace_file_in_file(file_path): if context.ids_ignorable(file_path): pass elif context.ids_replaceable_last(file_path): source_file_path = file_path target_file_path = common.replacement_last(file_path, context.regex, context.token) try: os.makedirs(os.path.dirname(target_file_path)) except IOError: pass os.rename(source_file_path, target_file_path)
def preview_folder(folder_path): if context.ids_roi(context.roitd): if context.ids_replaceable_last(folder_path): shower.show_red_tipped(folder_path) shower.show_green_tipped( common.replacement_last(folder_path, context.regex, context.token)) preview_files(folder_path) preview_links(folder_path) preview_pipes(folder_path) preview_folders(folder_path)
def replace_pipes_in_folder(folder_path): if context.ids_ignorable(folder_path): pass else: for subfolder_path in common.folders_paths(folder_path): replace_pipes_in_folder(subfolder_path) for pipe_path in common.pipes_paths(folder_path): if context.ids_ignorable(pipe_path): pass elif context.ids_replaceable_last(pipe_path): source_pipe_path = pipe_path target_pipe_path = common.replacement_last( pipe_path, context.regex, context.token) os.rename(source_pipe_path, target_pipe_path)
def replace_links_in_folder(folder_path): if context.ids_ignorable(folder_path): pass else: for subfolder_path in common.folders_paths(folder_path): replace_links_in_folder(subfolder_path) for link_path in common.links_paths(folder_path): if context.ids_ignorable(link_path): pass elif context.ids_replaceable_last(link_path): source_link_path = link_path target_link_path = common.replacement_last( link_path, context.regex, context.token) terminal = os.path.realpath(source_link_path) os.remove(source_link_path) os.symlink(terminal, target_link_path)
def replace_folders_in_folder(folder_path): if context.ids_ignorable(folder_path): pass else: for subfolder_path in common.folders_paths(folder_path): replace_folders_in_folder(subfolder_path) if context.ids_replaceable_last(folder_path): source_folder_path = folder_path target_folder_path = common.replacement_last( folder_path, context.regex, context.token) try: os.makedirs(target_folder_path) except Error: pass os.rename(source_folder_path, target_folder_path)