# Path: supplement/fixer.py
# def fix(code, tries=10):
#     try:
#         return ast.parse(code), code
#     except Exception, e:
#         tries -= 1
#         if tries <= 0:
#             raise
# 
#         code, fixed_location = try_to_fix(e, code)
#         if fixed_location:
#             return fix(code, tries)
#         else:
#             raise


import ast
from .fixer import fix


UNSUPPORTED_ASSIGNMENTS = ast.Subscript, ast.Attribute


class AstProvider(object):
    def __init__(self):
        self.cache = {}

    def get(self, module):
        try:
            return self.cache[module.name]
        except KeyError:
            pass

        source = module.get_source()
        if source:
            tree, _ = fix(source)
        else:
            tree = None


# Path: supplement/fixer.py
# def fix(code, tries=10):
#     try:
#         return ast.parse(code), code
#     except Exception, e:
#         tries -= 1
#         if tries <= 0:
#             raise
# 
#         code, fixed_location = try_to_fix(e, code)
#         if fixed_location:
#             return fix(code, tries)
#         else:
#             raise


# Path: supplement/tree.py
import ast
from .fixer import fix



UNSUPPORTED_ASSIGNMENTS = ast.Subscript, ast.Attribute


class AstProvider(object):
    def __init__(self):
        self.cache = {}

    def get(self, module):
        try:
            return self.cache[module.name]
        except KeyError:
            pass

        source = module.get_source()
        if source:
            tree, _ = fix(source)
        else:
            tree = None


        self.cache[module.name] = tree