Skip to content

Commit

Permalink
Replace ruby script with python (issue ros2#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
eholum committed Jun 9, 2024
1 parent d53267f commit 3a103c8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ setup:
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# Install repos file generator script requirements.
RUN apt-get install -y python3-rosinstall-generator ruby
RUN apt-get install -y python3-rosinstall-generator

repos-file:
FROM +setup
Expand All @@ -48,7 +48,7 @@ repos-file:
--outfile ros2.repos \
--packages spaceros-pkgs.txt \
--excluded-packages excluded-pkgs.txt
RUN --no-cache ruby scripts/merge-repos.rb
RUN --no-cache python3 scripts/merge-repos.py

# Save the generated .repos file
SAVE ARTIFACT ros2.repos AS LOCAL ros2.repos
Expand Down
22 changes: 22 additions & 0 deletions scripts/merge-repos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3

import yaml

# Load YAML repos files
with open('ros2.repos', 'r') as ros2_file:
ros2 = yaml.safe_load(ros2_file)

with open('spaceros.repos', 'r') as spaceros_file:
spaceros = yaml.safe_load(spaceros_file)

# Merge repos
for repo, data in spaceros['repositories'].items():
ros2['repositories'][repo] = data

# Sort repositories and create a new ordered dictionary
sorted_repositories = {repo: ros2['repositories'][repo] for repo in sorted(ros2['repositories'].keys())}
ros2['repositories'] = sorted_repositories

# Write the updated YAML back to file
with open('ros2.repos', 'w') as ros2_file:
yaml.dump(ros2, ros2_file, default_flow_style=False, explicit_start=True)
22 changes: 0 additions & 22 deletions scripts/merge-repos.rb

This file was deleted.

0 comments on commit 3a103c8

Please sign in to comment.