整理composer安装版本的python脚本

2024-01-08 18:37:33

整理composer安装版本的python脚本

脚本实现的功能是去除composer安装命令后的版本号

def remove_version_numbers(commands):
    """
 Remove version numbers from composer require commands.

 Args:
 commands (list of str): List of composer require commands.

 Returns:
 list of str: Commands with version numbers removed.
 """
    cleaned_commands = []
    for command in commands:
        # Split the command by space and remove any part that starts with '^'
        parts = [part for part in command.split() if not part.startswith('^')]
        cleaned_command = ' '.join(parts)
        cleaned_commands.append(cleaned_command)

    return cleaned_commands


def main():
    print("请输入您的 Composer 命令,每行一个。输入 'END' 来结束输入:")
    user_input = []
    while True:
        line = input()
        if line == "END":
            break
        user_input.append(line)

    # 移除版本号
    cleaned_commands = remove_version_numbers(user_input)
    print("\n处理后的命令:")
    for command in cleaned_commands:
        print(command)


if __name__ == "__main__":
    main()

文章来源:https://blog.csdn.net/Suprman88/article/details/135384889
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。