Merge lp:~dholbach/arb-lint/1019212 into lp:arb-lint

Proposed by Daniel Holbach
Status: Merged
Merged at revision: 27
Proposed branch: lp:~dholbach/arb-lint/1019212
Merge into: lp:arb-lint
Diff against target: 115 lines (+51/-13)
3 files modified
lint/binarypackages.py (+30/-4)
lint/checks.py (+7/-0)
lint/output.py (+14/-9)
To merge this branch: bzr merge lp:~dholbach/arb-lint/1019212
Reviewer Review Type Date Requested Status
Andrew Mitchell (community) Needs Fixing
Review via email: mp+113047@code.launchpad.net
To post a comment you must log in.
lp:~dholbach/arb-lint/1019212 updated
29. By Daniel Holbach

correct /opt error message

30. By Daniel Holbach

changed file identation

Revision history for this message
Andrew Mitchell (ajmitch) wrote :

The checks for /opt mostly look like they'll do the right thing, but you may run into python problems with the default arguments to functions being [], as calling pretty_print without file_list set after having it set, will likely still print out the file list, which isn't really what you want.
I think we just accept a blanket exception for /usr/share/doc/<packagename> which would allow README.Debian, NEWS, etc in that directory.

review: Needs Fixing
Revision history for this message
Daniel Holbach (dholbach) wrote :

I'm not sure if I understand "you may run into python problems with the default arguments to functions being [], as calling pretty_print without file_list set after having it set, will likely still print out the file list, which isn't really what you want." correctly, but there is a test for "if file_list:" in line 9 in pretty_print().

I'm happy to relax the checks for files in /usr/share/doc, if that's what we agree on.

lp:~dholbach/arb-lint/1019212 updated
31. By Daniel Holbach

add missing line break

32. By Daniel Holbach

relax checks for files in usr/share/doc

Revision history for this message
Daniel Holbach (dholbach) wrote :

<ajmitch> dholbach: merge it

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lint/binarypackages.py'
2--- lint/binarypackages.py 2012-06-29 08:53:07 +0000
3+++ lint/binarypackages.py 2012-07-03 07:14:23 +0000
4@@ -5,6 +5,7 @@
5
6 from . depends import provides, requires
7 from . output import warning, error
8+import checks
9
10 class BinaryPackages(object):
11 arches = []
12@@ -47,6 +48,7 @@
13 "tests.")
14
15 @provides('debs')
16+ @requires('changes_file')
17 def find_debs(self):
18 if not self.changes_file:
19 return None
20@@ -60,8 +62,8 @@
21 if not self.debs:
22 error("No packages found.")
23
24+ @provides('deb_contents')
25 @requires('debs')
26- @provides('deb_contents')
27 def find_deb_contents(self):
28 if not self.debs:
29 return None
30@@ -99,6 +101,30 @@
31 not os.path.basename(a).startswith("extras-unity-"), self.deb_contents)
32 if offending_files:
33 error("The following file names should start with "
34- "'extras-unity-':"
35- "%s" % ("\n".join(["\t%s" % f for f in offending_files])))
36-
37+ "'extras-unity-':",
38+ offending_files)
39+
40+ @requires('deb_contents')
41+ def test_files_in_opt(self):
42+ if not self.deb_contents:
43+ return
44+ correct_opt_path = "opt/extras.ubuntu.com/" + self.sp.package_name
45+ doc_path = "usr/share/doc/" + self.sp.package_name
46+ exceptions = [
47+ ".lens",
48+ ".desktop",
49+ ".service",
50+ doc_path,
51+ ]
52+ files_in_opt = filter(lambda filename: correct_opt_path in filename,
53+ self.deb_contents)
54+ files_not_in_opt = filter(lambda filename: correct_opt_path not in filename,
55+ self.deb_contents)
56+ if not files_in_opt:
57+ error("The package seems to contain no files in '/%s' which "
58+ "indicates a problem with the installation of files." % \
59+ correct_opt_path)
60+ other_std_files = checks.find_offending_items(files_not_in_opt, exceptions)
61+ if other_std_files:
62+ error("These files are outside %s and shouldn't be: " % correct_opt_path,
63+ other_std_files)
64
65=== modified file 'lint/checks.py'
66--- lint/checks.py 2012-06-29 10:26:20 +0000
67+++ lint/checks.py 2012-07-03 07:14:23 +0000
68@@ -9,3 +9,10 @@
69 if len(contents) == 0:
70 return True
71 return False
72+
73+def find_offending_items(items, exceptions):
74+ offenders = []
75+ for item in items:
76+ if filter(lambda a: a not in item, exceptions) == exceptions:
77+ offenders += [ item ]
78+ return offenders
79
80=== modified file 'lint/output.py'
81--- lint/output.py 2012-06-29 11:46:49 +0000
82+++ lint/output.py 2012-07-03 07:14:23 +0000
83@@ -1,18 +1,23 @@
84 import textwrap
85
86-def pretty_print(message, start):
87+def pretty_print(message, start, file_list=[]):
88 indent = len(start)
89 lines = textwrap.wrap(message, 75-indent)
90 message = start + lines[0] + "\n"
91 indented_lines = [' '.ljust(indent) + line for line in lines[1:]]
92 message += "\n".join(indented_lines)
93+ if file_list:
94+ if message[-1] != "\n":
95+ message += "\n"
96+ indented_files = [' '.ljust(indent) + "- " + f for f in file_list]
97+ message += "\n".join(indented_files)
98 return message
99
100-def error(message):
101- print pretty_print(message, "E: ")
102-
103-def warning(message):
104- print pretty_print(message, "W: ")
105-
106-def info(message):
107- print pretty_print(message, "I: ")
108+def error(message, file_list=[]):
109+ print pretty_print(message, "E: ", file_list)
110+
111+def warning(message, file_list=[]):
112+ print pretty_print(message, "W: ", file_list)
113+
114+def info(message, file_list=[]):
115+ print pretty_print(message, "I: ", file_list)

Subscribers

People subscribed via source and target branches