Пример #1
0
def set_function_names_loweru(paths):
    for path in paths:
        string = open(path).read()
        tuples = [(name, set_loweru(name))
                  for name in find_function_names(string)]
        for path2 in paths:  #must apply in path
            apply_to_file(path2, lambda s: replace_words(tuples, s))
Пример #2
0
def set_function_names_loweru(paths):
    for path in paths:
        string = open(path).read()
        tuples = [(name, set_loweru(name)) for name in find_function_names(string)]
        for path2 in paths:  # must apply in path
            apply_to_file(path2, lambda s: replace_words(tuples, s))
Пример #3
0
    def aux(s):
        return "_" + s.group(1).lower()

    string = string[0].lower() + string[1:]
    return re.sub("(?!^)_?([A-Z])", aux, string)


def replace_words(list_tuple, string):
    for w1, w2 in list_tuple:
        string = re.sub("(?<!\w)" + w1 + "(?!\w)", w2, string)
    return string


def set_function_names_loweru(paths):
    for path in paths:
        string = open(path).read()
        tuples = [(name, set_loweru(name)) for name in find_function_names(string)]
        for path2 in paths:  # must apply in path
            apply_to_file(path2, lambda s: replace_words(tuples, s))


if __name__ == "__main__":
    paths = sys.argv[2:]
    if len(sys.argv) <= 2:
        pass
    elif sys.argv[1] == "blank":
        for path in paths:
            apply_to_file(path, set_blanks_lines)
    elif sys.argv[1] == "names":
        set_function_names_loweru(paths)
Пример #4
0
        return "_" + s.group(1).lower()

    string = string[0].lower() + string[1:]
    return re.sub("(?!^)_?([A-Z])", aux, string)


def replace_words(list_tuple, string):
    for w1, w2 in list_tuple:
        string = re.sub("(?<!\w)" + w1 + "(?!\w)", w2, string)
    return string


def set_function_names_loweru(paths):
    for path in paths:
        string = open(path).read()
        tuples = [(name, set_loweru(name))
                  for name in find_function_names(string)]
        for path2 in paths:  #must apply in path
            apply_to_file(path2, lambda s: replace_words(tuples, s))


if __name__ == "__main__":
    paths = sys.argv[2:]
    if len(sys.argv) <= 2:
        pass
    elif sys.argv[1] == "blank":
        for path in paths:
            apply_to_file(path, set_blanks_lines)
    elif sys.argv[1] == "names":
        set_function_names_loweru(paths)