PyLinks 0.0.0.dev76__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pylinks-0.1.1/PKG-INFO +7 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/pyproject.toml +3 -3
- pylinks-0.1.1/src/PyLinks.egg-info/PKG-INFO +7 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/PyLinks.egg-info/SOURCES.txt +6 -0
- pylinks-0.1.1/src/PyLinks.egg-info/requires.txt +3 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/__init__.py +1 -1
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/_settings.py +2 -4
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/api/__init__.py +2 -2
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/api/doi.py +28 -25
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/api/github.py +377 -185
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/api/orcid.py +8 -5
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/api/zenodo.py +17 -20
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/exception/api.py +27 -30
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/exception/base.py +17 -11
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/exception/media_type.py +6 -6
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/exception/uri.py +3 -3
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/http.py +78 -59
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/media_type.py +14 -7
- pylinks-0.1.1/src/pylinks/site/__init__.py +1 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/site/binder.py +0 -2
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/site/conda.py +28 -12
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/site/github.py +52 -32
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/site/lib_io.py +14 -7
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/site/pypi.py +18 -9
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/site/readthedocs.py +8 -7
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/string.py +12 -13
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/uri/data.py +12 -11
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/url.py +47 -29
- pylinks-0.0.0.dev76/PKG-INFO +0 -7
- pylinks-0.0.0.dev76/src/PyLinks.egg-info/PKG-INFO +0 -7
- pylinks-0.0.0.dev76/src/PyLinks.egg-info/requires.txt +0 -3
- pylinks-0.0.0.dev76/src/pylinks/site/__init__.py +0 -1
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/setup.cfg +0 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/PyLinks.egg-info/dependency_links.txt +0 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/PyLinks.egg-info/not-zip-safe +0 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/PyLinks.egg-info/top_level.txt +0 -0
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/exception/__init__.py +1 -1
- {pylinks-0.0.0.dev76 → pylinks-0.1.1}/src/pylinks/uri/__init__.py +0 -0
pylinks-0.1.1/PKG-INFO
ADDED
|
@@ -17,11 +17,11 @@ namespaces = true
|
|
|
17
17
|
# ----------------------------------------- Project Metadata -------------------------------------
|
|
18
18
|
#
|
|
19
19
|
[project]
|
|
20
|
-
version = "0.
|
|
20
|
+
version = "0.1.1"
|
|
21
21
|
name = "PyLinks"
|
|
22
22
|
dependencies = [
|
|
23
23
|
"requests >= 2.31.0, < 3",
|
|
24
|
-
"ExceptionMan
|
|
25
|
-
"MDit
|
|
24
|
+
"ExceptionMan >=0.1,<0.2",
|
|
25
|
+
"MDit >=0.1,<0.2",
|
|
26
26
|
]
|
|
27
27
|
requires-python = ">=3.10"
|
|
@@ -11,6 +11,12 @@ src/pylinks/http.py
|
|
|
11
11
|
src/pylinks/media_type.py
|
|
12
12
|
src/pylinks/string.py
|
|
13
13
|
src/pylinks/url.py
|
|
14
|
+
src/pylinks.egg-info/PKG-INFO
|
|
15
|
+
src/pylinks.egg-info/SOURCES.txt
|
|
16
|
+
src/pylinks.egg-info/dependency_links.txt
|
|
17
|
+
src/pylinks.egg-info/not-zip-safe
|
|
18
|
+
src/pylinks.egg-info/requires.txt
|
|
19
|
+
src/pylinks.egg-info/top_level.txt
|
|
14
20
|
src/pylinks/api/__init__.py
|
|
15
21
|
src/pylinks/api/doi.py
|
|
16
22
|
src/pylinks/api/github.py
|
|
@@ -11,5 +11,5 @@ but can be used directly from the root. It returns a URL object, also defined in
|
|
|
11
11
|
Other available modules offer shortcuts for creating useful URLs for popular online services.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
+
from pylinks import api, http, media_type, site, string, uri, url
|
|
14
15
|
from pylinks._settings import settings
|
|
15
|
-
from pylinks import url, http, api, site, uri, media_type, string
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
class Settings:
|
|
2
|
-
def __init__(self):
|
|
2
|
+
def __init__(self) -> None:
|
|
3
3
|
self._offline_mode = False
|
|
4
|
-
return
|
|
5
4
|
|
|
6
5
|
@property
|
|
7
6
|
def offline_mode(self) -> bool:
|
|
8
7
|
return self._offline_mode
|
|
9
8
|
|
|
10
9
|
@offline_mode.setter
|
|
11
|
-
def offline_mode(self, value: bool):
|
|
10
|
+
def offline_mode(self, value: bool) -> None:
|
|
12
11
|
self._offline_mode = bool(value)
|
|
13
|
-
return
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
settings = Settings()
|
|
@@ -10,7 +10,7 @@ def doi(doi: str) -> DOI:
|
|
|
10
10
|
return DOI(doi=doi)
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
def github(token:
|
|
13
|
+
def github(token: str | None = None, timezone: str | None = "UTC") -> GitHub:
|
|
14
14
|
return GitHub(token=token, timezone=timezone)
|
|
15
15
|
|
|
16
16
|
|
|
@@ -19,4 +19,4 @@ def orcid(orcid_id: str) -> Orcid:
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def zenodo(token: str, sandbox: bool = False) -> Zenodo:
|
|
22
|
-
return Zenodo(token=token, sandbox=sandbox)
|
|
22
|
+
return Zenodo(token=token, sandbox=sandbox)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Standard libraries
|
|
2
|
+
import datetime
|
|
2
3
|
import re
|
|
3
4
|
import unicodedata
|
|
4
|
-
import datetime
|
|
5
|
-
from typing import Optional
|
|
6
5
|
|
|
7
6
|
# Non-standard libraries
|
|
8
7
|
import pylinks as _pylinks
|
|
@@ -18,7 +17,7 @@ class DOI:
|
|
|
18
17
|
https://support.datacite.org/docs/doi-basics
|
|
19
18
|
"""
|
|
20
19
|
|
|
21
|
-
def __init__(self, doi: str):
|
|
20
|
+
def __init__(self, doi: str) -> None:
|
|
22
21
|
"""
|
|
23
22
|
Parameters
|
|
24
23
|
----------
|
|
@@ -33,12 +32,12 @@ class DOI:
|
|
|
33
32
|
"""
|
|
34
33
|
match = re.match(r"(?:https?://)?(?:dx\.)?(?:doi\.org/)?(10\.\d+/\S+)", doi)
|
|
35
34
|
if not match:
|
|
36
|
-
|
|
35
|
+
msg = f"Invalid DOI: {doi}"
|
|
36
|
+
raise ValueError(msg)
|
|
37
37
|
self.doi = match.group(1)
|
|
38
38
|
self.url = f"https://doi.org/{self.doi}" # See also: https://api.crossref.org/works/{doi}
|
|
39
|
-
return
|
|
40
39
|
|
|
41
|
-
def text(self, style:
|
|
40
|
+
def text(self, style: str | None = None, locale: str | None = None) -> str:
|
|
42
41
|
"""
|
|
43
42
|
Formatted text citation for the DOI, with an optional citation style and locale.
|
|
44
43
|
|
|
@@ -59,7 +58,10 @@ class DOI:
|
|
|
59
58
|
if locale:
|
|
60
59
|
accept += f"; locale={locale}"
|
|
61
60
|
return _pylinks.http.request(
|
|
62
|
-
self.url,
|
|
61
|
+
self.url,
|
|
62
|
+
headers={"accept": accept},
|
|
63
|
+
encoding="utf-8",
|
|
64
|
+
response_type="str",
|
|
63
65
|
)
|
|
64
66
|
|
|
65
67
|
@property
|
|
@@ -82,9 +84,7 @@ class DOI:
|
|
|
82
84
|
|
|
83
85
|
@property
|
|
84
86
|
def citeproc_dict(self) -> dict:
|
|
85
|
-
"""
|
|
86
|
-
Citation data as a dictionary with Citeproc JSON schema.
|
|
87
|
-
"""
|
|
87
|
+
"""Citation data as a dictionary with Citeproc JSON schema."""
|
|
88
88
|
return _pylinks.http.request(
|
|
89
89
|
self.url,
|
|
90
90
|
headers={"accept": "application/citeproc+json"},
|
|
@@ -98,15 +98,17 @@ class DOI:
|
|
|
98
98
|
journal = data["container-title"] or None
|
|
99
99
|
journal_abbr = (
|
|
100
100
|
(
|
|
101
|
-
data.get("container-title-short")
|
|
102
|
-
|
|
101
|
+
data.get("container-title-short")
|
|
102
|
+
or _pylinks.http.request(
|
|
103
|
+
f"https://abbreviso.toolforge.org/abbreviso/a/{journal}",
|
|
103
104
|
response_type="str",
|
|
104
105
|
).title()
|
|
105
106
|
)
|
|
106
|
-
if journal
|
|
107
|
+
if journal
|
|
108
|
+
else None
|
|
107
109
|
)
|
|
108
110
|
date = self._get_date(data)
|
|
109
|
-
|
|
111
|
+
return {
|
|
110
112
|
"doi": self.doi,
|
|
111
113
|
"url": f"https://doi.org/{self.doi}",
|
|
112
114
|
"type": data["type"], # e.g. 'journal-article', 'posted-content'
|
|
@@ -125,9 +127,10 @@ class DOI:
|
|
|
125
127
|
"date_tuple": date, # tuple of (year, month, day)
|
|
126
128
|
"year": date[0],
|
|
127
129
|
"date": datetime.date(*date).strftime("%e %B %Y").lstrip(),
|
|
128
|
-
"abstract": self.jats_to_html(data["abstract"])
|
|
130
|
+
"abstract": self.jats_to_html(data["abstract"])
|
|
131
|
+
if data.get("abstract")
|
|
132
|
+
else None,
|
|
129
133
|
}
|
|
130
|
-
return curated
|
|
131
134
|
|
|
132
135
|
@staticmethod
|
|
133
136
|
def jats_to_html(string):
|
|
@@ -147,18 +150,18 @@ class DOI:
|
|
|
147
150
|
month = None
|
|
148
151
|
day = None
|
|
149
152
|
for choice in (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
"pubished",
|
|
154
|
+
"published-online",
|
|
155
|
+
"published-print",
|
|
156
|
+
"published-other",
|
|
157
|
+
"issued",
|
|
158
|
+
"created",
|
|
159
|
+
"deposited",
|
|
160
|
+
"indexed",
|
|
158
161
|
):
|
|
159
162
|
if year and month and day:
|
|
160
163
|
break
|
|
161
|
-
date = data.get(choice,
|
|
164
|
+
date = data.get(choice, {}).get("date-parts", [None])[0]
|
|
162
165
|
if date:
|
|
163
166
|
year = year or date[0]
|
|
164
167
|
if not month:
|