Skip to content

Commit accc3c9

Browse files
committed
Reduce printing if verbose is not set
1 parent 92518eb commit accc3c9

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

earthpy/io.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ def _get_figshare_download_urls(self, article_id):
301301
"""
302302
# API Endpoint for article metadata
303303
url = f"https://api.figshare.com/v2/articles/{article_id}"
304-
print(f"🔄 Fetching metadata for article {article_id}...")
304+
if self.verbose:
305+
print(f"🔄 Fetching metadata for article {article_id}...")
305306

306307
response = requests.get(url)
307308
if response.status_code != 200:
@@ -322,7 +323,8 @@ def _get_figshare_download_urls(self, article_id):
322323
for file_info in files
323324
}
324325

325-
print(f"✅ Found {len(download_urls)} files for download.")
326+
if self.verbose:
327+
print(f"✅ Found {len(download_urls)} files for download.")
326328
return download_urls
327329

328330
def _download(self, url, path, kind, replace, verbose):

earthpy/project.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def __init__(
7777
title=None, key=None,
7878
dirname=None,
7979
appname="earth-analytics",
80+
verbose=False
8081
):
8182
self.appname = appname
8283
self.config = self._load_config_files()
@@ -88,6 +89,7 @@ def __init__(
8889
or title
8990
or DEFAULT_PROJECT_DIRNAME
9091
).replace(" ", "-").lower()
92+
self.verbose = verbose
9193

9294

9395
# Prepare directories
@@ -224,19 +226,22 @@ def _load_config_files(self):
224226

225227
# Load local config if it exists
226228
if local_file.exists():
227-
print(f"Loading local configuration from {local_file}")
229+
if self.verbose:
230+
print(f"Loading local configuration from {local_file}")
228231
local_configs.update(self._read_config_file(local_file))
229232

230233
# Load global config if it exists
231234
if global_file.exists():
232-
print(f"Loading global configuration from {global_file}")
235+
if self.verbose:
236+
print(f"Loading global configuration from {global_file}")
233237
global_configs.update(self._read_config_file(global_file))
234238

235239
# Merge configurations, local values override global
236240
combined_config = {**global_configs, **local_configs}
237241

238-
print("\n**Final Configuration Loaded:**")
239-
pprint(combined_config, sort_dicts=False, width=80)
242+
if self.verbose:
243+
print("\n**Final Configuration Loaded:**")
244+
pprint(combined_config, sort_dicts=False, width=80)
240245

241246
return combined_config
242247

@@ -262,12 +267,14 @@ def _get_config_parameter(self, param_name):
262267
# Environment variable check (case-insensitive)
263268
for key, value in os.environ.items():
264269
if key.lower() == f"EARTHPY_{param_name}".lower():
265-
print(f"Found '{param_name}' in environment variables.")
270+
if self.verbose:
271+
print(f"Found '{param_name}' in environment variables.")
266272
return value
267273

268274
# Configuration file check
269275
if param_name in self.config:
270-
print(f"Found '{param_name}' in configuration files.")
276+
if self.verbose:
277+
print(f"Found '{param_name}' in configuration files.")
271278
return self.config[param_name]
272279

273280
return None

0 commit comments

Comments
 (0)