Skip to content

Commit

Permalink
Merge pull request #66 from osrf/support-snapshots
Browse files Browse the repository at this point in the history
Fixup regexes for version extraction
  • Loading branch information
mikaelarguedas authored Jul 17, 2019
2 parents b602d61 + 98b15d8 commit 8ce46b4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docker_templates/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

# 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)'),
'ros2_packages': string.Template(r'(\bPackage: ros-$ros2distro_name-$package\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)(.*?(?:\r*\n{2}))'),
}

indexUrlTemplateLookup = {
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 8ce46b4

Please sign in to comment.