launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19663
[Merge] lp:~cjwatson/launchpad/scripts-lint into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/scripts-lint into lp:launchpad.
Commit message:
Remove lots of lint from lp.scripts.
Requested reviews:
Colin Watson (cjwatson)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/scripts-lint/+merge/275702
Remove lots of lint from lp.scripts.
--
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/scripts/utilities/js/combo.py'
--- lib/lp/scripts/utilities/js/combo.py 2012-06-14 05:18:22 +0000
+++ lib/lp/scripts/utilities/js/combo.py 2015-10-26 13:22:33 +0000
@@ -68,6 +68,7 @@
C{Content-Type} header.
"""
root = os.path.abspath(root)
+
def app(environ, start_response, root=root):
fnames = parse_qs(environ["QUERY_STRING"])
content_type = "text/plain"
@@ -82,4 +83,5 @@
start_response("200 OK", [("Content-Type", content_type)])
return combine_files(fnames, root, resource_prefix,
minify_css, rewrite_urls)
+
return app
=== modified file 'lib/lp/scripts/utilities/js/tests/test_combo.py'
--- lib/lp/scripts/utilities/js/tests/test_combo.py 2014-01-30 15:04:06 +0000
+++ lib/lp/scripts/utilities/js/tests/test_combo.py 2015-10-26 13:22:33 +0000
@@ -100,23 +100,23 @@
"3.0.0/build/event-custom/event-custom-min.js"))
def test_combine_files_includes_filename(self):
- """Combining files should include their relative filename at the top."""
+ """
+ Combining files should include their relative filename at the top.
+ """
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("yui", "yui-min.js"),
- "** yui-min **"),
- self.makeSampleFile(
- test_dir,
- os.path.join("oop", "oop-min.js"),
- "** oop-min **"),
- self.makeSampleFile(
- test_dir,
- os.path.join("event-custom", "event-custom-min.js"),
- "** event-custom-min **"),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("yui", "yui-min.js"),
+ "** yui-min **")
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("oop", "oop-min.js"),
+ "** oop-min **")
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("event-custom", "event-custom-min.js"),
+ "** event-custom-min **")
expected = "\n".join(("// yui/yui-min.js",
"** yui-min **",
@@ -138,26 +138,24 @@
"""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("widget", "assets", "skins", "sam", "widget.css"),
- """\
- /* widget skin */
- .yui-widget {
- background: url("img/bg.png");
- }
- """),
- self.makeSampleFile(
- test_dir,
- os.path.join("editor", "assets", "skins", "sam", "editor.css"),
- """\
- /* editor skin */
- .yui-editor {
- background: url("img/bg.png");
- }
- """),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
+ """\
+ /* widget skin */
+ .yui-widget {
+ background: url("img/bg.png");
+ }
+ """)
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
+ """\
+ /* editor skin */
+ .yui-editor {
+ background: url("img/bg.png");
+ }
+ """)
expected = "\n".join(
("/* widget/assets/skins/sam/widget.css */",
@@ -178,26 +176,24 @@
"""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("widget", "assets", "skins", "sam", "widget.css"),
- """\
- /* widget skin */
- .yui-widget {
- background: url("/static/img/bg.png");
- }
- """),
- self.makeSampleFile(
- test_dir,
- os.path.join("editor", "assets", "skins", "sam", "editor.css"),
- """\
- /* editor skin */
- .yui-editor {
- background: url("http://foo/static/img/bg.png");
- }
- """),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
+ """\
+ /* widget skin */
+ .yui-widget {
+ background: url("/static/img/bg.png");
+ }
+ """)
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
+ """\
+ /* editor skin */
+ .yui-editor {
+ background: url("http://foo/static/img/bg.png");
+ }
+ """)
expected = "\n".join(
("/* widget/assets/skins/sam/widget.css */",
@@ -218,26 +214,24 @@
"""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("widget", "assets", "skins", "sam", "widget.css"),
- """\
- /* widget skin */
- .yui-widget {
- background: url("data:image/gif;base64,base64-data");
- }
- """),
- self.makeSampleFile(
- test_dir,
- os.path.join("editor", "assets", "skins", "sam", "editor.css"),
- """\
- /* editor skin */
- .yui-editor {
- background: url(data:image/gif;base64,base64-data);
- }
- """),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
+ """\
+ /* widget skin */
+ .yui-widget {
+ background: url("data:image/gif;base64,base64-data");
+ }
+ """)
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
+ """\
+ /* editor skin */
+ .yui-editor {
+ background: url(data:image/gif;base64,base64-data);
+ }
+ """)
expected = "\n".join(
('/* widget/assets/skins/sam/widget.css */',
@@ -258,25 +252,23 @@
"""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("widget", "assets", "skins", "sam", "widget.css"),
- "\n".join(
- ('/* widget skin */',
- '.yui-widget {',
- ' background: url("img/bg.png");',
- '}'))
- ),
- self.makeSampleFile(
- test_dir,
- os.path.join("editor", "assets", "skins", "sam", "editor.css"),
- "\n".join(('/* editor skin */',
- '.yui-editor {',
- ' background: url("img/bg.png");',
- '}'))
- ),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
+ "\n".join(
+ ('/* widget skin */',
+ '.yui-widget {',
+ ' background: url("img/bg.png");',
+ '}'))
+ )
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
+ "\n".join(('/* editor skin */',
+ '.yui-editor {',
+ ' background: url("img/bg.png");',
+ '}'))
+ )
expected = "\n".join(
("/* widget/assets/skins/sam/widget.css */",
@@ -303,26 +295,24 @@
"""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("widget", "assets", "skins", "sam", "widget.css"),
- """\
- /* widget skin */
- .yui-widget {
- background: url("img/bg.png");
- }
- """),
- self.makeSampleFile(
- test_dir,
- os.path.join("editor", "assets", "skins", "sam", "editor.css"),
- """\
- /* editor skin */
- .yui-editor {
- background: url("img/bg.png");
- }
- """),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
+ """\
+ /* widget skin */
+ .yui-widget {
+ background: url("img/bg.png");
+ }
+ """)
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
+ """\
+ /* editor skin */
+ .yui-editor {
+ background: url("img/bg.png");
+ }
+ """)
expected = "\n".join(
("/* widget/assets/skins/sam/widget.css */",
@@ -344,25 +334,23 @@
"""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("widget", "assets", "skins", "sam", "widget.css"),
- "\n".join(
- ('/* widget skin */',
- '.yui-widget {',
- ' background: url("img/bg.png");',
- '}'))
- ),
- self.makeSampleFile(
- test_dir,
- os.path.join("editor", "assets", "skins", "sam", "editor.css"),
- "\n".join(('/* editor skin */',
- '.yui-editor {',
- ' background: url("img/bg.png");',
- '}'))
- ),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
+ "\n".join(
+ ('/* widget skin */',
+ '.yui-widget {',
+ ' background: url("img/bg.png");',
+ '}'))
+ )
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
+ "\n".join(('/* editor skin */',
+ '.yui-editor {',
+ ' background: url("img/bg.png");',
+ '}'))
+ )
expected = "\n".join(
('/* widget/assets/skins/sam/widget.css */',
@@ -392,26 +380,24 @@
"""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("widget", "assets", "skins", "sam", "widget.css"),
- """\
- /* widget skin */
- .yui-widget {
- background: url("img/bg.png");
- }
- """),
- self.makeSampleFile(
- test_dir,
- os.path.join("editor", "assets", "skins", "sam", "editor.css"),
- """\
- /* editor skin */
- .yui-editor {
- background: url("img/bg.png");
- }
- """),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
+ """\
+ /* widget skin */
+ .yui-widget {
+ background: url("img/bg.png");
+ }
+ """)
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
+ """\
+ /* editor skin */
+ .yui-editor {
+ background: url("img/bg.png");
+ }
+ """)
expected = "\n".join(
("/* widget/assets/skins/sam/widget.css */",
@@ -429,19 +415,19 @@
expected)
def test_missing_file_is_ignored(self):
- """If a missing file is requested we should still combine the others."""
+ """
+ If a missing file is requested we should still combine the others.
+ """
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("yui", "yui-min.js"),
- "** yui-min **"),
- self.makeSampleFile(
- test_dir,
- os.path.join("event-custom", "event-custom-min.js"),
- "** event-custom-min **"),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("yui", "yui-min.js"),
+ "** yui-min **")
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("event-custom", "event-custom-min.js"),
+ "** event-custom-min **")
expected = "\n".join(("// yui/yui-min.js",
"** yui-min **",
@@ -459,12 +445,10 @@
def test_no_parent_hack(self):
"""If someone tries to hack going up the root, he'll get a miss."""
test_dir = self.makeDir()
- files = [
- self.makeSampleFile(
- test_dir,
- os.path.join("oop", "oop-min.js"),
- "** oop-min **"),
- ]
+ self.makeSampleFile(
+ test_dir,
+ os.path.join("oop", "oop-min.js"),
+ "** oop-min **")
root = os.path.join(test_dir, "root", "lazr")
os.makedirs(root)
@@ -494,7 +478,6 @@
"".join(combine_files(files, root=test_dir)).strip(),
expected)
-
def test_no_absolute_path_hack(self):
"""If someone tries to fetch an absolute file, he'll get nothing."""
test_dir = self.makeDir()
@@ -517,20 +500,18 @@
def test_combo_app_sets_content_type_for_js(self):
"""The WSGI App should set a proper Content-Type for Javascript."""
- files = [
- self.makeSampleFile(
- self.root,
- os.path.join("yui", "yui-min.js"),
- "** yui-min **"),
- self.makeSampleFile(
- self.root,
- os.path.join("oop", "oop-min.js"),
- "** oop-min **"),
- self.makeSampleFile(
- self.root,
- os.path.join("event-custom", "event-custom-min.js"),
- "** event-custom-min **"),
- ]
+ self.makeSampleFile(
+ self.root,
+ os.path.join("yui", "yui-min.js"),
+ "** yui-min **")
+ self.makeSampleFile(
+ self.root,
+ os.path.join("oop", "oop-min.js"),
+ "** oop-min **")
+ self.makeSampleFile(
+ self.root,
+ os.path.join("event-custom", "event-custom-min.js"),
+ "** event-custom-min **")
expected = "\n".join(("// yui/yui-min.js",
"** yui-min **",
@@ -548,12 +529,10 @@
def test_combo_app_sets_content_type_for_css(self):
"""The WSGI App should set a proper Content-Type for CSS."""
- files = [
- self.makeSampleFile(
- self.root,
- os.path.join("widget", "skin", "sam", "widget.css"),
- "/* widget-skin-sam */"),
- ]
+ self.makeSampleFile(
+ self.root,
+ os.path.join("widget", "skin", "sam", "widget.css"),
+ "/* widget-skin-sam */")
expected = "/* widget/skin/sam/widget.css */"
@@ -567,4 +546,3 @@
res = self.app.get("/", status=404)
self.assertEquals(res.headers, [("Content-Type", "text/plain")])
self.assertEquals(res.body, "Not Found")
-
=== modified file 'lib/lp/scripts/utilities/killservice.py'
--- lib/lp/scripts/utilities/killservice.py 2013-01-07 02:40:55 +0000
+++ lib/lp/scripts/utilities/killservice.py 2015-10-26 13:22:33 +0000
@@ -40,7 +40,7 @@
if len(args) < 1:
parser.error('No service name provided')
- pids = [] # List of pids we tried to kill.
+ pids = [] # List of pids we tried to kill.
services = args[:]
# Mailman is special, but only stop it if it was launched.
@@ -125,7 +125,7 @@
"""
wait_start = time.time()
while len(pids) > 0 and time.time() < wait_start + wait:
- for service, pid in pids[:]: # Copy pids because we mutate it.
+ for service, pid in pids[:]: # Copy pids because we mutate it.
if not process_exists(pid):
pids.remove((service, pid))
time.sleep(0.1)
=== modified file 'lib/lp/scripts/utilities/settingsauditor.py'
--- lib/lp/scripts/utilities/settingsauditor.py 2011-04-27 18:39:56 +0000
+++ lib/lp/scripts/utilities/settingsauditor.py 2015-10-26 13:22:33 +0000
@@ -19,9 +19,9 @@
We can't just use ConfigParser for this case, as we're doing our own
specialized parsing--not interpreting the settings, but verifying."""
- header_regex = re.compile(r'.*?(?=\[)', re.MULTILINE|re.DOTALL)
+ header_regex = re.compile(r'.*?(?=\[)', re.MULTILINE | re.DOTALL)
section_regex = re.compile(
- r'\[.*?\].*?(?=(\[)|($\Z))', re.MULTILINE|re.DOTALL)
+ r'\[.*?\].*?(?=(\[)|($\Z))', re.MULTILINE | re.DOTALL)
section_label_regex = re.compile(r'\[.*\]')
def __init__(self, data):
=== modified file 'lib/lp/scripts/utilities/tests/test_audit_security_settings.py'
--- lib/lp/scripts/utilities/tests/test_audit_security_settings.py 2012-01-01 02:58:52 +0000
+++ lib/lp/scripts/utilities/tests/test_audit_security_settings.py 2015-10-26 13:22:33 +0000
@@ -90,5 +90,3 @@
'#public.foo = SELECT\n')
data = sa._strip(test_data)
self.assertEqual('', data)
-
-
=== modified file 'lib/lp/scripts/utilities/warninghandler.py'
--- lib/lp/scripts/utilities/warninghandler.py 2013-04-10 09:36:25 +0000
+++ lib/lp/scripts/utilities/warninghandler.py 2015-10-26 13:22:33 +0000
@@ -25,6 +25,7 @@
else:
return self.message
+
class ImportantInfo:
def __init__(self, expressiontext, viewclassname, templatefilename,
@@ -75,6 +76,7 @@
from zope.browserpage.simpleviewclass import simple
+
def find_important_info():
stack = inspect.stack()
try:
@@ -155,6 +157,8 @@
other_warnings = {}
old_show_warning = warnings.showwarning
+
+
def launchpad_showwarning(message, category, filename, lineno, file=None,
line=None):
if file is None:
@@ -183,6 +187,7 @@
other_warnings[(category, filename, lineno)] = WarningReport(
warning_message, important_info)
+
def report_need_page_titles():
global need_page_titles
if need_page_titles:
@@ -191,6 +196,7 @@
for message in need_page_titles:
print " ", message
+
def report_no_order_by():
global no_order_by
if no_order_by:
@@ -201,6 +207,7 @@
print
print report
+
def report_other_warnings():
global other_warnings
if other_warnings:
@@ -210,11 +217,13 @@
print
print warninginfo
+
def report_warnings():
report_need_page_titles()
report_no_order_by()
report_other_warnings()
+
def install_warning_handler():
warnings.showwarning = launchpad_showwarning
atexit.register(report_warnings)
References