Skip to content

Commit

Permalink
use regex for base version split
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Feb 8, 2024
1 parent b7f54d8 commit e491eb2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/lookup_extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re

import asdf

Expand All @@ -24,11 +25,13 @@ def error(**kwargs):


def split_uri_base_and_version(uri):
parts = asdf.util._patched_urllib_parse.urlparse(uri)
basename = os.path.basename(parts.path)
if "-" in basename:
version = basename.split("-", maxsplit=1)[1]
base = uri.rstrip(f"-{version}")
# parts = asdf.util._patched_urllib_parse.urlparse(uri)
# basename = os.path.basename(parts.path)
m = re.match(r"^(?P<base>.*)-(?P<version>([0-9]+\.?){1,3}(-.*)?)$", uri)
if m:
version = m["version"]
base = m["base"]
assert "-".join((base, version)) == uri
else:
version = ""
base = uri
Expand Down

0 comments on commit e491eb2

Please sign in to comment.