1 |
commit: 8c8dcc663f90f36a81437a711b086ec3bc5d3eef |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Aug 26 21:45:05 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 26 21:45:49 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8c8dcc66 |
7 |
|
8 |
validate_desktop_entry: filter more kde noise |
9 |
|
10 |
This will fix bug #432862. |
11 |
|
12 |
--- |
13 |
pym/portage/util/_desktop_entry.py | 60 +++++++++++++++++++++++++++-------- |
14 |
1 files changed, 46 insertions(+), 14 deletions(-) |
15 |
|
16 |
diff --git a/pym/portage/util/_desktop_entry.py b/pym/portage/util/_desktop_entry.py |
17 |
index 8c760c0..deb0a35 100644 |
18 |
--- a/pym/portage/util/_desktop_entry.py |
19 |
+++ b/pym/portage/util/_desktop_entry.py |
20 |
@@ -2,6 +2,7 @@ |
21 |
# Distributed under the terms of the GNU General Public License v2 |
22 |
|
23 |
import io |
24 |
+import re |
25 |
import subprocess |
26 |
import sys |
27 |
|
28 |
@@ -11,6 +12,7 @@ except ImportError: |
29 |
from ConfigParser import Error as ConfigParserError, RawConfigParser |
30 |
|
31 |
from portage import _encodings, _unicode_encode, _unicode_decode |
32 |
+from portage.util import writemsg |
33 |
|
34 |
def parse_desktop_entry(path): |
35 |
""" |
36 |
@@ -39,11 +41,16 @@ def parse_desktop_entry(path): |
37 |
|
38 |
return parser |
39 |
|
40 |
-_ignored_service_errors = ( |
41 |
- 'error: required key "Name" in group "Desktop Entry" is not present', |
42 |
- 'error: key "Actions" is present in group "Desktop Entry", but the type is "Service" while this key is only valid for type "Application"', |
43 |
- 'error: key "MimeType" is present in group "Desktop Entry", but the type is "Service" while this key is only valid for type "Application"', |
44 |
-) |
45 |
+_trivial_warnings = re.compile(r' looks redundant with value ') |
46 |
+_ignore_kde_key_re = re.compile(r'^\s*(configurationType\s*=|Type\s*=\s*Service)') |
47 |
+_ignore_kde_types = frozenset( |
48 |
+ ["AkonadiAgent", "AkonadiResource", "Service", "ServiceType"]) |
49 |
+ |
50 |
+# kdebase-data installs files with [Currency Code] sections |
51 |
+# in /usr/share/locale/currency |
52 |
+# kdepim-runtime installs files with [Plugin] and [Wizard] |
53 |
+# sections in /usr/share/apps/akonadi/{plugins,accountwizard} |
54 |
+_ignore_kde_sections = ("Currency Code", "Plugin", "Wizard") |
55 |
|
56 |
def validate_desktop_entry(path): |
57 |
args = ["desktop-file-validate", path] |
58 |
@@ -56,10 +63,19 @@ def validate_desktop_entry(path): |
59 |
proc.wait() |
60 |
|
61 |
if output_lines: |
62 |
+ # Ignore kde extensions for bug #414125 and bug #432862. |
63 |
try: |
64 |
desktop_entry = parse_desktop_entry(path) |
65 |
except ConfigParserError: |
66 |
- pass |
67 |
+ with io.open(_unicode_encode(path, |
68 |
+ encoding=_encodings['fs'], errors='strict'), |
69 |
+ mode='r', encoding=_encodings['repo.content'], |
70 |
+ errors='replace') as f: |
71 |
+ for line in f: |
72 |
+ if _ignore_kde_key_re.match(line): |
73 |
+ # Ignore kde extensions for bug #432862. |
74 |
+ del output_lines[:] |
75 |
+ break |
76 |
else: |
77 |
if desktop_entry.has_section("Desktop Entry"): |
78 |
try: |
79 |
@@ -67,13 +83,29 @@ def validate_desktop_entry(path): |
80 |
except ConfigParserError: |
81 |
pass |
82 |
else: |
83 |
- if entry_type == "Service": |
84 |
- # Filter false errors for Type=Service (bug #414125). |
85 |
- filtered_output = [] |
86 |
- for line in output_lines: |
87 |
- if line[len(path)+2:] in _ignored_service_errors: |
88 |
- continue |
89 |
- filtered_output.append(line) |
90 |
- output_lines = filtered_output |
91 |
+ if entry_type in _ignore_kde_types: |
92 |
+ del output_lines[:] |
93 |
+ try: |
94 |
+ desktop_entry.get("Desktop Entry", "Hidden") |
95 |
+ except ConfigParserError: |
96 |
+ pass |
97 |
+ else: |
98 |
+ # The "Hidden" key appears to be unique to special kde |
99 |
+ # service files (which don't validate well), installed |
100 |
+ # in /usr/share/kde4/services/ by packages like |
101 |
+ # nepomuk-core and kurifilter-plugins. |
102 |
+ del output_lines[:] |
103 |
+ for section in _ignore_kde_sections: |
104 |
+ if desktop_entry.has_section(section): |
105 |
+ del output_lines[:] |
106 |
+ |
107 |
+ if output_lines: |
108 |
+ output_lines = [line for line in output_lines |
109 |
+ if _trivial_warnings.search(line) is None] |
110 |
|
111 |
return output_lines |
112 |
+ |
113 |
+if __name__ == "__main__": |
114 |
+ for arg in sys.argv[1:]: |
115 |
+ for line in validate_desktop_entry(arg): |
116 |
+ writemsg(line + "\n", noiselevel=-1) |