From 6f5f497fd39a9aed08d16399e8408d2474178fed Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Wed, 17 Jul 2019 01:25:02 +0200 Subject: [PATCH 1/2] fixup version extraction regexes Signed-off-by: Mikael Arguedas --- docker_templates/packages.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker_templates/packages.py b/docker_templates/packages.py index 22db859..9a4412c 100644 --- a/docker_templates/packages.py +++ b/docker_templates/packages.py @@ -18,11 +18,11 @@ # TODO: think of a better version pattern like # r'\d(?!Version\:\s)(.+)(?=(~\w+\n))' but works without a trailing ~ -version_pattern = r'(?<= )\d+\.\d+\.\d+\-\d+' +version_pattern = r'(?<=Version: )\d+\.\d+\.\d+\-\d+' packagePatternTemplateLookup = { 'gazebo_packages': string.Template(r'(\bPackage: gazebo$gazebo_version\n)(.*\n)'), - 'ros_packages': string.Template(r'(\bPackage: ros-$rosdistro_name-$package\n)(.*\n)'), + 'ros_packages': string.Template(r'(\bPackage: ros-$rosdistro_name-$package\n)(.*?(?:\r*\n{2}))'), 'ros2_packages': string.Template(r'(\bPackage: ros-$ros2distro_name-$package\n)(.*\n)'), } @@ -58,7 +58,7 @@ def getPackagePattern(data, package_pattern_template, package): """Get package pattern""" package_pattern_raw = package_pattern_template.substitute(data,package=package) - package_pattern = re.compile(package_pattern_raw) + package_pattern = re.compile(package_pattern_raw, re.DOTALL) return package_pattern @@ -67,8 +67,8 @@ def getPackageVersion(data, package_pattern, package, package_index): # Parse for version_number matchs = re.search(package_pattern, package_index) - version_line = matchs.groups(0)[1] # Grab the second line of the first match - package_version = re.search(version_pattern, version_line).group(0) # extract version_number + package_info = matchs.group(0) + package_version = re.search(version_pattern, package_info).group(0) # extract version_number return package_version From 98b15d8cce407e50f4353398eecf32139c71d01b Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Wed, 17 Jul 2019 02:48:42 +0200 Subject: [PATCH 2/2] update gazebo and ros2 regexes accordingly Signed-off-by: Mikael Arguedas --- docker_templates/packages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker_templates/packages.py b/docker_templates/packages.py index 9a4412c..f17d5a4 100644 --- a/docker_templates/packages.py +++ b/docker_templates/packages.py @@ -21,9 +21,9 @@ version_pattern = r'(?<=Version: )\d+\.\d+\.\d+\-\d+' packagePatternTemplateLookup = { - 'gazebo_packages': string.Template(r'(\bPackage: gazebo$gazebo_version\n)(.*\n)'), + 'gazebo_packages': string.Template(r'(\bPackage: gazebo$gazebo_version\n)(.*?(?:\r*\n{2}))'), 'ros_packages': string.Template(r'(\bPackage: ros-$rosdistro_name-$package\n)(.*?(?:\r*\n{2}))'), - 'ros2_packages': string.Template(r'(\bPackage: ros-$ros2distro_name-$package\n)(.*\n)'), + 'ros2_packages': string.Template(r'(\bPackage: ros-$ros2distro_name-$package\n)(.*?(?:\r*\n{2}))'), } indexUrlTemplateLookup = {