Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
otter606 committed Feb 9, 2022
1 parent 3046d16 commit 802e6ee
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 27 deletions.
3 changes: 2 additions & 1 deletion examples/freezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def add_to_parent_tier(self, parents, parents_per_gp, items_per_parent, items):
col = 1
samples_created = samples_created + box_cols
print(
f" created {box_cols} samples / {total_samples_to_create}", file=sys.stderr,
f" created {box_cols} samples / {total_samples_to_create}",
file=sys.stderr,
)

## we can move 12 samples at a time
Expand Down
6 changes: 4 additions & 2 deletions examples/tree_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,10 @@ def _populateFromLog(itemType, folderDict):
)
)
docname = "eCAT gallery images for documents in " + os.path.basename(parentDir)
folder_link = "Gallery Images in Documents in this folder:\n<docId={}>\n".format(
gifolders[parentDir]
folder_link = (
"Gallery Images in Documents in this folder:\n<docId={}>\n".format(
gifolders[parentDir]
)
)
new_document_id = -1
if not dirName in sdocs:
Expand Down
8 changes: 6 additions & 2 deletions rspace_client/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def doDelete(self, path, resource_id):
"""
numeric_id = self._get_numeric_record_id(resource_id)
return self.retrieve_api_results(
"/{}/{}".format(path, numeric_id), content_type=None, request_type="DELETE",
"/{}/{}".format(path, numeric_id),
content_type=None,
request_type="DELETE",
)

def retrieve_api_results(
Expand Down Expand Up @@ -205,7 +207,9 @@ def serr(self, msg: str):
print(msg, file=sys.stderr)

def _stream(
self, endpoint: str, pagination: Pagination = Pagination(),
self,
endpoint: str,
pagination: Pagination = Pagination(),
):
"""
Yields items, making paginated requests to the server as each page
Expand Down
19 changes: 13 additions & 6 deletions rspace_client/eln/eln.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def get_document_csv(self, doc_id):
"""
numeric_doc_id = self._get_numeric_record_id(doc_id)
return self.retrieve_api_results(
"/documents/{}".format(numeric_doc_id), content_type="text/csv",
"/documents/{}".format(numeric_doc_id),
content_type="text/csv",
)

def create_document(
Expand Down Expand Up @@ -244,7 +245,9 @@ def update_document(
data["fields"] = fields
numeric_doc_id = self._get_numeric_record_id(document_id)
return self.retrieve_api_results(
"/documents/{}".format(numeric_doc_id), request_type="PUT", params=data,
"/documents/{}".format(numeric_doc_id),
request_type="PUT",
params=data,
)

# Sharing methods
Expand Down Expand Up @@ -684,7 +687,8 @@ def publish_form(self, form_id):
"""
numeric_doc_id = self._get_numeric_record_id(form_id)
return self.retrieve_api_results(
"/forms/{}/publish".format(numeric_doc_id), request_type="PUT",
"/forms/{}/publish".format(numeric_doc_id),
request_type="PUT",
)

def unpublish_form(self, form_id):
Expand All @@ -696,7 +700,8 @@ def unpublish_form(self, form_id):
"""
numeric_doc_id = self._get_numeric_record_id(form_id)
return self.retrieve_api_results(
"/forms/{}/unpublish".format(numeric_doc_id), request_type="PUT",
"/forms/{}/unpublish".format(numeric_doc_id),
request_type="PUT",
)

def share_form(self, form_id):
Expand All @@ -708,7 +713,8 @@ def share_form(self, form_id):
"""
numeric_doc_id = self._get_numeric_record_id(form_id)
return self.retrieve_api_results(
"/forms/{}/share".format(numeric_doc_id), request_type="PUT",
"/forms/{}/share".format(numeric_doc_id),
request_type="PUT",
)

def unshare_form(self, form_id):
Expand All @@ -721,7 +727,8 @@ def unshare_form(self, form_id):
"""
numeric_doc_id = self._get_numeric_record_id(form_id)
return self.retrieve_api_results(
"/forms/{}/unshare".format(numeric_doc_id), request_type="PUT",
"/forms/{}/unshare".format(numeric_doc_id),
request_type="PUT",
)

# Folder / notebook methods
Expand Down
4 changes: 3 additions & 1 deletion rspace_client/eln/filetree_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def __init__(self, eln_client):

def _create_file_linking_doc(self, content, parent_folder_id, name, path2Id):
rs_doc = self.cli.create_document(
name, parent_folder_id=parent_folder_id, fields=[{"content": content}],
name,
parent_folder_id=parent_folder_id,
fields=[{"content": content}],
)
path2Id[name] = rs_doc["globalId"]

Expand Down
32 changes: 21 additions & 11 deletions rspace_client/inv/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ def __init__(self, target_container: Union[str, int, dict, Container]):

class ImageContainerTargetLocation(TargetLocation):
"""
An location in an ImageContainer is specified by the the container, and the
ID of the location within the container.
An location in an ImageContainer is specified by the the container, and the
ID of the location within the container.
"""

def __init__(
Expand Down Expand Up @@ -928,7 +928,7 @@ def __repr__(self):

class ListContainerPost(ContainerPost):
"""
Define a new ListContainer to create
Define a new ListContainer to create
"""

def __init__(
Expand All @@ -955,7 +955,7 @@ def __init__(

class ImageContainerPost(ContainerPost):
"""
Define a new ImageContainer to create.
Define a new ImageContainer to create.
"""

def __init__(
Expand Down Expand Up @@ -1011,7 +1011,7 @@ def __init__(

class GridContainerPost(ContainerPost):
"""
Define a new grid container to create
Define a new grid container to create
"""

def __init__(
Expand Down Expand Up @@ -1203,7 +1203,9 @@ def _do_simple_list(self, endpoint, pagination, sample_filter):
if sample_filter is not None:
pagination.data.update(sample_filter.data)
return self.retrieve_api_results(
f"/{endpoint}", request_type="GET", params=pagination.data,
f"/{endpoint}",
request_type="GET",
params=pagination.data,
)

def stream_samples(
Expand Down Expand Up @@ -1408,7 +1410,8 @@ def duplicate(
id_to_copy = Id(item_to_duplicate)
endpoint = id_to_copy.get_api_endpoint()
rc = self.retrieve_api_results(
f"/{endpoint}/{id_to_copy.as_id()}/actions/duplicate", request_type="POST",
f"/{endpoint}/{id_to_copy.as_id()}/actions/duplicate",
request_type="POST",
)
if new_name is not None:
rc = self.rename(rc, new_name)
Expand Down Expand Up @@ -1449,7 +1452,9 @@ def add_note_to_subsample(
raise ValueError("Supplied id is not a subsamples")
data = {"content": note}
return self.retrieve_api_results(
f"/subSamples/{ss_id.as_id()}/notes", request_type="POST", params=data,
f"/subSamples/{ss_id.as_id()}/notes",
request_type="POST",
params=data,
)

def get_workbenches(self) -> Sequence[dict]:
Expand Down Expand Up @@ -1598,7 +1603,7 @@ def set_as_top_level_container(
self, container: Union[int, str, dict, Container]
) -> dict:
"""
Moves a container from its current location to be a top-level container
Moves a container from its current location to be a top-level container
Parameters
----------
Expand All @@ -1621,7 +1626,11 @@ def _id_as_container_id(self, target_container_id):
raise ValueError("Target must be a container")
return id_target

def add_items_to_list_container(self, target_container_id, *item_ids: str,) -> list:
def add_items_to_list_container(
self,
target_container_id,
*item_ids: str,
) -> list:
"""
Adds 1 or more items to a list container
Expand Down Expand Up @@ -2011,7 +2020,8 @@ def restore_sample_template(self, sample_template_id: Union[int, str]) -> dict:
"""
id_to_restore = Id(sample_template_id)
return self.retrieve_api_results(
f"/sampleTemplates/{id_to_restore.as_id()}/restore", request_type="PUT",
f"/sampleTemplates/{id_to_restore.as_id()}/restore",
request_type="PUT",
)

def transfer_sample_template_owner(
Expand Down
19 changes: 15 additions & 4 deletions rspace_client/tests/template_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
class TemplateBuilderTest(unittest.TestCase):
def test_invalid_unit(self):
self.assertRaises(
ValueError, TemplateBuilder, "name", "unknownUnit",
ValueError,
TemplateBuilder,
"name",
"unknownUnit",
)

def test_add_radio(self):
Expand Down Expand Up @@ -66,7 +69,10 @@ def test_add_number_field_requires_number(self):
builder = TemplateBuilder("myTemplate", "ml")

self.assertRaises(
ValueError, builder.number, "pH", "XXX",
ValueError,
builder.number,
"pH",
"XXX",
)

def test_add_number_field_no_default(self):
Expand All @@ -77,7 +83,9 @@ def test_add_number_field_no_default(self):
def test_name_required(self):
builder = TemplateBuilder("myTemplate", "ml")
self.assertRaises(
ValueError, builder.number, "",
ValueError,
builder.number,
"",
)

def test_add_date(self):
Expand Down Expand Up @@ -128,7 +136,10 @@ def test_add_uri(self):
self.assertEqual(2, builder.field_count())
self.assertEqual("https://www.google.com", builder._fields()[0]["content"])
self.assertRaises(
ValueError, builder.uri, "name", "aa://www.goog[le.com:XXXX",
ValueError,
builder.uri,
"name",
"aa://www.goog[le.com:XXXX",
)

def test_build(self):
Expand Down

0 comments on commit 802e6ee

Please sign in to comment.