Skip to content

Commit

Permalink
Update clean_yaml.py
Browse files Browse the repository at this point in the history
Signed-off-by: ҉αkα x⠠⠵ <[email protected]>
  • Loading branch information
4k4xs4pH1r3 authored Nov 28, 2024
1 parent f7d2a59 commit 91f8d94
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Python/Anaconda/Apple/m4/clean_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 91f8d94

Please sign in to comment.