This PR refactors some of the classes to reduce direct dependencies between them. I'll summarize the changes below.
Note, these changes are structural and should be largely invisible. The only exception to this is the information string (previously stream) when using getMetadataTrack with json.
config.py
Relocate ffmpeg version logic from config.py to ffmpegtools.py. This file just queries the config file if it exists and stores the ffprobe and ffmpeg paths if available. This removes ffmpeg specific operations from the concerns of config.py.
ffmpegtools.py
Remove the dependency and internal knowledge of the Config class from the FFMpegTools class. This class now conditionally overrides the ffprobe and ffmpeg paths if provided, otherwise with initialize itself with sensible defaults (based on the plaform). Additionally, this allows for the determination of whether to use the ffprobe json interface to be internal to the FFMpegTools class. This allows for the getMetadataTrackFromJSON and getMetadataTrack methods to be removed and combined into a single method getMetadataTrack which uses the json interface as needed. This simplifies the use of the class in the gpmf.py classes.
gopro2gpx.py
The FFMpegTools class is instantiated at the top-level main() function so that it can be injected into the Parser class rather than have it be instantiated inline. This should make the Parser class easier to test as we can mock the FFMpegTools class.
gpmf.py
This now takes the injected FFMpegTools dependency. There is now only a unified method getMetadataTrack to call so the conditional has been removed.
This PR refactors some of the classes to reduce direct dependencies between them. I'll summarize the changes below. Note, these changes are structural and should be largely invisible. The only exception to this is the information string (previously
stream
) when usinggetMetadataTrack
with json.config.py
Relocate ffmpeg version logic from
config.py
toffmpegtools.py
. This file just queries the config file if it exists and stores the ffprobe and ffmpeg paths if available. This removes ffmpeg specific operations from the concerns ofconfig.py
.ffmpegtools.py
Remove the dependency and internal knowledge of the
Config
class from theFFMpegTools
class. This class now conditionally overrides the ffprobe and ffmpeg paths if provided, otherwise with initialize itself with sensible defaults (based on the plaform). Additionally, this allows for the determination of whether to use the ffprobe json interface to be internal to theFFMpegTools
class. This allows for thegetMetadataTrackFromJSON
andgetMetadataTrack
methods to be removed and combined into a single methodgetMetadataTrack
which uses the json interface as needed. This simplifies the use of the class in thegpmf.py
classes.gopro2gpx.py
The
FFMpegTools
class is instantiated at the top-levelmain()
function so that it can be injected into theParser
class rather than have it be instantiated inline. This should make theParser
class easier to test as we can mock theFFMpegTools
class.gpmf.py
This now takes the injected
FFMpegTools
dependency. There is now only a unified methodgetMetadataTrack
to call so the conditional has been removed.