From eb7450de6f1b17686316a2b0044f28c0f28c96ef Mon Sep 17 00:00:00 2001 From: Sean Davis Date: Fri, 17 Sep 2021 08:35:19 -0400 Subject: [PATCH] Add valid types to validator (#66) --- menulibre/util.py | 13 ++++++++++++- po/menulibre.pot | 11 ++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/menulibre/util.py b/menulibre/util.py index c537db5e..5d91592b 100644 --- a/menulibre/util.py +++ b/menulibre/util.py @@ -673,7 +673,15 @@ def validate_desktop_file(desktop_file): # noqa # missing in a failing desktop file. return _('%s key not found') % 'Type' - if type_key != GLib.KEY_FILE_DESKTOP_TYPE_APPLICATION: + valid_type_keys = [ + GLib.KEY_FILE_DESKTOP_TYPE_APPLICATION, + GLib.KEY_FILE_DESKTOP_TYPE_LINK, + GLib.KEY_FILE_DESKTOP_TYPE_DIRECTORY, + # KDE-specific types + # https://specifications.freedesktop.org/desktop-entry-spec/latest/apb.html + "ServiceType", "Service", "FSDevice" + ] + if type_key not in valid_type_keys: # Translators: This error is displayed when a failing desktop file # has an invalid value for the provided key. return (_('%s value is invalid - currently \'%s\', should be \'%s\'') @@ -711,6 +719,9 @@ def validate_desktop_file(desktop_file): # noqa return (_('%s program \'%s\' is not a valid shell command ' 'according to GLib.shell_parse_argv, error: %s') % ('Exec', exec_key, e)) + + if type_key == "Service": + return False # KDE services are not displayed in the menu # Translators: This error is displayed for a failing desktop file where # errors were detected but the file seems otherwise valid. diff --git a/po/menulibre.pot b/po/menulibre.pot index 9636af13..a5b6a61b 100644 --- a/po/menulibre.pot +++ b/po/menulibre.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-17 08:14-0400\n" +"POT-Creation-Date: 2021-09-17 08:34-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -962,25 +962,26 @@ msgstr "" #. Translators: This error is displayed when a failing desktop file #. has an invalid value for the provided key. -#: ../menulibre/util.py:679 +#: ../menulibre/util.py:687 #, python-format msgid "%s value is invalid - currently '%s', should be '%s'" msgstr "" -#: ../menulibre/util.py:708 +#: ../menulibre/util.py:716 #, python-format msgid "%s program '%s' has not been found in the PATH" msgstr "" -#: ../menulibre/util.py:711 +#: ../menulibre/util.py:719 #, python-format msgid "" "%s program '%s' is not a valid shell command according to GLib." "shell_parse_argv, error: %s" msgstr "" +#. KDE services are not displayed in the menu #. Translators: This error is displayed for a failing desktop file where #. errors were detected but the file seems otherwise valid. -#: ../menulibre/util.py:717 +#: ../menulibre/util.py:728 msgid "Unknown error. Desktop file appears to be valid." msgstr ""