Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Replace distutils.version.LooseVersion with packaging.version.Version
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Oct 25, 2021
1 parent 04aab25 commit c1d4ced
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dandi/pynwb_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import Counter
from distutils.version import LooseVersion
import os
import os.path as op
import re
Expand All @@ -10,6 +9,7 @@
import h5py
import hdmf
import numpy as np
from packaging.version import Version
import pynwb
from pynwb import NWBHDF5IO
import semantic_version
Expand Down Expand Up @@ -73,7 +73,7 @@ def log(v): # does nothing
log(f"{msg} is not text which follows semver specification")

if isinstance(v, str) and not semantic_version.validate(v):
msgtype = "error" if LooseVersion(v) >= "2.1.0" else "warning"
msgtype = "error" if Version(v) >= Version("2.1.0") else "warning"
log(f"{msgtype}: {msg} is not a proper semantic version. See http://semver.org")

return v
Expand Down Expand Up @@ -276,8 +276,11 @@ def validate(path, devel_debug=False):
# Explicitly sanitize so we collect warnings.
# TODO: later cast into proper ERRORs
version = _sanitize_nwb_version(version, log=errors.append)
loosever = LooseVersion(version)
if loosever and loosever < "2.1.0":
try:
v = Version(version)
except ValueError:
v = None
if v is not None and v < Version("2.1.0"):
errors_ = errors[:]
errors = [e for e in errors if not re_ok_prior_210.search(str(e))]
if errors != errors_:
Expand Down

0 comments on commit c1d4ced

Please sign in to comment.