add support for Figshare versions > 9
MODIFY
repo2docker/contentproviders/figshare.py
repo2docker/contentproviders/figshare.py
@@ -39,7 +39,7 @@ class Figshare(DoiProvider):
}
]
- url_regex = re.compile(r"(.*)/articles/([^/]+)/(\d+)(/)?(\d)?")
+ url_regex = re.compile(r"(.*)/articles/([^/]+)/(\d+)(/)?(\d+)?")
def detect(self, doi, ref=None, extra_args=None):
"""Trigger this provider for things that resolve to a Figshare article"""

MODIFY
tests/unit/contentproviders/test_figshare.py
tests/unit/contentproviders/test_figshare.py
@@ -21,6 +21,17 @@ def test_content_id():
fig.detect("10.6084/m9.figshare.9782777")
assert fig.content_id == "9782777"
+ fig.detect("10.6084/m9.figshare.9782777.v123")
+ assert fig.content_id == "9782777"
+
+
+def test_content_version():
+ with patch.object(Figshare, "urlopen") as fake_urlopen:
+ fake_urlopen.return_value.url = "https://figshare.com/articles/title/9782777/2"
+ fig = Figshare()
+ fig.detect("10.6084/m9.figshare.9782777.v2")
+ assert fig.content_version == "2"
+
test_fig = Figshare()
test_fig.article_id = "123456"

add support for Figshare versions > 9