|
3 | 3 |
|
4 | 4 | import globus_sdk |
5 | 5 | import mdf_toolbox |
| 6 | +from nameparser import HumanName |
6 | 7 | import requests |
7 | 8 |
|
8 | 9 |
|
@@ -106,13 +107,8 @@ def create_dc_block(self, title, authors, |
106 | 107 |
|
107 | 108 | Arguments: |
108 | 109 | title (str or list of str): The title(s) of the dataset. |
109 | | - authors (str or list of str): The author(s) of the dataset. Format must be one of: |
110 | | -
|
111 | | - * ``"Givenname Familyname"`` |
112 | | - * ``"Familyname, Givenname"`` |
113 | | - * ``"Familyname; Givenname"`` |
114 | | -
|
115 | | - No additional commas or semicolons are permitted. |
| 110 | + authors (str or list of str): The author(s) of the dataset. |
| 111 | + The name will be automatically parsed into given name and family name. |
116 | 112 | publisher (str): The publisher of the dataset (not an associated paper). |
117 | 113 | **Default:** The Materials Data Facility. |
118 | 114 | publication_year (int or str): The year of dataset publication. |
@@ -174,25 +170,16 @@ def create_dc_block(self, title, authors, |
174 | 170 | affiliations = [affiliations] * len(authors) |
175 | 171 | creators = [] |
176 | 172 | for auth, affs in zip(authors, affiliations): |
177 | | - if auth.find(",") >= 0: |
178 | | - family, given = auth.split(",", 1) |
179 | | - elif auth.find(";") >= 0: |
180 | | - family, given = auth.split(";", 1) |
181 | | - elif auth.find(" ") >= 0: |
182 | | - given, family = auth.split(" ", 1) |
183 | | - else: |
184 | | - given = auth |
185 | | - family = "" |
186 | | - if not isinstance(affs, list): |
187 | | - affs = [affs] |
188 | | - |
189 | | - family = family.strip() |
190 | | - given = given.strip() |
| 173 | + name = HumanName(auth) |
| 174 | + given = "{} {}".format(name.first, name.middle).strip() |
| 175 | + family = "{} {}".format(name.last, name.suffix).strip() |
191 | 176 | creator = { |
192 | | - "creatorName": "{}, {}".format(family, given), |
| 177 | + "creatorName": "{}, {}".format(family, given).strip(" ,"), |
193 | 178 | "familyName": family, |
194 | 179 | "givenName": given |
195 | 180 | } |
| 181 | + if not isinstance(affs, list): |
| 182 | + affs = [affs] |
196 | 183 | if affs: |
197 | 184 | creator["affiliations"] = affs |
198 | 185 | creators.append(creator) |
|
0 commit comments