Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmr/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,26 @@ def bearer_token(self, bearer_token: str) -> Self:

return self

def client_id(self, client_id: str) -> Self:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to use https://docs.python.org/3/library/importlib.metadata.html#importlib.metadata.version to dynamically replace the version of python_cmr in use instead of hard-coding it in the string.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid confusion, I suggest that you do not name the function parameter the same as the function itself. I suggest changing the function parameter name to id_ instead of client_id. Note the trailing underscore on id_ because there is a global function named id, so the trailing underscore is a convention used to avoid name collisions with global variables.

"""
Set the value of this query's 'Client ID' header according to User's input.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Set the value of this query's 'Client ID' header according to User's input.
Set the value of this query's `Client-Id` header.


If an empty parameter is given, default is set to be
python_cmr-vX.Y.Z, where X.Y.Z is the version of python_cmr.
Otherwise, set the specified paramter option to the value along with
the suffix (python_cmr-vX.Y.Z) and a space character between the specified paramter and the suffix.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Otherwise, set the specified paramter option to the value along with
the suffix (python_cmr-vX.Y.Z) and a space character between the specified paramter and the suffix.
Otherwise, set the header value to the specified value along with
the suffix `(python_cmr-vX.Y.Z)`, separated by a space character.


:param client_id
:returns self
"""

if not client_id:
self.headers.update({"Client-Id: python_cmr-v0.13.0"})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.headers.update({"Client-Id: python_cmr-v0.13.0"})
self.headers.update({"Client-Id": "python_cmr-v0.13.0"})


self.headers.update({"Client-Id": f"{client_id} python_cmr-v0.13.0"})

return self

def option(
self, parameter: str, key: str, value: Union[str, bool, int, float, None]
) -> Self:
Expand Down