Skip to content

Commit

Permalink
docs: standardise returns field
Browse files Browse the repository at this point in the history
  • Loading branch information
alycejenni committed Oct 31, 2024
1 parent d2acd39 commit f904325
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions ckanext/doi/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_mode(self):
Whether to run in test mode.
Defaults to true.
:return: test mode enabled as boolean (true=enabled)
:returns: test mode enabled as boolean (true=enabled)
"""
if self._test_mode is None:
self._test_mode = doi_test_mode()
Expand All @@ -58,7 +58,7 @@ def get_prefix(cls):
"""
Get the prefix to use for DOIs.
:return: config prefix setting
:returns: config prefix setting
"""
prefix = toolkit.config.get('ckanext.doi.prefix')
if prefix is None:
Expand All @@ -77,7 +77,7 @@ def generate_doi(self):
The database is checked for previous usage, as is Datacite itself. Use whatever
value is retuned from this function quickly to avoid double use as this function
uses no locking.
:return: the full, unique DOI
:returns: the full, unique DOI
"""
# the list of valid characters is larger than just lowercase and the digits but we don't
# need that many options and URLs with just alphanumeric characters in them are nicer. We
Expand Down Expand Up @@ -133,7 +133,7 @@ def set_metadata(self, doi, xml_dict):
:param doi: the DOI to update the metadata for
:param xml_dict: the metadata as an xml dict (generated from build_xml_dict)
:return:
:returns:
"""
xml_dict['identifiers'] = [{'identifierType': 'DOI', 'identifier': doi}]

Expand All @@ -149,7 +149,7 @@ def get_metadata(self, doi):
Retrieve metadata for a given DOI on datacite.
:param doi: the DOI for which to retrieve the stored metadata
:return:
:returns:
"""
try:
metadata = self.client.metadata_get(doi)
Expand All @@ -163,7 +163,7 @@ def check_for_update(self, doi, xml_dict):
:param doi: the DOI of the package
:param xml_dict: the xml_dict generated by build_xml_dict
:return: True if the two are the same, False if not
:returns: True if the two are the same, False if not
"""
posted_xml = self.get_metadata(doi)
if posted_xml is None or posted_xml.strip() == '':
Expand Down
4 changes: 2 additions & 2 deletions ckanext/doi/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def date_or_none(date_object_or_string):
Try and convert the given object into a datetime; if not possible, return None.
:param date_object_or_string: a datetime or date string
:return: datetime or None
:returns: datetime or None
"""
if isinstance(date_object_or_string, datetime):
return date_object_or_string
Expand All @@ -63,6 +63,6 @@ def doi_test_mode():
"""
Determines whether we're running in test mode.
:return: bool
:returns: bool
"""
return toolkit.asbool(get_setting('ckanext.doi.test_mode', default=get_debug()))
2 changes: 1 addition & 1 deletion ckanext/doi/lib/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def build_xml_dict(metadata_dict):
generate the xml.
:param metadata_dict: a dict of metadata generated from build_metadata_dict
:return: dict that can be passed directly to datacite.schema42.tostring()
:returns: dict that can be passed directly to datacite.schema42.tostring()
"""

# required fields first (DOI will be added later)
Expand Down
2 changes: 1 addition & 1 deletion ckanext/doi/lib/xml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_contributor(
strings
:param identifiers: a list of dicts with "identifier", "scheme", and (optionally)
"scheme_uri"
:return: a dict
:returns: a dict
"""
if is_org and full_name is None:
raise ValueError('Creator name must be supplied as full_name="Org Name"')
Expand Down
14 changes: 7 additions & 7 deletions ckanext/doi/model/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create(cls, identifier, package_id, published=None):
:param identifier: a new DOI string
:param package_id: the id of the package this DOI represents
:param published: when this DOI was published (datetime, nullable)
:return: the newly created record object
:returns: the newly created record object
"""
new_record = DOI(
identifier=identifier, package_id=package_id, published=published
Expand All @@ -37,7 +37,7 @@ def read_doi(cls, identifier):
Retrieve a record with a given DOI.
:param identifier: the DOI string
:return: the record object
:returns: the record object
"""
return Session.query(DOI).get(identifier)

Expand All @@ -49,7 +49,7 @@ def read_package(cls, package_id, create_if_none=False):
:param package_id: the id of the package
:param create_if_none: generate a new DOI and add a record if no record is found
for the given package
:return: the record object
:returns: the record object
"""
from ckanext.doi.lib.api import DataciteClient

Expand All @@ -67,7 +67,7 @@ def update_doi(cls, identifier, **kwargs):
:param identifier: the DOI string
:param kwargs: the values to be updated
:return: the updated record object
:returns: the updated record object
"""
update_dict = {k: v for k, v in kwargs.items() if k in cls.cols}
Session.query(DOI).filter(DOI.identifier == identifier).update(update_dict)
Expand All @@ -82,7 +82,7 @@ def update_package(cls, package_id, **kwargs):
:param package_id: the id of the package
:param kwargs: the values to be updated
:return: the updated record object
:returns: the updated record object
"""
update_dict = {k: v for k, v in kwargs.items() if k in cls.cols}
Session.query(DOI).filter(DOI.package_id == package_id).update(update_dict)
Expand All @@ -95,7 +95,7 @@ def delete_doi(cls, identifier):
Delete the record with a given DOI.
:param identifier: the DOI string
:return: True if a record was deleted, False if not
:returns: True if a record was deleted, False if not
"""
to_delete = cls.read_doi(identifier)
if to_delete is not None:
Expand All @@ -111,7 +111,7 @@ def delete_package(cls, package_id):
Delete the record associated with a given package.
:param package_id: the id of the package
:return: True if a record was deleted, False if not
:returns: True if a record was deleted, False if not
"""
to_delete = cls.read_package(package_id)
if to_delete is not None:
Expand Down

0 comments on commit f904325

Please sign in to comment.