Skip to content

Commit

Permalink
Add valid types to validator (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluesabre committed Sep 17, 2021
1 parent 9fd2ce7 commit eb7450d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 12 additions & 1 deletion menulibre/util.py
Expand Up @@ -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\'')
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions po/menulibre.pot
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -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 ""

0 comments on commit eb7450d

Please sign in to comment.