Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dirconf #363

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ License: GPL3
Change Log:

+------------------------------------+
Wed, 04 Sep 2024 V.5.0.21
Mon, 28 Oct 2024 V.5.0.21

* Update French language (thanks to Phil Aug).
* Update Spanish language (thanks to katnatek).
Expand All @@ -16,6 +16,9 @@ Wed, 04 Sep 2024 V.5.0.21
* Improved build using pyproject.toml file.
* Improved build using pyinstaller_setup.py file.
* Improved requirements.
* Fixed some broken link.
* Fixed an issue when restoring the configuration directory, which copied
unnecessary files and directories.


+------------------------------------+
Expand Down
5 changes: 4 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ videomass (5.0.21-1) UNRELEASED; urgency=medium
* Improved build using pyproject.toml file.
* Improved build using pyinstaller_setup.py file.
* Improved requirements.
* Fixed some broken link.
* Fixed an issue when restoring the configuration directory, which copied
unnecessary files and directories.

-- Gianluca Pernigotto <[email protected]> Wed, 04 Sep 2024 16:00:00 +0200
-- Gianluca Pernigotto <[email protected]> Mon, 28 Oct 2024 00:00:00 +0200

videomass (5.0.20-1) UNRELEASED; urgency=medium

Expand Down
2 changes: 1 addition & 1 deletion videomass/gui_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, redirect=True, filename=None, **kwargs):
# supported langs for online help (user guide)
}
self.data = DataSource(kwargs) # instance data
self.appset.update(self.data.get_fileconf()) # data system
self.appset.update(self.data.get_configuration()) # data system
self.iconset = None

wx.App.__init__(self, redirect, filename) # constructor
Expand Down
25 changes: 7 additions & 18 deletions videomass/vdms_panels/concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,20 @@ def __init__(self, parent):
sizer_link2 = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(sizer_link2)
self.lbl_msg3 = wx.StaticText(self, wx.ID_ANY,
label=_("For more details, see the "
"Videomass User Guide:")
label=_("Videomass Documentation:")
)
if self.appdata['GETLANG'] in self.appdata['SUPP_LANGs']:
lang = self.appdata['GETLANG'].split('_')[0]
page = (f"https://jeanslack.github.io/Videomass/"
f"Pages/User-guide-languages/{lang}/1-User_"
f"Interface_Overview_{lang}.pdf")
else:
page = ("https://jeanslack.github.io/Videomass/"
"Pages/User-guide-languages/en/1-User_"
"Interface_Overview_en.pdf"
)
link2 = hpl.HyperLinkCtrl(self, -1, ("1.4 Concatenate media files "
"(demuxer)"), URL=page)
page = ("https://jeanslack.github.io/Videomass/User-guide/"
"User_Interface_Overview_en.pdf")
link2 = hpl.HyperLinkCtrl(self, -1, ("User Interface Overview"),
URL=page)
sizer_link2.Add(self.lbl_msg3, 0, wx.ALL | wx.EXPAND, 5)
sizer_link2.Add(link2)
sizer_link1 = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(sizer_link1)
self.lbl_msg2 = wx.StaticText(self, wx.ID_ANY,
label=_("For more information, "
"visit the official FFmpeg "
"documentation:")
label=_("Official FFmpeg documentation:")
)
link1 = hpl.HyperLinkCtrl(self, -1, "3.4 concat",
link1 = hpl.HyperLinkCtrl(self, -1, "Concat",
URL="https://ffmpeg.org/ffmpeg-formats."
"html#concat"
)
Expand Down
6 changes: 2 additions & 4 deletions videomass/vdms_panels/sequence_to_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,9 @@ def __init__(self, parent):
sizer_link1 = wx.BoxSizer(wx.HORIZONTAL)
fgs1.Add(sizer_link1)
lbl_link = wx.StaticText(self, wx.ID_ANY,
label=_("For more information, "
"visit the official FFmpeg "
"documentation:")
label=_("Official FFmpeg documentation:")
)
link1 = hpl.HyperLinkCtrl(self, -1, ("FFmpeg Slideshow wiki"),
link1 = hpl.HyperLinkCtrl(self, -1, ("FFmpeg Slideshow Wiki"),
URL="https://trac.ffmpeg.org/wiki/Slideshow"
)
sizer_link1.Add(lbl_link, 0, wx.ALL | wx.EXPAND, 5)
Expand Down
10 changes: 4 additions & 6 deletions videomass/vdms_panels/video_to_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,13 @@ def __init__(self, parent):
sizer_link1 = wx.BoxSizer(wx.HORIZONTAL)
fgs1.Add(sizer_link1)
lbl_msg1 = wx.StaticText(self, wx.ID_ANY,
label=_("For more information, "
"visit the official FFmpeg "
"documentation:")
label=_("Official FFmpeg documentation:")
)
link1 = hpl.HyperLinkCtrl(self, -1, "4.19 image2",
link1 = hpl.HyperLinkCtrl(self, -1, "image2",
URL="https://ffmpeg.org/ffmpeg-"
"formats.html#image2-2"
"formats.html#image2"
)
link2 = hpl.HyperLinkCtrl(self, -1, ("3.3 FFmpeg FAQ"),
link2 = hpl.HyperLinkCtrl(self, -1, ("FFmpeg FAQ"),
URL="https://ffmpeg.org/faq.html#How-do-I-"
"encode-movie-to-single-pictures_003f"
)
Expand Down
93 changes: 40 additions & 53 deletions videomass/vdms_sys/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Author: Gianluca Pernigotto <[email protected]>
Copyleft - 2024 Gianluca Pernigotto <[email protected]>
license: GPL3
Rev: June.14.2024
Rev: Oct.28.2024
Code checker: flake8, pylint

This file is part of Videomass.
Expand Down Expand Up @@ -60,30 +60,35 @@ def create_dirs(dirname, fconf):
return {'R': None}


def restore_presets_dir(dirconf, srcdata):
def restore_dirconf(dirconf, srcdata):
"""
Restore preset directory from source if it doesn't exist.
check existence of configuration directory
with possibility of restore.
Returns dict:
key == 'R'
key == ERROR (if any errors)
"""
if not os.path.exists(dirconf): # create the configuration directory
try:
os.mkdir(dirconf, mode=0o777)
except FileNotFoundError as err: # parent directory does not exist
return {'ERROR': err}

if not os.path.exists(os.path.join(dirconf, "presets")):
# try to restoring presets directory on videomass dir
drest = copydir_recursively(os.path.join(srcdata, "presets"), dirconf)
if drest:
return {'ERROR': drest}

return {'R': None}


def get_options(dirconf, fileconf, srcdata, makeportable):
def get_options(fileconf, makeportable):
"""
Check the application options. Reads the `settings.json`
file; if it does not exist or is unreadable try to restore
it. If `dirconf` does not exist try to restore both `dirconf`
and `settings.json`. If VERSION is not the same as the version
readed, it adds new missing items while preserving the old ones
with the same values.
it. If VERSION is not the same as the version readed, it adds
new missing items while preserving the old ones with the same
values.

Returns dict:
key == 'R'
Expand All @@ -92,31 +97,19 @@ def get_options(dirconf, fileconf, srcdata, makeportable):
conf = ConfigManager(fileconf, makeportable)
version = ConfigManager.VERSION

if os.path.exists(dirconf): # i.e ~/.conf/videomass dir
if os.path.isfile(fileconf):
data = {'R': conf.read_options()}
if not data['R']:
conf.write_options()
data = {'R': conf.read_options()}
if float(data['R']['confversion']) != version: # conf version
data['R']['confversion'] = version
new = ConfigManager.DEFAULT_OPTIONS # model
data = {'R': {**new, **data['R']}}
conf.write_options(**data['R'])
else:
conf.write_options()
data = {'R': conf.read_options()}

else: # try to restore entire configuration directory
dconf = copydir_recursively(srcdata,
os.path.dirname(dirconf),
"videomass",
)
if dconf:
data = {'ERROR': dconf}
else:
if os.path.isfile(fileconf):
data = {'R': conf.read_options()}
if not data['R']:
conf.write_options()
data = {'R': conf.read_options()}
if float(data['R']['confversion']) != version: # conf version
data['R']['confversion'] = version
new = ConfigManager.DEFAULT_OPTIONS # model
data = {'R': {**new, **data['R']}}
conf.write_options(**data['R'])
else:
conf.write_options()
data = {'R': conf.read_options()}

return data

Expand Down Expand Up @@ -248,7 +241,7 @@ def data_location(kwargs):
"""
Determines data location and modes to make the app
portable, fully portable or using conventional paths.
return data location.
Returns data location dict.
"""
if kwargs['make_portable']:
portdir = kwargs['make_portable']
Expand Down Expand Up @@ -303,31 +296,27 @@ def __init__(self, kwargs):
self.prg_icon = os.path.join(self.dataloc['icodir'], "videomass.png")
# ---------------------------------------------------------------------

def get_fileconf(self):
def get_configuration(self):
"""
Get settings.json configuration data and returns a dict object
with current data-set for bootstrap.
Get configuration data of the application.
Returns a dict object with current data-set for bootstrap.

Note: If returns a dict key == ERROR it will raise a windowed
fatal error in the gui_app bootstrap.
"""
# checks configuration directory
ckdconf = restore_dirconf(self.dataloc['confdir'],
self.dataloc['srcdata'],
)
if ckdconf.get('ERROR'):
return ckdconf

# handle configuration file
userconf = get_options(self.dataloc['confdir'],
self.dataloc['conffile'],
self.dataloc['srcdata'],
self.makeportable,
)
userconf = get_options(self.dataloc['conffile'], self.makeportable)
if userconf.get('ERROR'):
return userconf
userconf = userconf['R']

# restore presets folder
presets_rest = restore_presets_dir(self.dataloc['confdir'],
self.dataloc['srcdata'],
)
if presets_rest.get('ERROR'):
return presets_rest

# create the required directories if not existing
requiredirs = (os.path.join(self.dataloc['cachedir'], 'tmp'),
self.dataloc['logdir'],
Expand Down Expand Up @@ -358,7 +347,7 @@ def _relativize(path, relative=self.relativepaths):
try:
return os.path.relpath(path) if relative else path
except (ValueError, TypeError):
# return {'ERROR': f'{error}'} # use `as error` here
# return {'ERROR': f'{error}'} # used `as error` here
return path

return ({'ostype': platform.system(),
Expand Down Expand Up @@ -386,11 +375,9 @@ def _relativize(path, relative=self.relativepaths):

def icons_set(self, icontheme):
"""
Determines icons set assignment defined on the configuration
file (see `Set icon themes map:`, on paragraph `6- GUI setup`
in the settings.json file).
Determines icons set assignment defined on the
configuration file.
Returns a icontheme dict object.

"""
keys = ('videomass', 'A/V-Conv', 'startconv', 'fileproperties',
'playback', 'concatenate', 'preview', 'clear',
Expand Down
Loading