/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

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