def analyze_file(self, path, source=None): if source is None: with open(path) as f: source = f.read() split_last_lines = source.rsplit('\n', 2) if len(split_last_lines) > 1 and \ split_last_lines[-2].endswith(':') and split_last_lines[-1] == '': indent = utils.get_indentation(split_last_lines[-2]) source += '%spass;' % indent self.module_id = path if not self.cdaemon.daemon.is_alive(): completion_daemon.shutdown_daemon() del self.cdaemon self.cdaemon = completion_daemon.CompletionDaemon() # Set modules reference to model model.MODULES = self.cdaemon.modules module = self.cdaemon.get_module(self.module_id) module = self.analyzer.analyze(source, module) self.cdaemon.inspect_module(self.module_id, module)
def tearDown(self): completion_daemon.shutdown_daemon()
import _ast import time import unittest from kanzen import analyzer from kanzen import model from kanzen import code_completion from kanzen import completion_daemon from tests import ( get_source_data, SOURCE_LATE_RESOLUTION, SOURCE_INHERITANCE ) completion_daemon.shutdown_daemon() completion_daemon.WAITING_BEFORE_START = 0 class AnalyzerLateResolutionTestCase(unittest.TestCase): def setUp(self): code_completion.utils.KEYWORDS = [] self.cc = code_completion.CodeCompletion() self.analyzer = analyzer.Analyzer() def tearDown(self): completion_daemon.shutdown_daemon() ############################################################################### # For Python Imports