Skip to content

Commit ee84478

Browse files
committed
more robust regex substitution
1 parent e5810f0 commit ee84478

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/update_ios_android_dependencies.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def modify_pod_file(pod_file, pod_version_map, dryrun=True):
290290

291291

292292
RE_README_POD_VERSION = re.compile(
293-
r"<br>Firebase/(?P<product_pod_name>\w+) Cocoapod \((?P<version>([0-9.]+))\)")
293+
r"| (?P<pod_name>.*) Cocoapod \((?P<version>([0-9.]+))\)")
294294

295295
def modify_readme_file_pods(readme_filepath, version_map, dryrun=True):
296296
"""Modify a readme Markdown file to reference correct cocoapods versions.
@@ -318,12 +318,12 @@ def modify_readme_file_pods(readme_filepath, version_map, dryrun=True):
318318

319319
# Replacement function, look up the version number of the given pkg.
320320
def replace_pod_line(m):
321-
if not m.group('product_pod_name'):
321+
if not m.group('pod_name'):
322322
return m.group(0)
323-
pod_key = 'Firebase' + m.group('product_pod_name')
323+
pod_key = m.group('pod_name').replace('/', '')
324324
if pod_key not in version_map:
325325
return m.group(0)
326-
repl = '<br>Firebase/%s Cocoapod (%s)' % (m.group('product_pod_name'),
326+
repl = '| %s Cocoapod (%s)' % (m.group('product_pod_name'),
327327
version_map[pod_key])
328328
return repl
329329

@@ -438,7 +438,7 @@ def replace_dependency(m):
438438

439439

440440
RE_README_ANDROID_VERSION = re.compile(
441-
r"<br>(?P<pkg>[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+):([0-9.]+)")
441+
r"| (?P<pkg>[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+):([0-9.]+)")
442442

443443

444444
def modify_readme_file_android(readme_filepath, version_map, dryrun=True):
@@ -473,7 +473,7 @@ def replace_module_line(m):
473473
pkg = m.group('pkg').replace('-', '_').replace(':', '.')
474474
if pkg not in version_map:
475475
return m.group(0)
476-
repl = '<br>%s:%s' % (m.group('pkg'), version_map[pkg])
476+
repl = '| %s:%s ' % (m.group('pkg'), version_map[pkg])
477477
return repl
478478

479479
substituted_pairs = []

0 commit comments

Comments
 (0)