summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-08-26 14:45:05 -0700
committerZac Medico <zmedico@gentoo.org>2012-08-26 14:45:49 -0700
commit8c8dcc663f90f36a81437a711b086ec3bc5d3eef (patch)
tree8eb11eaf6510a7746b7656a5d8cd36f1f6dc600a
parente5034a4ec9153047c756923d49c0969fb4fb8ed0 (diff)
downloadportage-8c8dcc663f90f36a81437a711b086ec3bc5d3eef.tar.gz
portage-8c8dcc663f90f36a81437a711b086ec3bc5d3eef.tar.bz2
portage-8c8dcc663f90f36a81437a711b086ec3bc5d3eef.zip
validate_desktop_entry: filter more kde noise
This will fix bug #432862.
-rw-r--r--pym/portage/util/_desktop_entry.py60
1 files changed, 46 insertions, 14 deletions
diff --git a/pym/portage/util/_desktop_entry.py b/pym/portage/util/_desktop_entry.py
index 8c760c043..deb0a35e7 100644
--- a/pym/portage/util/_desktop_entry.py
+++ b/pym/portage/util/_desktop_entry.py
@@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
import io
+import re
import subprocess
import sys
@@ -11,6 +12,7 @@ except ImportError:
from ConfigParser import Error as ConfigParserError, RawConfigParser
from portage import _encodings, _unicode_encode, _unicode_decode
+from portage.util import writemsg
def parse_desktop_entry(path):
"""
@@ -39,11 +41,16 @@ def parse_desktop_entry(path):
return parser
-_ignored_service_errors = (
- 'error: required key "Name" in group "Desktop Entry" is not present',
- 'error: key "Actions" is present in group "Desktop Entry", but the type is "Service" while this key is only valid for type "Application"',
- 'error: key "MimeType" is present in group "Desktop Entry", but the type is "Service" while this key is only valid for type "Application"',
-)
+_trivial_warnings = re.compile(r' looks redundant with value ')
+_ignore_kde_key_re = re.compile(r'^\s*(configurationType\s*=|Type\s*=\s*Service)')
+_ignore_kde_types = frozenset(
+ ["AkonadiAgent", "AkonadiResource", "Service", "ServiceType"])
+
+# kdebase-data installs files with [Currency Code] sections
+# in /usr/share/locale/currency
+# kdepim-runtime installs files with [Plugin] and [Wizard]
+# sections in /usr/share/apps/akonadi/{plugins,accountwizard}
+_ignore_kde_sections = ("Currency Code", "Plugin", "Wizard")
def validate_desktop_entry(path):
args = ["desktop-file-validate", path]
@@ -56,10 +63,19 @@ def validate_desktop_entry(path):
proc.wait()
if output_lines:
+ # Ignore kde extensions for bug #414125 and bug #432862.
try:
desktop_entry = parse_desktop_entry(path)
except ConfigParserError:
- pass
+ with io.open(_unicode_encode(path,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['repo.content'],
+ errors='replace') as f:
+ for line in f:
+ if _ignore_kde_key_re.match(line):
+ # Ignore kde extensions for bug #432862.
+ del output_lines[:]
+ break
else:
if desktop_entry.has_section("Desktop Entry"):
try:
@@ -67,13 +83,29 @@ def validate_desktop_entry(path):
except ConfigParserError:
pass
else:
- if entry_type == "Service":
- # Filter false errors for Type=Service (bug #414125).
- filtered_output = []
- for line in output_lines:
- if line[len(path)+2:] in _ignored_service_errors:
- continue
- filtered_output.append(line)
- output_lines = filtered_output
+ if entry_type in _ignore_kde_types:
+ del output_lines[:]
+ try:
+ desktop_entry.get("Desktop Entry", "Hidden")
+ except ConfigParserError:
+ pass
+ else:
+ # The "Hidden" key appears to be unique to special kde
+ # service files (which don't validate well), installed
+ # in /usr/share/kde4/services/ by packages like
+ # nepomuk-core and kurifilter-plugins.
+ del output_lines[:]
+ for section in _ignore_kde_sections:
+ if desktop_entry.has_section(section):
+ del output_lines[:]
+
+ if output_lines:
+ output_lines = [line for line in output_lines
+ if _trivial_warnings.search(line) is None]
return output_lines
+
+if __name__ == "__main__":
+ for arg in sys.argv[1:]:
+ for line in validate_desktop_entry(arg):
+ writemsg(line + "\n", noiselevel=-1)