commonmeta-py 0.73__tar.gz → 0.75__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.
Files changed (76) hide show
  1. {commonmeta_py-0.73 → commonmeta_py-0.75}/PKG-INFO +1 -1
  2. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/__init__.py +1 -1
  3. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/constants.py +12 -5
  4. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/crossref_utils.py +2 -2
  5. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/crossref_reader.py +2 -1
  6. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/crossref_xml_reader.py +3 -0
  7. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/inveniordm_reader.py +3 -0
  8. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/json_feed_reader.py +1 -1
  9. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/schema_org_reader.py +1 -1
  10. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/commonmeta_v0.15.json +1 -0
  11. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/utils.py +24 -4
  12. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/datacite_writer.py +2 -0
  13. {commonmeta_py-0.73 → commonmeta_py-0.75}/pyproject.toml +1 -1
  14. {commonmeta_py-0.73 → commonmeta_py-0.75}/.gitignore +0 -0
  15. {commonmeta_py-0.73 → commonmeta_py-0.75}/LICENSE +0 -0
  16. {commonmeta_py-0.73 → commonmeta_py-0.75}/README.md +0 -0
  17. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/api_utils.py +0 -0
  18. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/author_utils.py +0 -0
  19. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/base_utils.py +0 -0
  20. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/cli.py +0 -0
  21. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/date_utils.py +0 -0
  22. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/doi_utils.py +0 -0
  23. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/metadata.py +0 -0
  24. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/__init__.py +0 -0
  25. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/bibtex_reader.py +0 -0
  26. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/cff_reader.py +0 -0
  27. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/codemeta_reader.py +0 -0
  28. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/commonmeta_reader.py +0 -0
  29. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/csl_reader.py +0 -0
  30. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/datacite_reader.py +0 -0
  31. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/datacite_xml_reader.py +0 -0
  32. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/kbase_reader.py +0 -0
  33. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/readers/ris_reader.py +0 -0
  34. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/cff_v1.2.0.json +0 -0
  35. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/commonmeta_v0.12.json +0 -0
  36. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/commonmeta_v0.13.json +0 -0
  37. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/commonmeta_v0.14.json +0 -0
  38. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/AccessIndicators.xsd +0 -0
  39. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3-elements.xsd +0 -0
  40. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3.xsd +0 -0
  41. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/JATS-journalpublishing1-elements.xsd +0 -0
  42. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3-elements.xsd +0 -0
  43. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3.xsd +0 -0
  44. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/JATS-journalpublishing1.xsd +0 -0
  45. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/clinicaltrials.xsd +0 -0
  46. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/common5.3.1.xsd +0 -0
  47. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/crossref5.3.1.xsd +0 -0
  48. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/crossref_query_output3.0.xsd +0 -0
  49. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/fundref.xsd +0 -0
  50. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/module-ali.xsd +0 -0
  51. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref/relations.xsd +0 -0
  52. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/crossref-v0.2.json +0 -0
  53. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/csl-data.json +0 -0
  54. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/datacite-v4.5.json +0 -0
  55. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/datacite-v4.5pr.json +0 -0
  56. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/ietf-bcp-47.json +0 -0
  57. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/iso-8601.json +0 -0
  58. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/spdx/licenses.json +0 -0
  59. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/spdx-schema.json +0 -0
  60. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/styles/apa.csl +0 -0
  61. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/styles/chicago-author-date.csl +0 -0
  62. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/styles/harvard-cite-them-right.csl +0 -0
  63. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/styles/ieee.csl +0 -0
  64. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/styles/modern-language-association.csl +0 -0
  65. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/resources/styles/vancouver.csl +0 -0
  66. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/schema_utils.py +0 -0
  67. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/translators.py +0 -0
  68. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/__init__.py +0 -0
  69. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/bibtex_writer.py +0 -0
  70. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/citation_writer.py +0 -0
  71. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/commonmeta_writer.py +0 -0
  72. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/crossref_xml_writer.py +0 -0
  73. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/csl_writer.py +0 -0
  74. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/inveniordm_writer.py +0 -0
  75. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/ris_writer.py +0 -0
  76. {commonmeta_py-0.73 → commonmeta_py-0.75}/commonmeta/writers/schema_org_writer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commonmeta-py
