commonmeta-py 0.52__py3-none-any.whl → 0.53__py3-none-any.whl
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.
- commonmeta/__init__.py +1 -1
- commonmeta/readers/json_feed_reader.py +9 -4
- commonmeta/utils.py +51 -1
- {commonmeta_py-0.52.dist-info → commonmeta_py-0.53.dist-info}/METADATA +1 -1
- {commonmeta_py-0.52.dist-info → commonmeta_py-0.53.dist-info}/RECORD +8 -8
- {commonmeta_py-0.52.dist-info → commonmeta_py-0.53.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.52.dist-info → commonmeta_py-0.53.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.52.dist-info → commonmeta_py-0.53.dist-info}/entry_points.txt +0 -0
commonmeta/__init__.py
CHANGED
@@ -49,7 +49,7 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
|
|
49
49
|
read_options = kwargs or {}
|
50
50
|
url = None
|
51
51
|
if py_.get(meta, "blog.status", None) == "active":
|
52
|
-
|
52
|
+
url = normalize_url(meta.get("url", None))
|
53
53
|
elif py_.get(meta, "blog.status", None) == "archived":
|
54
54
|
url = normalize_url(meta.get("archive_url", None))
|
55
55
|
_id = normalize_doi(read_options.get("doi", None) or meta.get("doi", None)) or url
|
@@ -189,9 +189,14 @@ def get_references(references: list) -> list:
|
|
189
189
|
)
|
190
190
|
|
191
191
|
else:
|
192
|
-
|
193
|
-
|
194
|
-
|
192
|
+
id_ = normalize_url(reference.get("id", None))
|
193
|
+
if id_ is None:
|
194
|
+
return None
|
195
|
+
return compact(
|
196
|
+
{
|
197
|
+
"id": id_,
|
198
|
+
}
|
199
|
+
)
|
195
200
|
|
196
201
|
def number_reference(reference: dict, index: int) -> dict:
|
197
202
|
"""number reference"""
|
commonmeta/utils.py
CHANGED
@@ -183,12 +183,18 @@ def normalize_ids(ids: list, relation_type=None) -> list:
|
|
183
183
|
return [format_id(i) for i in ids]
|
184
184
|
|
185
185
|
|
186
|
-
def normalize_url(
|
186
|
+
def normalize_url(
|
187
|
+
url: Optional[str], secure=False, fragments=False, lower=False
|
188
|
+
) -> Optional[str]:
|
187
189
|
"""Normalize URL"""
|
188
190
|
if url is None or not isinstance(url, str):
|
189
191
|
return None
|
192
|
+
url = url.strip()
|
190
193
|
if url.endswith("/"):
|
191
194
|
url = url.strip("/")
|
195
|
+
scheme = urlparse(url).scheme
|
196
|
+
if not scheme or scheme not in ["http", "https"]:
|
197
|
+
return None
|
192
198
|
if secure is True and url.startswith(HTTP_SCHEME):
|
193
199
|
url = url.replace(HTTP_SCHEME, HTTPS_SCHEME)
|
194
200
|
if lower is True:
|
@@ -196,6 +202,50 @@ def normalize_url(url: Optional[str], secure=False, lower=False) -> Optional[str
|
|
196
202
|
return url
|
197
203
|
|
198
204
|
|
205
|
+
# def normalize_url(url: Optional[str], secure=False, fragments=False, lower=False) -> Optional[str]:
|
206
|
+
# """Normalize URL"""
|
207
|
+
# if url is None or not isinstance(url, str):
|
208
|
+
# return None
|
209
|
+
# try:
|
210
|
+
# f = furl(url.strip())
|
211
|
+
# f.path.normalize()
|
212
|
+
|
213
|
+
# # only allow http and https schemes
|
214
|
+
# if f.scheme not in ["http", "https"]:
|
215
|
+
# return None
|
216
|
+
# if secure and f.scheme == "http":
|
217
|
+
# f.set(scheme="https")
|
218
|
+
|
219
|
+
# # remove index.html
|
220
|
+
# if f.path.segments and f.path.segments[-1] in ["index.html"]:
|
221
|
+
# f.path.segments.pop(-1)
|
222
|
+
|
223
|
+
# # remove fragments
|
224
|
+
# if fragments:
|
225
|
+
# f.remove(fragment=True)
|
226
|
+
|
227
|
+
# # remove specific query parameters
|
228
|
+
# f.remove(
|
229
|
+
# [
|
230
|
+
# "origin",
|
231
|
+
# "ref",
|
232
|
+
# "referrer",
|
233
|
+
# "source",
|
234
|
+
# "utm_content",
|
235
|
+
# "utm_medium",
|
236
|
+
# "utm_campaign",
|
237
|
+
# "utm_source",
|
238
|
+
# ]
|
239
|
+
# )
|
240
|
+
|
241
|
+
# if lower:
|
242
|
+
# return f.url.lower().strip("/")
|
243
|
+
# return f.url.strip("/")
|
244
|
+
# except ValueError:
|
245
|
+
# print(f"Error normalizing url {url}")
|
246
|
+
# return None
|
247
|
+
|
248
|
+
|
199
249
|
def normalize_cc_url(url: Optional[str]):
|
200
250
|
"""Normalize Creative Commons URL"""
|
201
251
|
if url is None or not isinstance(url, str):
|
@@ -1,4 +1,4 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=CWAn2ZHrz-0zqFcWvaWudK9dRbHt1qX2DmYjRalD4_0,1779
|
2
2
|
commonmeta/api_utils.py,sha256=-ZHGVZZhJqnjnsLtp4-PoeHYbDqL0cQme7W70BEjo4U,2677
|
3
3
|
commonmeta/author_utils.py,sha256=zBIPTgP5n7Zx57xomJ2h7x0dvC0AV8gJ2gPoYeDy5Lo,8348
|
4
4
|
commonmeta/base_utils.py,sha256=AsUElA5kT2fw_Osy7Uaj2F6MKeq9yB7d5f2V-h2lh7c,3750
|
@@ -19,7 +19,7 @@ commonmeta/readers/csl_reader.py,sha256=5V_sHSJwcAWJmhB8SYk199nB96BWYX1Sq9vkQ3iE
|
|
19
19
|
commonmeta/readers/datacite_reader.py,sha256=CdOtxhthrakBoQMsLTdPx6sUCmqtEWo5ICYE6ZsWDdo,12026
|
20
20
|
commonmeta/readers/datacite_xml_reader.py,sha256=nhnO92fZihr1HZlbXjyem-HJXc9_DWLgJ2zeltuPMIg,13041
|
21
21
|
commonmeta/readers/inveniordm_reader.py,sha256=jzv0rXzT8OCdPD_MShBXTnlwD-F9tpTX7OKZGn8smzs,7480
|
22
|
-
commonmeta/readers/json_feed_reader.py,sha256=
|
22
|
+
commonmeta/readers/json_feed_reader.py,sha256=uJrFTbHEfjTcydnR9U0ce81IF0X94xti72DiQVcR_A8,13731
|
23
23
|
commonmeta/readers/kbase_reader.py,sha256=ehKXQsJyPCtaq2FmBxNb2Jb5Nktpx8pNscpmEM6N0A4,6763
|
24
24
|
commonmeta/readers/ris_reader.py,sha256=v6qOd-i2OcMTEFy5RGd3MlYthJcYSU6yzmZ5yHDzmII,3677
|
25
25
|
commonmeta/readers/schema_org_reader.py,sha256=xyWzO2XAWlI2pYVl2EbVRsUmfiWXEwP64CHRBQNRN-M,16835
|
@@ -58,7 +58,7 @@ commonmeta/resources/styles/modern-language-association.csl,sha256=HI2iU4krze1aH
|
|
58
58
|
commonmeta/resources/styles/vancouver.csl,sha256=lun3_i2oTilgsANk4LjFao2UDPQlGj_hgFgKAWC_DF8,12878
|
59
59
|
commonmeta/schema_utils.py,sha256=gg3l1jd_lFtRkQlO1DYGMVbC10nEmVTN4AWacxC4AAE,915
|
60
60
|
commonmeta/translators.py,sha256=RpGJtKNLjmz41VREZDY7KyyE2eXOi8j7m-da4jHmknI,1362
|
61
|
-
commonmeta/utils.py,sha256=
|
61
|
+
commonmeta/utils.py,sha256=MkcI2v9hr_tJuSHzopOHbPZXkmmvL3ooQvt2RUq5c_M,43992
|
62
62
|
commonmeta/writers/__init__.py,sha256=47-snms6xBHkoEXKYV1DBtH1npAtlVtvY29Z4Zr45qI,45
|
63
63
|
commonmeta/writers/bibtex_writer.py,sha256=s3hIJIgWvSG7TAriZMRQEAyuitw6ebwWSI1YcYFQ-do,4971
|
64
64
|
commonmeta/writers/citation_writer.py,sha256=RjaNh9EALxq6gfODLRWVJxGxPArGd6ZiHUlkYnCT6MA,2355
|
@@ -69,8 +69,8 @@ commonmeta/writers/datacite_writer.py,sha256=G7Lr0aZ4sAEdbfXe3dG4Y6AyGUKA9UWr_ii
|
|
69
69
|
commonmeta/writers/inveniordm_writer.py,sha256=UMFjUC_uvF8Bkm-Le5mR_nDolagqr9M6XTUH-x2sxYc,9994
|
70
70
|
commonmeta/writers/ris_writer.py,sha256=AcnCszS3WY9lF594NbFBtLylsA8ownnYp_XLQJ84Ios,2093
|
71
71
|
commonmeta/writers/schema_org_writer.py,sha256=5j002uCNLdlScZMNQmPjodcVWqaBh2z38zL1H4lo2hY,5741
|
72
|
-
commonmeta_py-0.
|
73
|
-
commonmeta_py-0.
|
74
|
-
commonmeta_py-0.
|
75
|
-
commonmeta_py-0.
|
76
|
-
commonmeta_py-0.
|
72
|
+
commonmeta_py-0.53.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
73
|
+
commonmeta_py-0.53.dist-info/METADATA,sha256=6HFvBtd6ddlGtLNAGf8aB1FCDNbmS_TPy66qNbbYYjk,8282
|
74
|
+
commonmeta_py-0.53.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
75
|
+
commonmeta_py-0.53.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
76
|
+
commonmeta_py-0.53.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|