commonmeta-py 0.74__py3-none-any.whl → 0.76__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 CHANGED
@@ -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.74"
13
+ __version__ = "0.76"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
@@ -59,6 +59,7 @@ from .utils import (
59
59
  extract_url,
60
60
  extract_urls,
61
61
  extract_curie,
62
+ replace_curie,
62
63
  )
63
64
  from .author_utils import (
64
65
  authors_as_string,
commonmeta/utils.py CHANGED
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commonmeta-py
3
- Version: 0.74
3
+ Version: 0.76
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
@@ -1,4 +1,4 @@
1
- commonmeta/__init__.py,sha256=NJr14BwK23CaaTT8Gdm65_xUY6BXlphGitiMdChRX0k,1875
1
+ commonmeta/__init__.py,sha256=7EHM9Agw6V7u_fjApYJaiXtuMqKmJKvQPrmA-K-OVAE,1894
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
@@ -10,7 +10,7 @@ commonmeta/doi_utils.py,sha256=s2J95V9rWPbGsh5oNXht3yJkJ0NmVLRlOXDPXjnN-Ck,9152
10
10
  commonmeta/metadata.py,sha256=cjvCcxW1FMtKCbNKan0zXX0FN6z5orHFGPYsgkp6fSI,12480
11
11
  commonmeta/schema_utils.py,sha256=gg3l1jd_lFtRkQlO1DYGMVbC10nEmVTN4AWacxC4AAE,915
12
12
  commonmeta/translators.py,sha256=RpGJtKNLjmz41VREZDY7KyyE2eXOi8j7m-da4jHmknI,1362
13
- commonmeta/utils.py,sha256=lIH7VejIn_gReLsuXsAZxE-RiMCRGECA_6aPrhGsBFc,44596
13
+ commonmeta/utils.py,sha256=nWSdkc1jNkhSnv46MKScExOUlD--wMP_QCRpy8Rnq_g,44989
14
14
  commonmeta/readers/__init__.py,sha256=vOf7UsOKNoh_ZCuyexxhAmPMt8wjB-pF_CfpWRaN8pk,45
15
15
  commonmeta/readers/bibtex_reader.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  commonmeta/readers/cff_reader.py,sha256=5HMFUvjE1zb-zfpQSNM8vtB0YunD0reom99hn8N0xKc,6144
@@ -69,8 +69,8 @@ commonmeta/writers/datacite_writer.py,sha256=UpDp4Brg5xrmS5T3QYoNi6PPXKdRxAo254e
69
69
  commonmeta/writers/inveniordm_writer.py,sha256=TctfZsiB8aiXWDLijJpxjMM77aKY6-hgKeAPDMfZoh4,11438
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.74.dist-info/METADATA,sha256=JBv2STCC_kh62r4UVTnTuZwMRXENr2UFlsxNz8RIORE,7731
73
- commonmeta_py-0.74.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
74
- commonmeta_py-0.74.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
75
- commonmeta_py-0.74.dist-info/licenses/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
76
- commonmeta_py-0.74.dist-info/RECORD,,
72
+ commonmeta_py-0.76.dist-info/METADATA,sha256=v1MtR60xaJ7lpgvvgPRV2VFVpeLlHUBIn54U6e7tY-8,7731
73
+ commonmeta_py-0.76.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
74
+ commonmeta_py-0.76.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
75
+ commonmeta_py-0.76.dist-info/licenses/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
76
+ commonmeta_py-0.76.dist-info/RECORD,,