/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/brzflakes.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
2
 
 
3
 
from __future__ import absolute_import
4
 
 
5
 
import ast
6
 
 
7
 
from pyflakes.checker import Checker, ImportationFrom
8
 
 
9
 
# Do some monkey patching..
10
 
def CALL(self, node):
11
 
    if isinstance(node.func, ast.Name) and node.func.id == 'lazy_import':
12
 
        self.LAZY_IMPORT(node)
13
 
    elif (isinstance(node.func, ast.Attribute) and
14
 
            node.func.attr == 'lazy_import' and
15
 
            node.func.value.id == 'lazy_import'):
16
 
        self.LAZY_IMPORT(node)
17
 
    return self.handleChildren(node)
18
 
 
19
 
Checker.CALL = CALL
20
 
 
21
 
def LAZY_IMPORT(self, node):
22
 
    from breezy.lazy_import import ImportProcessor
23
 
    processor = ImportProcessor()
24
 
    if not isinstance(node.args[1], ast.Str):
25
 
        # Not sure how to deal with this..
26
 
        return
27
 
    import_text = node.args[1].s
28
 
    scope = {}
29
 
    processor.lazy_import(scope, import_text)
30
 
    for name, (path, sub, scope) in processor.imports.items():
31
 
        importation = ImportationFrom(name, node, '.'.join(path), scope)
32
 
        self.addBinding(node, importation)
33
 
 
34
 
Checker.LAZY_IMPORT = LAZY_IMPORT
35
 
 
36
 
 
37
 
if __name__ == '__main__':
38
 
    from pyflakes import __main__
39
 
    __main__.main()