(self, base_dir: str)
return self._filter_and_merge_tracks(tracks)
Load tracks base_dir and return as a List of tracks
Load tracks base_dir and return as a List of tracks
Load tracks base_dir and return as a List of tracks
def load_tracks(self, base_dir: str) -> typing.List[Track]:
        """Load tracks base_dir and return as a List of tracks"""
        file_names = list(self._list_gpx_files(base_dir))
        log.info("GPX files: %d", len(file_names))

        tracks: typing.List[Track] = []

        # load track from cache
        cached_tracks: typing.Dict[str, Track] = {}
        if self.cache_dir:
            log.info("Trying to load %d track(s) from cache...", len(file_names))
            cached_tracks = self._load_tracks_from_cache(file_names)
            log.info("Loaded tracks from cache: %d", len(cached_tracks))
            tracks = list(cached_tracks.values())

        # load remaining gpx files
        remaining_file_names = [f for f in file_names if f not in cached_tracks]
        if remaining_file_names:
            log.info("Trying to load %d track(s) from GPX files; this may take a while...", len(remaining_file_names))
            timezone_adjuster = TimezoneAdjuster()
            loaded_tracks = self._load_tracks(remaining_file_names, timezone_adjuster)
            tracks.extend(loaded_tracks.values())
            log.info("Conventionally loaded tracks: %d", len(loaded_tracks))
            self._store_tracks_to_cache(loaded_tracks)

        return self._filter_and_merge_tracks(tracks)
def load_tracks ( self , base_dir : str ) -> typing . List [ Track ] : file_names = list ( self . _list_gpx_files ( base_dir ) ) log . info ( "GPX files: %d" , len ( file_names ) ) tracks : typing . List [ Track ] = [ ] # load track from cache cached_tracks : typing . Dict [ str , Track ] = { } if self . cache_dir : log . info ( "Trying to load %d track(s) from cache..." , len ( file_names ) ) cached_tracks = self . _load_tracks_from_cache ( file_names ) log . info ( "Loaded tracks from cache: %d" , len ( cached_tracks ) ) tracks = list ( cached_tracks . values ( ) ) # load remaining gpx files remaining_file_names = [ f for f in file_names if f not in cached_tracks ] if remaining_file_names : log . info ( "Trying to load %d track(s) from GPX files; this may take a while..." , len ( remaining_file_names ) ) timezone_adjuster = TimezoneAdjuster ( ) loaded_tracks = self . _load_tracks ( remaining_file_names , timezone_adjuster ) tracks . extend ( loaded_tracks . values ( ) ) log . info ( "Conventionally loaded tracks: %d" , len ( loaded_tracks ) ) self . _store_tracks_to_cache ( loaded_tracks ) return self . _filter_and_merge_tracks ( tracks )