From f1602666996d9aa051bec3fe85855963928065d6 Mon Sep 17 00:00:00 2001
From: Haibo Huang <hhb@google.com>
Date: Thu, 28 Feb 2019 16:23:55 -0800
Subject: [PATCH] Support version splitter other than dot

Test: check updater for libmtp
Change-Id: Id6c54dd95d698ca5b0f206a35e6ce823a82beb32
---
 updater_utils.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/updater_utils.py b/updater_utils.py
index 54ddf98..a08846c 100644
--- a/updater_utils.py
+++ b/updater_utils.py
@@ -57,11 +57,12 @@ def replace_package(source_dir, target_dir):
         'update_package.sh')
     subprocess.check_call(['bash', script_path, source_dir, target_dir])
 
-
+VERSION_SPLITTER_PATTERN = r'[\.\-_]'
 VERSION_PATTERN = (r'^(?P<prefix>[^\d]*)' +
-                   r'(?P<version>\d+(\.\d+)*)' +
+                   r'(?P<version>\d+(' + VERSION_SPLITTER_PATTERN + r'\d+)*)' +
                    r'(?P<suffix>.*)$')
 VERSION_RE = re.compile(VERSION_PATTERN)
+VERSION_SPLITTER_RE = re.compile(VERSION_SPLITTER_PATTERN)
 
 
 def _parse_version(version):
@@ -82,7 +83,7 @@ def _match_and_get_version(prefix, suffix, version):
 
     right_format = (version_prefix == prefix and version_suffix == suffix)
 
-    return [right_format] + [int(v) for v in version.split('.')]
+    return [right_format] + [int(v) for v in VERSION_SPLITTER_RE.split(version)]
 
 
 def get_latest_version(current_version, version_list):
-- 
GitLab