Skip to content

Commit 5db55f2

Browse files
committed
Exit with better error if no files found
1 parent a38449e commit 5db55f2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/stravavis/cli.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import argparse
2+
import glob
23
import os.path
4+
import sys
35

46

57
def main():
@@ -87,6 +89,10 @@ def main():
8789
if os.path.isdir(args.path):
8890
args.path = os.path.join(args.path, "*")
8991

92+
filenames = glob.glob(args.path)
93+
if not filenames:
94+
sys.exit(f"No files found matching {args.path}")
95+
9096
if args.bbox:
9197
# Convert comma-separated string into floats
9298
args.lon_min, args.lat_min, args.lon_max, args.lat_max = (
@@ -108,7 +114,7 @@ def main():
108114
from .process_data import process_data
109115

110116
print("Processing data...")
111-
df = process_data(args.path)
117+
df = process_data(filenames)
112118

113119
activities = None
114120
if args.activities_path:

src/stravavis/process_data.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import glob
21
import math
32
from multiprocessing import Pool
43

@@ -101,10 +100,8 @@ def process_fit(fitfile):
101100

102101

103102
# Function for processing (unzipped) GPX and FIT files in a directory (path)
104-
def process_data(path):
103+
def process_data(filenames: list[str]) -> pd.DataFrame:
105104
# Process all files (GPX or FIT)
106-
filenames = glob.glob(path)
107-
108105
with Pool() as pool:
109106
try:
110107
it = pool.imap_unordered(process_file, filenames)

0 commit comments

Comments
 (0)