3
- Version: 0.73
3
+ Version: 0.75
4
4
  Summary: Library for conversions to/from the Commonmeta scholarly metadata format
5
5
  Project-URL: Homepage, https://python.commonmeta.org
6
6
  Project-URL: Repository, https://github.com/front-matter/commonmeta-py
@@ -10,7 +10,7 @@ commonmeta-py is a Python library to convert scholarly metadata
10
10
  """
11
11
 
12
12
  __title__ = "commonmeta-py"
13
- __version__ = "0.73"
13
+ __version__ = "0.75"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
@@ -51,6 +51,7 @@ BIB_TO_CM_TRANSLATIONS = {
51
51
 
52
52
  CM_TO_BIB_TRANSLATIONS = {
53
53
  "Article": "article",
54
+ "BlogPost": "article",
54
55
  "Book": "book",
55
56
  "BookChapter": "inbook",
56
57
  "Dissertation": "phdthesis",
@@ -97,7 +98,7 @@ CSL_TO_CM_TRANSLATIONS = {
97
98
  "periodical": "Journal",
98
99
  "personal_communication": "PersonalCommunication",
99
100
  "post": "Post",
100
- "post-weblog": "Article",
101
+ "post-weblog": "BlogPost",
101
102
  "regulation": "LegalDocument",
102
103
  "report": "Report",
103
104
  "review": "Review",
@@ -113,7 +114,7 @@ CSL_TO_CM_TRANSLATIONS = {
113
114
 
114
115
  CM_TO_CSL_TRANSLATIONS = {
115
116
  "Article": "article",
116
- "JournalArticle": "article-journal",
117
+ "BlogPost": "post-weblog",
117
118
  "Book": "book",
118
119
  "BookChapter": "chapter",
119
120
  "Collection": "collection",
@@ -123,6 +124,7 @@ CM_TO_CSL_TRANSLATIONS = {
123
124
  "Event": "event",
124
125
  "Figure": "figure",
125
126
  "Image": "graphic",
127
+ "JournalArticle": "article-journal",
126
128
  "LegalDocument": "legal_case",
127
129
  "Manuscript": "manuscript",
128
130
  "Map": "map",
@@ -176,6 +178,7 @@ CR_TO_CM_TRANSLATIONS = {
176
178
 
177
179
  CM_TO_CR_TRANSLATIONS = {
178
180
  "Article": "PostedContent",
181
+ "BlogPost": "PostedContent",
179
182
  "BookChapter": "BookChapter",
180
183
  "BookSeries": "BookSeries",
181
184
  "Book": "Book",
@@ -200,7 +203,7 @@ CM_TO_CR_TRANSLATIONS = {
200
203
  # source: https://github.com/datacite/schema/blob/master/source/meta/kernel-4/include/datacite-resourceType-v4.xsd
201
204
  DC_TO_CM_TRANSLATIONS = {
202
205
  "Audiovisual": "Audiovisual",
203
- "BlogPosting": "Article",
206
+ "BlogPosting": "BlogPost",
204
207
  "Book": "Book",
205
208
  "BookChapter": "BookChapter",
206
209
  "Collection": "Collection",
@@ -269,6 +272,7 @@ INVENIORDM_TO_CM_TRANSLATIONS = {
269
272
 
270
273
  CM_TO_INVENIORDM_TRANSLATIONS = {
271
274
  "Article": "publication-preprint",
275
+ "BlogPost": "publication-preprint",
272
276
  "Book": "book",
273
277
  "Dataset": "dataset",
274
278
  "Image": "image-other",
@@ -281,6 +285,7 @@ CM_TO_INVENIORDM_TRANSLATIONS = {
281
285
  CM_TO_DC_TRANSLATIONS = {
282
286
  "Article": "Preprint",
283
287
  "Audiovisual": "Audiovisual",
288
+ "BlogPost": "Preprint",
284
289
  "Book": "Book",
285
290
  "BookChapter": "BookChapter",
286
291
  "Collection": "Collection",
@@ -317,7 +322,7 @@ RIS_TO_CM_TRANSLATIONS = {
317
322
  "ANCIENT": "Text",
318
323
  "ART": "Text",
319
324
  "BILL": "Text",
320
- "BLOG": "Text",
325
+ "BLOG": "BlogPost",
321
326
  "BOOK": "Book",
322
327
  "CASE": "Text",
323
328
  "CHAP": "BookChapter",
@@ -370,6 +375,7 @@ RIS_TO_CM_TRANSLATIONS = {
370
375
  CM_TO_RIS_TRANSLATIONS = {
371
376
  "Article": "JOUR",
372
377
  "Audiovisual": "VIDEO",
378
+ "BlogPost": "BLOG",
373
379
  "Book": "BOOK",
374
380
  "BookChapter": "CHAP",
375
381
  "Collection": "CTLG",
@@ -400,7 +406,7 @@ CM_TO_RIS_TRANSLATIONS = {
400
406
 
401
407
  SO_TO_CM_TRANSLATIONS = {
402
408
  "Article": "Article",
403
- "BlogPosting": "Article",
409
+ "BlogPosting": "BlogPost",
404
410
  "Book": "Book",
405
411
  "BookChapter": "BookChapter",
406
412
  "CreativeWork": "Other",
@@ -439,6 +445,7 @@ OG_TO_SO_TRANSLATIONS = {
439
445
  CM_TO_SO_TRANSLATIONS = {
440
446
  "Article": "Article",
441
447
  "Audiovisual": "CreativeWork",
448
+ "BlogPost": "BlogPosting",
442
449
  "Book": "Book",
443
450
  "BookChapter": "BookChapter",
444
451
  "Collection": "CreativeWork",
@@ -36,13 +36,13 @@ def generate_crossref_xml(metadata: Commonmeta) -> Optional[str]:
36
36
 
37
37
  def insert_crossref_work(metadata, xml):
38
38
  """Insert crossref work"""
39
- if metadata.type not in ["JournalArticle", "Article"]:
39
+ if metadata.type not in ["JournalArticle", "Article", "BlogPost"]:
40
40
  return xml
41
41
  if doi_from_url(metadata.id) is None or metadata.url is None:
42
42
  return xml
43
43
  if metadata.type == "JournalArticle":
44
44
  xml = insert_journal(metadata, xml)
45
- elif metadata.type == "Article":
45
+ elif metadata.type in ["Article", "BlogPost"]:
46
46
  xml = insert_posted_content(metadata, xml)
47
47
 
48
48
 
@@ -83,7 +83,8 @@ def read_crossref(data: Optional[dict], **kwargs) -> Commonmeta:
83
83
  url = normalize_url(py_.get(meta, "resource.primary.URL"))
84
84
  titles = get_titles(meta)
85
85
  publisher = compact({"name": meta.get("publisher", None)})
86
-
86
+ if _type == "Article" and py_.get(publisher, "name") == "Front Matter":
87
+ _type = "BlogPost"
87
88
  date = compact(
88
89
  {
89
90
  "published": py_.get(meta, "issued.date-time")
@@ -158,6 +158,9 @@ def read_crossref_xml(data: dict, **kwargs) -> Commonmeta:
158
158
  or py_.get(bibmeta, "doi_data.doi")
159
159
  )
160
160
  _type = CR_TO_CM_TRANSLATIONS.get(resource_type, "Other")
161
+ if _type == "Article" and py_.get(publisher, "name") == "Front Matter":
162
+ _type = "BlogPost"
163
+
161
164
  url = parse_attributes(py_.get(bibmeta, "doi_data.resource"))
162
165
  url = normalize_url(url)
163
166
  titles = crossref_titles(bibmeta)
@@ -57,6 +57,9 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
57
57
  publisher = meta.get("publisher", None) or py_.get(meta, "metadata.publisher")
58
58
  if publisher:
59
59
  publisher = {"name": publisher}
60
+ if _type == "Article" and py_.get(publisher, "name") == "Front Matter":
61
+ _type = "BlogPost"
62
+
60
63
  title = py_.get(meta, "metadata.title")
61
64
  titles = [{"title": sanitize(title)}] if title else None
62
65
  additional_titles = py_.get(meta, "metadata.additional_titles")
@@ -54,7 +54,7 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
54
54
  ):
55
55
  url = normalize_url(meta.get("archive_url", None))
56
56
  _id = normalize_doi(read_options.get("doi", None) or meta.get("doi", None)) or url
57
- _type = "Article"
57
+ _type = "BlogPost"
58
58
 
59
59
  # optionally generate a DOI if missing but a DOI prefix is provided
60
60
  prefix = read_options.get("prefix", None) or py_.get(meta, "blog.prefix", None)
@@ -216,7 +216,7 @@ def read_schema_org(data: Optional[dict], **kwargs) -> Commonmeta:
216
216
  "lastPage": meta.get("pageEnd", None),
217
217
  }
218
218
  )
219
- elif _type == "Article":
219
+ elif _type in ["Article", "BlogPost"]:
220
220
  issn = py_.get(meta, "isPartOf.issn")
221
221
  container_url = py_.get(meta, "publisher.url")
222
222
  container = compact(
@@ -533,6 +533,7 @@
533
533
  "enum": [
534
534
  "Article",
535
535
  "Audiovisual",
536
+ "BlogPost",
536
537
  "BookChapter",
537
538
  "BookPart",
538
539
  "BookSection",
@@ -1116,16 +1116,33 @@ def extract_curie(string: Optional[str]) -> Optional[str]:
1116
1116
  """Extract CURIE"""
1117
1117
  if string is None:
1118
1118
  return None
1119
- match = re.search(r"((?:doi|DOI):\s?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))", string)
1119
+ match = re.search(
1120
+ r"((?:doi|DOI):\s?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))", string
1121
+ )
1120
1122
  if match is None:
1121
1123
  return None
1122
1124
  return doi_as_url(match.group(2))
1123
1125
 
1124
-
1126
+
1127
+ def replace_curie(string: Optional[str]) -> Optional[str]:
1128
+ """Replace CURIE with DOI expressed as URL"""
1129
+ if string is None:
1130
+ return None
1131
+ match = re.sub(
1132
+ r"((?:doi|DOI):\s?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))", r'https://doi.org/\2', string
1133
+ )
1134
+ if match is None:
1135
+ return None
1136
+ return match
1137
+
1138
+
1125
1139
  def extract_url(string: str) -> list:
1126
1140
  """Extract urls from string, including markdown and html."""
1127
1141
 
1128
- match = re.search(r"((?:http|https):\/\/(?:[\w_-]+(?:(?:\.[\w_-]+)+))(?:[\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))", string)
1142
+ match = re.search(
1143
+ r"((?:http|https):\/\/(?:[\w_-]+(?:(?:\.[\w_-]+)+))(?:[\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))",
1144
+ string,
1145
+ )
1129
1146
  if match is None:
1130
1147
  return None
1131
1148
  return normalize_url(match.group(1))
@@ -1134,7 +1151,10 @@ def extract_url(string: str) -> list:
1134
1151
  def extract_urls(string: str) -> list:
1135
1152
  """Extract urls from string, including markdown and html."""
1136
1153
 
1137
- urls = re.findall(r"((?:http|https):\/\/(?:[\w_-]+(?:(?:\.[\w_-]+)+))(?:[\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))", string)
1154
+ urls = re.findall(
1155
+ r"((?:http|https):\/\/(?:[\w_-]+(?:(?:\.[\w_-]+)+))(?:[\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))",
1156
+ string,
1157
+ )
1138
1158
  return py_.uniq(urls)
1139
1159
 
1140
1160
 
@@ -47,6 +47,8 @@ def write_datacite(metadata: Commonmeta) -> Optional[Union[str, dict]]:
47
47
 
48
48
  resource__typegeneral = CM_TO_DC_TRANSLATIONS.get(metadata.type, "Other")
49
49
  resource_type = CM_TO_CR_TRANSLATIONS.get(metadata.type, "Other")
50
+ if metadata.type == "BlogPost":
51
+ resource_type = "BlogPost"
50
52
  if resource__typegeneral == resource_type or resource__typegeneral in [
51
53
  "Dataset",
52
54
  "JournalArticle",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "commonmeta-py"
3
- version = "0.73"
3
+ version = "0.75"
4
4
  description = "Library for conversions to/from the Commonmeta scholarly metadata format"
5
5
  authors = [{ name = "Martin Fenner", email = "martin@front-matter.io" }]
6
6
  requires-python = ">=3.9,<4.0"
File without changes
File without changes
File without changes