From 91f8d943f94a6bcee586e2d3d05016865c8d2518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D2=89=CE=B1k=CE=B1=20x=E2=A0=A0=E2=A0=B5?= <32862241+4k4xs4pH1r3@users.noreply.github.com> Date: Thu, 28 Nov 2024 09:57:30 -0500 Subject: [PATCH] Update clean_yaml.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ҉αkα x⠠⠵ <32862241+4k4xs4pH1r3@users.noreply.github.com> --- Python/Anaconda/Apple/m4/clean_yaml.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Python/Anaconda/Apple/m4/clean_yaml.py b/Python/Anaconda/Apple/m4/clean_yaml.py index 02b0c7f..c015d13 100644 --- a/Python/Anaconda/Apple/m4/clean_yaml.py +++ b/Python/Anaconda/Apple/m4/clean_yaml.py @@ -4,20 +4,24 @@ with open('x.yaml', 'r') as f: data = yaml.safe_load(f) -# Process dependencies, handling both strings and dictionaries +# Process regular dependencies new_dependencies = [] for item in data['dependencies']: if isinstance(item, str): package_name = item.split('=')[0] new_dependencies.append(package_name) elif isinstance(item, dict): - # Assuming each dictionary has one key-value pair - package_name = list(item.keys())[0].split('=')[0] + package_name = list(item.keys())[0].split('=')[0] new_dependencies.append(package_name) - -# Update the dependencies in the data data['dependencies'] = new_dependencies +# Process pip dependencies +new_pip_dependencies = [] +for item in data['pip']: + package_name = item.split('==')[0] + new_pip_dependencies.append(package_name) +data['pip'] = new_pip_dependencies + # Write the modified data back to the YAML file with open('x.yaml', 'w') as f: - yaml.dump(data, f, indent=2) # Added indent for better readability + yaml.dump(data, f, indent=2)