Skip to content

Commit 3f05e06

Browse files
authored
Merge pull request #43 from hugovk/exit-zero-filenames
2 parents a38449e + 4baf655 commit 3f05e06

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-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

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import glob
1+
from __future__ import annotations
2+
23
import math
34
from multiprocessing import Pool
45

@@ -101,10 +102,8 @@ def process_fit(fitfile):
101102

102103

103104
# Function for processing (unzipped) GPX and FIT files in a directory (path)
104-
def process_data(path):
105+
def process_data(filenames: list[str]) -> pd.DataFrame:
105106
# Process all files (GPX or FIT)
106-
filenames = glob.glob(path)
107-
108107
with Pool() as pool:
109108
try:
110109
it = pool.imap_unordered(process_file, filenames)

0 commit comments

Comments
 (0)