~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to tools/hacking.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
    # convert "from x import y" to "import x.y"
106
106
    # handle "from x import y as z" to "import x.y as z"
107
107
    split_line = line.split()
108
 
    if (line.startswith("from ") and "," not in line and
 
108
    if ("import" in line and line.startswith("from ") and "," not in line and
109
109
           split_line[2] == "import" and split_line[3] != "*" and
110
110
           split_line[1] != "__future__" and
111
111
           (len(split_line) == 4 or
137
137
    N201
138
138
    """
139
139
    if logical_line.startswith("except:"):
140
 
        return 6, "NOVA N201: no 'except:' at least use 'except Exception:'"
 
140
        yield 6, "NOVA N201: no 'except:' at least use 'except Exception:'"
141
141
 
142
142
 
143
143
def nova_except_format_assert(logical_line):
148
148
    N202
149
149
    """
150
150
    if logical_line.startswith("self.assertRaises(Exception"):
151
 
        return 1, "NOVA N202: assertRaises Exception too broad"
 
151
        yield 1, "NOVA N202: assertRaises Exception too broad"
152
152
 
153
153
 
154
154
def nova_one_import_per_line(logical_line):
166
166
    if (pos > -1 and (parts[0] == "import" or
167
167
                      parts[0] == "from" and parts[2] == "import") and
168
168
        not is_import_exception(parts[1])):
169
 
        return pos, "NOVA N301: one import per line"
 
169
        yield pos, "NOVA N301: one import per line"
170
170
 
171
171
_missingImport = set([])
172
172
 
241
241
            (len(split_line) == 2 or
242
242
            (len(split_line) == 4 and split_line[2] == "as"))):
243
243
        mod = split_line[1]
244
 
        return importModuleCheck(mod)
 
244
        rval = importModuleCheck(mod)
 
245
        if rval != None:
 
246
            yield rval
245
247
 
246
248
    # TODO(jogo) handle "from x import *"
247
249
 
248
250
#TODO(jogo): import template: N305
249
251
 
250
252
 
251
 
def nova_import_alphabetical(physical_line, line_number, lines):
 
253
def nova_import_alphabetical(logical_line, line_number, lines):
252
254
    """Check for imports in alphabetical order.
253
255
 
254
256
    nova HACKING guide recommendation for imports:
257
259
    """
258
260
    # handle import x
259
261
    # use .lower since capitalization shouldn't dictate order
260
 
    split_line = import_normalize(physical_line.strip()).lower().split()
 
262
    split_line = import_normalize(logical_line.strip()).lower().split()
261
263
    split_previous = import_normalize(lines[line_number - 2]
262
264
            ).strip().lower().split()
263
265
    # with or without "as y"
265
267
    if (len(split_line) in length and len(split_previous) in length and
266
268
        split_line[0] == "import" and split_previous[0] == "import"):
267
269
        if split_line[1] < split_previous[1]:
268
 
            return (0, "NOVA N306: imports not in alphabetical order (%s, %s)"
 
270
            yield (0, "NOVA N306: imports not in alphabetical order (%s, %s)"
269
271
                % (split_previous[1], split_line[1]))
270
272
 
271
273
 
 
274
def nova_import_no_db_in_virt(logical_line, filename):
 
275
    if ("nova/virt" in filename and
 
276
        not filename.endswith("fake.py") and
 
277
        "nova import db" in logical_line):
 
278
        yield (0, "NOVA N307: nova.db import not allowed in nova/virt/*")
 
279
 
 
280
 
272
281
def nova_docstring_start_space(physical_line):
273
282
    """Check for docstring not start with space.
274
283
 
306
315
    """
307
316
    pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE])  # start
308
317
    if (pos != -1 and len(physical_line) == pos):
309
 
        print physical_line
310
318
        if (physical_line[pos + 3] == ' '):
311
319
            return (pos, "NOVA N403: multi line docstring end on new line")
312
320
 
398
406
        map(gen.send, tokens)
399
407
        gen.close()
400
408
    except LocalizationError as e:
401
 
        return e.args
 
409
        yield e.args
402
410
 
403
411
#TODO(jogo) Dict and list objects
404
412