-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be smarter in detecting version #295
Comments
Thanks @peterdesmet for the suggestion. What do you think about these regex rules? Notice however that library(stringr)
pattern <- "\\d+(\\.\\d+){0,2}"
pattern_improved <- "\\d+(\\.\\d+){1,2}"
profile1 <- "a/b/c/10.12.5/camera/etc/camtrap-dp-profile.json"
version1 <- stringr::str_extract(profile1, pattern)
version1_improved <- stringr::str_extract(profile1, pattern_improved)
version1
#> [1] "10.12.5"
version1_improved
#> [1] "10.12.5"
profile2 <- "a/b/c/d1.0d/cam/camtrap-dp-profile.json"
version2 <- str_extract(profile2, pattern)
version2_improved <- stringr::str_extract(profile2, pattern_improved)
version2
#> [1] "1.0"
version2_improved
#> [1] "1.0"
profile3 <- "a/b/c/d1d/cam/v2/camtrap-dp-profile.json"
version3 <- str_extract(profile3, pattern)
version3_improved <- stringr::str_extract(profile3, pattern_improved)
version3
#> [1] "1"
version3_improved
#> [1] NA
profile4 <- "a/b/c/d1d/cam/3.0.5/camtrap-dp-profile.json"
version4 <- str_extract(profile4, pattern)
version4_improved <- stringr::str_extract(profile4, pattern_improved)
version4
#> [1] "1"
version4_improved
#> [1] "3.0.5" Created on 2024-01-15 with reprex v2.0.2 |
Nice, I would go for the improved version. It is a likely expectation that the Camtrap DP version number will always contain a dot. |
read_camtrap_dp()
currently detects the version on literal strings comparison inpackage$profile
:camtraptor/R/read_camtrap_dp.R
Lines 85 to 95 in 4b2f513
Packages published through GBIF however, won't have the profile:
But:
As a result,
read_camtrap_dp()
says their version is not supported.I think the profile code should check:
Does
profile
containcamtrap-dp-profile.json
?-> No: pass entire
profile
asversion
(will error)-> Yes: continue
Does
profile
contain regex for digits separated by dot (max 3 iterations)?-> No: pass entire
profile
asversion
(will error)-> Yes: pass extracted regex to supported versions (might error)
The text was updated successfully, but these errors were encountered: