Debian Codegraph @

debian/lomiri-gallery-app_01_update-content-hub

raw
1 #!/usr/bin/env python3
2
3 # Copyright (C) 2024-2025 Mike Gabriel <[email protected]>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 3 as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 # This script removes obsolete app names from com.lomiri.content.hub.source
18 # and com.lomiri.content.hub.destination gsettings user configurations.
19
20 from gi.repository import Gio
21
22 peers=["pictures", "videos"]
23
24 deprecated_appnames=["gallery-app", "gallery.ubports"]
25
26 for peer in peers:
27
28 # Retrieve source peers as list of strings
29 src_gsettings = Gio.Settings.new("com.lomiri.content.hub.source")
30 src_peers_current = src_gsettings.get_strv(peer)
31
32 # Retrieve destination peers as list of strings
33 dst_gsettings = Gio.Settings.new("com.lomiri.content.hub.destination")
34 dst_peers_current = dst_gsettings.get_strv(peer)
35
36 #print ("SRC_CURRENT ({peer}): {src_peers_current}".format(peer=peer, src_peers_current=src_peers_current))
37 #print ("DST_CURRENT ({peer}): {dst_peers_current}".format(peer=peer, dst_peers_current=dst_peers_current))
38
39 src_peers_updated=[]
40 dst_peers_updated=[]
41
42 for src_peer in src_peers_current:
43 if src_peer not in deprecated_appnames:
44 src_peers_updated.append(src_peer)
45
46 for dst_peer in dst_peers_current:
47 if dst_peer not in deprecated_appnames:
48 dst_peers_updated.append(dst_peer)
49
50 #print ("SRC_CURRENT ({peer}): {src_peers_updated}".format(peer=peer, src_peers_updated=src_peers_updated))
51 #print ("DST_CURRENT ({peer}): {dst_peers_updated}".format(peer=peer, dst_peers_updated=dst_peers_updated))
52
53 src_gsettings.set_strv(peer, src_peers_updated)
54 dst_gsettings.set_strv(peer, dst_peers_updated)