Skip to content

Commit 9d6745f

Browse files
authored
Merge pull request #17 from materials-data-facility/mdfcc-dev
0.3.2
2 parents 344fddb + 5d71a37 commit 9d6745f

4 files changed

Lines changed: 23 additions & 33 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# MDF Connect Client
2+
[![PyPI](https://img.shields.io/pypi/v/mdf_connect_client.svg)](https://pypi.python.org/pypi/mdf-connect-client) [![Build Status](https://travis-ci.org/materials-data-facility/connect_client.svg?branch=master)](https://travis-ci.org/materials-data-facility/connect_client) [![Coverage Status](https://coveralls.io/repos/github/materials-data-facility/connect_client/badge.svg?branch=master)](https://coveralls.io/github/materials-data-facility/connect_client?branch=master) [![Read the Docs](https://readthedocs.org/projects/mdf-connect-client/badge/?version=master)](http://mdf-connect-client.readthedocs.io/en/master/)
3+
24
The MDF Connect Client is the Python client to easily submit datasets to MDF Connect.
35

46
# Installation
@@ -19,7 +21,7 @@ Documentation is available on [Read the Docs](https://mdf-connect-client.readthe
1921

2022

2123
# Requirements
22-
* The Connect Client requires Python 3.4 or greater.
24+
* The Connect Client requires Python 3.5 or greater.
2325
* To submit data to MDF Connect, you must have an account recognized by Globus Auth (including Google, ORCiD, many academic institutions, or a [free Globus ID](https://www.globusid.org/create)), and be a member of the [MDF Connect Convert Globus Group](https://app.globus.org/groups/cc192dca-3751-11e8-90c1-0a7c735d220a).
2426

2527

mdf_connect_client/mdfcc.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import globus_sdk
55
import mdf_toolbox
6+
from nameparser import HumanName
67
import requests
78

89

@@ -106,13 +107,8 @@ def create_dc_block(self, title, authors,
106107
107108
Arguments:
108109
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.
116112
publisher (str): The publisher of the dataset (not an associated paper).
117113
**Default:** The Materials Data Facility.
118114
publication_year (int or str): The year of dataset publication.
@@ -174,25 +170,16 @@ def create_dc_block(self, title, authors,
174170
affiliations = [affiliations] * len(authors)
175171
creators = []
176172
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()
191176
creator = {
192-
"creatorName": "{}, {}".format(family, given),
177+
"creatorName": "{}, {}".format(family, given).strip(" ,"),
193178
"familyName": family,
194179
"givenName": given
195180
}
181+
if not isinstance(affs, list):
182+
affs = [affs]
196183
if affs:
197184
creator["affiliations"] = affs
198185
creators.append(creator)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
setup(
44
name='mdf_connect_client',
5-
version='0.3.1',
5+
version='0.3.2',
66
packages=['mdf_connect_client'],
77
description='Materials Data Facility Connect Client',
88
long_description=("The MDF Connect Client is the Python client to easily submit"
99
" datasets to MDF Connect."),
1010
install_requires=[
1111
"mdf-toolbox>=0.2.6",
12+
"nameparser>=1.0.4",
1213
"requests>=2.18.4"
1314
],
1415
python_requires=">=3.5",

tests/test_connect_client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_create_dc_block():
2222
# Full test, no lists
2323
mdf.create_dc_block(
2424
title="Connect Title",
25-
authors="Data Facility; Materials",
25+
authors="Data Facility, Materials",
2626
affiliations="UChicago",
2727
publisher="Globus",
2828
publication_year="2017",
@@ -70,7 +70,7 @@ def test_create_dc_block():
7070
# Full test, all lists
7171
mdf.create_dc_block(
7272
title=["Connect Title", "Other Title"],
73-
authors=["Data Facility; Materials", "Blaiszik, Ben", "Jonathon Gaff"],
73+
authors=["Data Facility, Materials", "Blaiszik, Ben", "Jonathon Gaff"],
7474
affiliations=["UChicago", "Argonne"],
7575
publisher="Globus",
7676
publication_year="2017",
@@ -143,18 +143,18 @@ def test_create_dc_block():
143143
# Minimum test
144144
mdf.create_dc_block(
145145
title="Project One",
146-
authors=["Senior Programmer", "Programmer, Junior"]
146+
authors=["Artemis Moonshot", "Landing, Apollo"]
147147
)
148148
assert mdf.dc == {
149149
'creators': [{
150-
'creatorName': 'Programmer, Senior',
151-
'familyName': 'Programmer',
152-
'givenName': 'Senior'
150+
'creatorName': 'Moonshot, Artemis',
151+
'familyName': 'Moonshot',
152+
'givenName': 'Artemis'
153153
},
154154
{
155-
'creatorName': 'Programmer, Junior',
156-
'familyName': 'Programmer',
157-
'givenName': 'Junior'
155+
'creatorName': 'Landing, Apollo',
156+
'familyName': 'Landing',
157+
'givenName': 'Apollo'
158158
}
159159
],
160160
'publicationYear': '2019',

0 commit comments

Comments
 (0)