From 68eed798837912a042bb028fea7ece36763d2414 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 5 Feb 2022 19:01:37 +0200 Subject: [PATCH 1/2] Add CLI as strava_py --- setup.cfg | 50 ++++++++++++++++++++ setup.py | 3 ++ src/strava_py/__init__.py | 0 src/strava_py/__main__.py | 4 ++ src/strava_py/cli.py | 28 +++++++++++ {strava_py => src/strava_py}/plot_facets.py | 0 {strava_py => src/strava_py}/process_data.py | 0 7 files changed, 85 insertions(+) create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 src/strava_py/__init__.py create mode 100644 src/strava_py/__main__.py create mode 100644 src/strava_py/cli.py rename {strava_py => src/strava_py}/plot_facets.py (100%) rename {strava_py => src/strava_py}/process_data.py (100%) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..0bc3960 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,50 @@ +[metadata] +name = strava_py +version = 0.0.1 +description = Create artistic visualisations with your exercise data +long_description = file: README.md +long_description_content_type = text/markdown +url = https://github.com/marcusvolz/strava_py +author = Marcus Volz +license = MIT +license_file = LICENSE +classifiers = + Development Status :: 3 - Alpha + License :: OSI Approved :: MIT License + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Topic :: Artistic Software + Topic :: Multimedia :: Graphics + Topic :: Scientific/Engineering :: Visualization +keywords = + strava + artistic visualisations + artistic + visualisation + exercise data + exercise +project_urls = + Source=https://github.com/marcusvolz/strava_py + +[options] +packages = find: +install_requires = + fit2gpx + gpxpy + matplotlib + pandas + seaborn +python_requires = >=3.7 +package_dir = =src +zip_safe = True + +[options.packages.find] +where = src + +[options.entry_points] +console_scripts = + strava_py = strava_py.cli:main diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6068493 --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup() diff --git a/src/strava_py/__init__.py b/src/strava_py/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/strava_py/__main__.py b/src/strava_py/__main__.py new file mode 100644 index 0000000..13a3099 --- /dev/null +++ b/src/strava_py/__main__.py @@ -0,0 +1,4 @@ +from strava_py import cli + +if __name__ == "__main__": + cli.main() diff --git a/src/strava_py/cli.py b/src/strava_py/cli.py new file mode 100644 index 0000000..e384e72 --- /dev/null +++ b/src/strava_py/cli.py @@ -0,0 +1,28 @@ +import argparse + + +def main(): + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + parser.add_argument("path", help="Input path to folder with GPX and / or FIT files") + parser.add_argument( + "-o", "--output_file", default="plot.png", help="Output PNG file" + ) + args = parser.parse_args() + + # Normally imports go at the top, but scientific libraries can be slow to import + # so let's validate arguments first + from strava_py.plot_facets import plot_facets + from strava_py.process_data import process_data + + print("Processing data...") + df = process_data(args.path) + + print("Plotting facets...") + plot_facets(df, output_file=args.output_file) + print(f"Saved to {args.output_file}") + + +if __name__ == "__main__": + main() diff --git a/strava_py/plot_facets.py b/src/strava_py/plot_facets.py similarity index 100% rename from strava_py/plot_facets.py rename to src/strava_py/plot_facets.py diff --git a/strava_py/process_data.py b/src/strava_py/process_data.py similarity index 100% rename from strava_py/process_data.py rename to src/strava_py/process_data.py From 63ef6456abdd38601c1d454d7f52663770f53405 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 5 Feb 2022 19:02:00 +0200 Subject: [PATCH 2/2] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62b48fa..7fbb54b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ The process for downloading data is described on the Strava website here: [https ### Process the data -The main function for importing and processing activity files expects a path to a directory of unzipped GPX and / or FIT files. If required, the [fit2gpx](https://github.com/dodo-saba/fit2gpx) package provides useful tools for pre-processing bulk files exported from Stava, e.g. unzipping activity files (see Use Case 3: Strava Bulk Export Tools). +The main function for importing and processing activity files expects a path to a directory of unzipped GPX and / or FIT files. If required, the [fit2gpx](https://github.com/dodo-saba/fit2gpx) package provides useful tools for pre-processing bulk files exported from Strava, e.g. unzipping activity files (see Use Case 3: Strava Bulk Export Tools). ```python df = process_data()