Beispiel #1
0
def find_link(link_path):
    headed = False
    if context.ids_roi(context.roitk):
        if context.ids_replaceable_last(link_path):
            shower.show_red_tipped(link_path)
            headed = True
    find_terl(link_path, headed)
Beispiel #2
0
def find_file(file_path):
    headed = False
    if context.ids_roi(context.roitf):
        if context.ids_replaceable_last(file_path):
            shower.show_red_tipped(file_path)
            headed = True
    find_lines(file_path, headed)
Beispiel #3
0
def find_terl(link_path, headed):
    if context.ids_roi(context.roitt):
        if context.ids_replaceable(common.terminal(link_path)):
            if headed: pass
            else:
                shower.show_blue(link_path)
                headed = True
            shower.show_red_matched(common.terminal(link_path))
Beispiel #4
0
def find_folder(folder_path):
    if context.ids_roi(context.roitd):
        if context.ids_replaceable_last(folder_path):
            shower.show_red_tipped(folder_path)
    find_files(folder_path)
    find_links(folder_path)
    find_pipes(folder_path)
    find_folders(folder_path)
Beispiel #5
0
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))
Beispiel #6
0
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)
Beispiel #7
0
def preview_terl(link_path, headed):
    if context.ids_roi(context.roitp):
        if context.ids_replaceable(common.terminal(link_path)):
            if headed: pass
            else:
                shower.show_blue(link_path)
                headed = True
            shower.show_red_matched(common.terminal(link_path))
            shower.show_green_matched(
                common.replacement_all(common.terminal(link_path),
                                       context.regex, context.token))
Beispiel #8
0
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)
Beispiel #9
0
def find_lines(file_path, headed):
    if context.ids_roi(context.roitl):
        try:
            for line in open(file_path):
                if context.ids_replaceable(line):
                    if headed: pass
                    else:
                        shower.show_blue(file_path)
                        headed = True
                    shower.show_red_matched(line.rstrip())
        except UnicodeDecodeError:
            pass
Beispiel #10
0
def preview_lines(file_path, headed):
    if context.ids_roi(context.roitl):
        try:
            for line in open(file_path):
                if context.ids_replaceable(line):
                    if headed: pass
                    else:
                        shower.show_blue(file_path)
                        headed = True
                    shower.show_red_matched(line.rstrip())
                    shower.show_green_matched(
                        common.replacement_all(line.rstrip(), context.regex,
                                               context.token))
        except UnicodeDecodeError:
            pass
Beispiel #11
0
def replace():
    if common.ids_folder(context.base):
        if context.ids_roi(context.roitt):
            replace_terls_in_folder(context.base)
        if context.ids_roi(context.roitl):
            replace_lines_in_folder(context.base)
        if context.ids_roi(context.roitp):
            replace_pipes_in_folder(context.base)
        if context.ids_roi(context.roitk):
            replace_links_in_folder(context.base)
        if context.ids_roi(context.roitf):
            replace_files_in_folder(context.base)
        if context.ids_roi(context.roitd):
            replace_folders_in_folder(context.base)
    elif common.ids_file(context.base):
        if context.ids_roi(context.roitl): replace_lines_in_file(context.base)
        if context.ids_roi(context.roitf): replace_file_in_file(context.base)
    elif common.ids_link(context.base):
        if context.ids_roi(context.roitt): replace_terl_in_link(context.base)
        if context.ids_roi(context.roitk): replace_link_in_link(context.base)
    elif common.ids_pipe(context.base):
        if context.ids_roi(context.roitp): replace_pipe_in_pipe(context.base)
    else: print('unknown type of f. s. o.:', context.base)
Beispiel #12
0
def find_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)