Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use Python 3.10+ context manager syntax #218

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
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
36 changes: 20 additions & 16 deletions cubi_tk/irods_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ def _create_collections(self, job: TransferJob):

def put(self, recursive: bool = False, sync: bool = False):
# Double tqdm for currently transferred file info
# TODO: add more parenthesis after python 3.10
with tqdm(
total=self.__total_bytes,
unit="B",
unit_scale=True,
unit_divisor=1024,
position=1,
) as t, tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log:
with (
tqdm(
total=self.__total_bytes,
unit="B",
unit_scale=True,
unit_divisor=1024,
position=1,
) as t,
tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log,
):
for n, job in enumerate(self.__jobs):
file_log.set_description_str(
f"File [{n + 1}/{len(self.__jobs)}]: {Path(job.path_local).name}"
Expand Down Expand Up @@ -226,14 +228,16 @@ def get(self):
]
self.__total_bytes = sum([job.bytes for job in self.__jobs])
# Double tqdm for currently transferred file info
# TODO: add more parenthesis after python 3.10
with tqdm(
total=self.__total_bytes,
unit="B",
unit_scale=True,
unit_divisor=1024,
position=1,
) as t, tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log:
with (
tqdm(
total=self.__total_bytes,
unit="B",
unit_scale=True,
unit_divisor=1024,
position=1,
) as t,
tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log,
):
for n, job in enumerate(self.__jobs):
file_log.set_description_str(
f"File [{n + 1}/{len(self.__jobs)}]: {Path(job.path_local).name}"
Expand Down
Loading