Skip to content

Commit b4b9e4e

Browse files
committed
black formatting
1 parent 94bb781 commit b4b9e4e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pybullet_tree_sim/utils/mesh_downloader.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,25 @@
1111

1212

1313
def get_filename_from_url(url: str) -> str:
14-
local_filename = url.split('/')[-1]
14+
local_filename = url.split("/")[-1]
1515
return os.path.join(meshes_path, local_filename)
1616

1717

1818
def is_download_needed(target_file_path: str) -> bool:
1919
if not os.path.exists(meshes_path):
2020
os.mkdir(meshes_path)
2121
return True
22-
if not os.path.exists(os.path.join(meshes_path, 'trees')):
23-
if not os.path.isfile(os.path.join(meshes_path, 'pybullet-tree-sim-meshes.zip')): # TODO: pass name into func
22+
if not os.path.exists(os.path.join(meshes_path, "trees")):
23+
if not os.path.isfile(os.path.join(meshes_path, "pybullet-tree-sim-meshes.zip")): # TODO: pass name into func
2424
return True
2525
else:
2626
return False
2727
else:
2828
return False
2929

30+
3031
def is_unzip_needed(target_file_path: str) -> bool:
31-
if not os.path.exists(os.path.join(meshes_path, 'trees')):
32+
if not os.path.exists(os.path.join(meshes_path, "trees")):
3233
return True
3334
else:
3435
return False
@@ -40,25 +41,24 @@ def download_file(url: str, target_file_path: str) -> bool:
4041
with requests.get(url, stream=True) as r:
4142
r.raise_for_status()
4243
total_size = int(r.headers.get("content-length", 0))
43-
with tqdm(total=total_size, unit='B', unit_scale=True) as progress_bar:
44-
with open(target_file_path, 'wb') as f:
45-
for chunk in r.iter_content(chunk_size=8192):
44+
with tqdm(total=total_size, unit="B", unit_scale=True) as progress_bar:
45+
with open(target_file_path, "wb") as f:
46+
for chunk in r.iter_content(chunk_size=8192):
4647
# If you have chunk encoded response uncomment if
4748
# and set chunk_size parameter to None.
48-
# if chunk:
49+
# if chunk:
4950
progress_bar.update(len(chunk))
5051
f.write(chunk)
51-
52+
5253
return True
53-
54+
5455
except Exception as e:
55-
print(f'{e}')
56+
print(f"{e}")
5657
return False
57-
5858

5959

6060
def unzip(zip_file: str):
61-
with zipfile.ZipFile(zip_file, 'r') as zipper:
61+
with zipfile.ZipFile(zip_file, "r") as zipper:
6262
zipper.extractall(os.path.dirname(zip_file))
6363
return
6464

@@ -71,7 +71,7 @@ def main():
7171
download_needed = is_download_needed(target_file_path=file_abs_path)
7272
if download_needed:
7373
download_file(url=url, target_file_path=file_abs_path)
74-
74+
7575
unzip_needed = is_unzip_needed(target_file_path=file_abs_path)
7676
if unzip_needed:
7777
unzip(zip_file=file_abs_path)

0 commit comments

Comments
 (0)