|
2 | 2 | The `Synapse` object encapsulates a connection to the Synapse service and is used for building projects, uploading and |
3 | 3 | retrieving data, and recording provenance of data analysis. |
4 | 4 | """ |
| 5 | + |
5 | 6 | import asyncio |
6 | 7 | import collections |
7 | 8 | import collections.abc |
@@ -607,9 +608,7 @@ def _init_logger(self): |
607 | 608 | logger_name = ( |
608 | 609 | SILENT_LOGGER_NAME |
609 | 610 | if self.silent |
610 | | - else DEBUG_LOGGER_NAME |
611 | | - if self.debug |
612 | | - else DEFAULT_LOGGER_NAME |
| 611 | + else DEBUG_LOGGER_NAME if self.debug else DEFAULT_LOGGER_NAME |
613 | 612 | ) |
614 | 613 | self.logger = logging.getLogger(logger_name) |
615 | 614 | logging.getLogger("py.warnings").handlers = self.logger.handlers |
@@ -2672,9 +2671,11 @@ async def main(): |
2672 | 2671 | fileHandle = await upload_file_handle_async( |
2673 | 2672 | self, |
2674 | 2673 | parent_id_for_upload, |
2675 | | - local_state["path"] |
2676 | | - if (synapseStore or local_state_fh.get("externalURL") is None) |
2677 | | - else local_state_fh.get("externalURL"), |
| 2674 | + ( |
| 2675 | + local_state["path"] |
| 2676 | + if (synapseStore or local_state_fh.get("externalURL") is None) |
| 2677 | + else local_state_fh.get("externalURL") |
| 2678 | + ), |
2678 | 2679 | synapse_store=synapseStore, |
2679 | 2680 | md5=local_file_md5_hex or local_state_fh.get("contentMd5"), |
2680 | 2681 | file_size=local_state_fh.get("contentSize"), |
@@ -3243,9 +3244,10 @@ def get_download_list(self, downloadLocation: str = None) -> str: |
3243 | 3244 | dl_list_path = self.get_download_list_manifest() |
3244 | 3245 | downloaded_files = [] |
3245 | 3246 | new_manifest_path = f"manifest_{time.time_ns()}.csv" |
3246 | | - with open(dl_list_path) as manifest_f, open( |
3247 | | - new_manifest_path, "w" |
3248 | | - ) as write_obj: |
| 3247 | + with ( |
| 3248 | + open(dl_list_path) as manifest_f, |
| 3249 | + open(new_manifest_path, "w") as write_obj, |
| 3250 | + ): |
3249 | 3251 | reader = csv.DictReader(manifest_f) |
3250 | 3252 | columns = reader.fieldnames |
3251 | 3253 | columns.extend(["path", "error"]) |
@@ -4925,9 +4927,11 @@ def _convertProvenanceList(self, usedList: list, limitSearch: str = None) -> lis |
4925 | 4927 | if usedList is None: |
4926 | 4928 | return None |
4927 | 4929 | usedList = [ |
4928 | | - self.get(target, limitSearch=limitSearch) |
4929 | | - if (os.path.isfile(target) if isinstance(target, str) else False) |
4930 | | - else target |
| 4930 | + ( |
| 4931 | + self.get(target, limitSearch=limitSearch) |
| 4932 | + if (os.path.isfile(target) if isinstance(target, str) else False) |
| 4933 | + else target |
| 4934 | + ) |
4931 | 4935 | for target in usedList |
4932 | 4936 | ] |
4933 | 4937 | return usedList |
@@ -5468,7 +5472,7 @@ def _createExternalFileHandle( |
5468 | 5472 | "contentSize": fileSize, |
5469 | 5473 | } |
5470 | 5474 | if mimetype is None: |
5471 | | - (mimetype, enc) = mimetypes.guess_type(externalURL, strict=False) |
| 5475 | + mimetype, enc = mimetypes.guess_type(externalURL, strict=False) |
5472 | 5476 | if mimetype is not None: |
5473 | 5477 | fileHandle["contentType"] = mimetype |
5474 | 5478 | return self.restPOST( |
@@ -5893,16 +5897,16 @@ async def create_s3_storage_location_async( |
5893 | 5897 | } |
5894 | 5898 |
|
5895 | 5899 | if bucket_name: |
5896 | | - storage_location_kwargs[ |
5897 | | - "concreteType" |
5898 | | - ] = concrete_types.EXTERNAL_S3_STORAGE_LOCATION_SETTING |
| 5900 | + storage_location_kwargs["concreteType"] = ( |
| 5901 | + concrete_types.EXTERNAL_S3_STORAGE_LOCATION_SETTING |
| 5902 | + ) |
5899 | 5903 | storage_location_kwargs["bucket"] = bucket_name |
5900 | 5904 | if base_key: |
5901 | 5905 | storage_location_kwargs["baseKey"] = base_key |
5902 | 5906 | else: |
5903 | | - storage_location_kwargs[ |
5904 | | - "concreteType" |
5905 | | - ] = concrete_types.SYNAPSE_S3_STORAGE_LOCATION_SETTING |
| 5907 | + storage_location_kwargs["concreteType"] = ( |
| 5908 | + concrete_types.SYNAPSE_S3_STORAGE_LOCATION_SETTING |
| 5909 | + ) |
5906 | 5910 |
|
5907 | 5911 | storage_location_setting = self.restPOST( |
5908 | 5912 | "/storageLocation", json.dumps(storage_location_kwargs) |
|
0 commit comments