Skip to content

Commit

Permalink
avoid the use of f-strings for compatibility with python <3.6
Browse files Browse the repository at this point in the history
in code called from outside of the container
Fixes: #353
  • Loading branch information
denisri committed Dec 13, 2023
1 parent 5c0538f commit c819f78
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python/casa_distro/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,21 @@ def updated_image(image):
if osp.exists(image) and osp.exists(image + '.json'):
return image
ext = image.rsplit('.', 1)[-1]
if re.match(f'.*-[0-9]+\\.{ext}$', image):
image_pat = re.sub(f'-[0-9]+\\.{ext}$', f'-*.{ext}', image)
if re.match('.*-[0-9]+\\.{0}$'.format(ext), image):
image_pat = re.sub('-[0-9]+\\.{0}$'.format(ext), '-*.{0}'.format(ext),
image)
else:
image_pat = image[:-len(ext)-1] + '-*.' + ext
if image_pat:
images = glob(image_pat)
if len(images) == 1:
return images[0]
patches = [int(re.match(f'.*-([0-9]+)\\.{ext}$', im).group(1))
patches = [int(re.match('.*-([0-9]+)\\.{0}$'.format(ext), im).group(1))
for im in images]
if patches:
return images[patches.index(max(patches))]
# otherwise, look for image without patch version
image_pat = re.sub(f'-[0-9]+\\.{ext}$', f'.{ext}', image)
image_pat = re.sub('-[0-9]+\\.{}$'.format(ext), '.{0}'.format(ext), image)
if osp.exists(image_pat):
return image_pat
return image # not found
Expand Down

0 comments on commit c819f78

Please sign in to comment.