Debian Codegraph @

bin/menulibre-menu-validate

raw
1 #!/usr/bin/python3
2 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3 # MenuLibre - Advanced fd.o Compliant Menu Editor
4 #
5 # This script is intended as a convenient way to access GMenu's debugging
6 # output on stderr, which exposes information about invalid desktop files,
7 # without doing strange hacks on menulibre's own stderr
8
9 # Copyright (C) 2017-2018 OmegaPhil <[email protected]>
10 #
11 # This program is free software: you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License version 3, as published
13 # by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranties of
17 # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
18 # PURPOSE. See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along
21 # with this program. If not, see <http://www.gnu.org/licenses/>.
22
23
24 import locale
25 locale.textdomain('menulibre')
26
27 import os
28 import os.path
29 import sys
30
31 import gi
32 gi.require_version('GMenu', '3.0')
33 gi.require_version('Gtk', '3.0') # This seems to be needed for imported
34 # menulibre code
35
36 from gi.repository import GMenu
37
38
39 # As with the main script, need to mess with the path to access menulibre code
40 # Get project root directory (enable symlink and trunk execution)
41 PROJECT_ROOT_DIRECTORY = os.path.abspath(
42 os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
43
44 # Add project root directory to python search path
45 sys.path.append(PROJECT_ROOT_DIRECTORY)
46
47
48 from menulibre.MenuEditor import MenuEditor
49
50
51 # Enable debug output from the GMenu library on stderr
52 os.environ["MENU_VERBOSE"] = "1"
53
54 # Create a GMenu object in the same way the real script does - menulibre will
55 # then hook into this script's stderr to pick up on the bad desktop files
56 menu_editor = MenuEditor()