-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tom Goetz
committed
Sep 22, 2021
1 parent
4b0976c
commit 190e4b5
Showing
9 changed files
with
64 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
include garmindb/GarminConnectConfig.json.example | ||
include requirements.in | ||
include requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Plugins
updated
9 files
+3 −2 | Makefile | |
+0 −56 | activity_plugin_base.py | |
+1 −1 | fbb_dozen_cycle_plugin.py | |
+1 −1 | fbb_dozen_paddle_plugin.py | |
+1 −1 | fbb_dozen_run_plugin.py | |
+1 −1 | fbb_dozen_walk_plugin.py | |
+1 −1 | fbb_elliptical_plugin.py | |
+1 −1 | fbb_hrv_plugin.py | |
+1 −1 | fbb_paddle_plus_plugin.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Base class for GarminDb plugins.""" | ||
|
||
__author__ = "Tom Goetz" | ||
__copyright__ = "Copyright Tom Goetz" | ||
__license__ = "GPL" | ||
|
||
import logging | ||
|
||
|
||
logger = logging.getLogger(__file__) | ||
|
||
|
||
class ActivityPluginBase(): | ||
"""Base class for GarminDb plugins.""" | ||
|
||
@classmethod | ||
def matches_activity_file(cls, fit_file): | ||
"""Return if the file matches this plugin.""" | ||
if hasattr(cls, '_application_id'): | ||
return cls._application_id in fit_file.dev_application_ids | ||
if hasattr(cls, '_sport') and (fit_file.sport_type is None or fit_file.sport_type.value is not cls._sport): | ||
return False | ||
if hasattr(cls, '_sub_sport') and (fit_file.sub_sport_type is None or fit_file.sub_sport_type.value is not cls._sub_sport): | ||
return False | ||
if hasattr(cls, '_dev_fields'): | ||
for dev_field in cls._dev_fields: | ||
if dev_field not in fit_file.dev_fields: | ||
return False | ||
return True | ||
|
||
@classmethod | ||
def init_activity(cls, act_db_class, activities_table): | ||
"""Initialize an instance of the elliptical plugin as an activity FIT file plugin.""" | ||
logger.info("Initializing tables for activity plugin %s with act_table %s", cls.__name__, activities_table) | ||
if hasattr(cls, '_records_tablename') and 'record' not in cls._tables: | ||
cls._tables['record'] = activities_table.create(cls._records_tablename, act_db_class, cls._records_version, cls._records_pk, cls._records_cols) | ||
if hasattr(cls, '_laps_tablename') and 'lap' not in cls._tables: | ||
cls._tables['lap'] = activities_table.create(cls._laps_tablename, act_db_class, cls._laps_version, cls._laps_pk, cls._laps_cols) | ||
if hasattr(cls, '_sessions_tablename') and 'session' not in cls._tables: | ||
cls._tables['session'] = activities_table.create(cls._sessions_tablename, act_db_class, cls._sessions_version, cols=cls._sessions_cols, | ||
create_view=cls._views['activity_view'], vars={'activities_table': activities_table}) | ||
|
||
@classmethod | ||
def _get_field(cls, message_fields, field_name_list): | ||
for field_name in field_name_list: | ||
if field_name in message_fields: | ||
return message_fields[field_name] | ||
|
||
@classmethod | ||
def filter_data(cls, indict): | ||
"""Filter None and 0 values from a dict.""" | ||
return {key: value for key, value in indict.items() if value} | ||
|
||
def __str__(self): | ||
"""Return a string representation of the class instance.""" | ||
return f'{self.__class__.__name__}(tables {repr(self._tables.keys())})' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ tqdm | |
matplotlib | ||
cloudscraper | ||
ipykernel | ||
fitfile>=1.0.1 | ||
fitfile>=1.0.3 | ||
tcxfile>=1.0.1 | ||
idbutils>=1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters