當前位置: 首頁>>代碼示例>>Python>>正文


Python linecache.lazycache方法代碼示例

本文整理匯總了Python中linecache.lazycache方法的典型用法代碼示例。如果您正苦於以下問題:Python linecache.lazycache方法的具體用法?Python linecache.lazycache怎麽用?Python linecache.lazycache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在linecache的用法示例。


在下文中一共展示了linecache.lazycache方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_lazycache_no_globals

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_lazycache_no_globals(self):
        lines = linecache.getlines(FILENAME)
        linecache.clearcache()
        self.assertEqual(False, linecache.lazycache(FILENAME, None))
        self.assertEqual(lines, linecache.getlines(FILENAME)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:7,代碼來源:test_linecache.py

示例2: test_lazycache_smoke

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_lazycache_smoke(self):
        lines = linecache.getlines(NONEXISTENT_FILENAME, globals())
        linecache.clearcache()
        self.assertEqual(
            True, linecache.lazycache(NONEXISTENT_FILENAME, globals()))
        self.assertEqual(1, len(linecache.cache[NONEXISTENT_FILENAME]))
        # Note here that we're looking up a non existant filename with no
        # globals: this would error if the lazy value wasn't resolved.
        self.assertEqual(lines, linecache.getlines(NONEXISTENT_FILENAME)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:test_linecache.py

示例3: test_lazycache_provide_after_failed_lookup

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_lazycache_provide_after_failed_lookup(self):
        linecache.clearcache()
        lines = linecache.getlines(NONEXISTENT_FILENAME, globals())
        linecache.clearcache()
        linecache.getlines(NONEXISTENT_FILENAME)
        linecache.lazycache(NONEXISTENT_FILENAME, globals())
        self.assertEqual(lines, linecache.updatecache(NONEXISTENT_FILENAME)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:test_linecache.py

示例4: test_lazycache_check

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_lazycache_check(self):
        linecache.clearcache()
        linecache.lazycache(NONEXISTENT_FILENAME, globals())
        linecache.checkcache() 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:test_linecache.py

示例5: test_lazycache_already_cached

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_lazycache_already_cached(self):
        linecache.clearcache()
        lines = linecache.getlines(NONEXISTENT_FILENAME, globals())
        self.assertEqual(
            False,
            linecache.lazycache(NONEXISTENT_FILENAME, globals()))
        self.assertEqual(4, len(linecache.cache[NONEXISTENT_FILENAME])) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:test_linecache.py

示例6: test_basics

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_basics(self):
        linecache.clearcache()
        linecache.lazycache("f", globals())
        f = traceback.FrameSummary("f", 1, "dummy")
        self.assertEqual(f,
            ("f", 1, "dummy", '"""Test cases for traceback module"""'))
        self.assertEqual(tuple(f),
            ("f", 1, "dummy", '"""Test cases for traceback module"""'))
        self.assertEqual(f, traceback.FrameSummary("f", 1, "dummy"))
        self.assertEqual(f, tuple(f))
        # Since tuple.__eq__ doesn't support FrameSummary, the equality
        # operator fallbacks to FrameSummary.__eq__.
        self.assertEqual(tuple(f), f)
        self.assertIsNone(f.locals) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:16,代碼來源:test_traceback.py

示例7: test_lazy_lines

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_lazy_lines(self):
        linecache.clearcache()
        f = traceback.FrameSummary("f", 1, "dummy", lookup_line=False)
        self.assertEqual(None, f._line)
        linecache.lazycache("f", globals())
        self.assertEqual(
            '"""Test cases for traceback module"""',
            f.line) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:test_traceback.py

示例8: lazycache

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def lazycache(cls, frame):
        if hasattr(linecache, 'lazycache'):
            linecache.lazycache(frame.f_code.co_filename, frame.f_globals) 
開發者ID:alexmojaki,項目名稱:executing,代碼行數:5,代碼來源:executing.py

示例9: run_cell

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def run_cell(self, code, name):
        linecache.lazycache(
            name, {
                '__name__': name, '__loader__': self.loader})

        exec_result = ExecutionResult()

        with CapturedIOCtx(exec_result.capture_io), CapturedDisplayCtx(exec_result.displayhook):
            code_ast = ast.parse(code, filename=name, mode='exec')
            run_failed, output_name = self._run_ast_nodes(code_ast.body, name)

            exec_result.has_exception = run_failed
            exec_result.target_id = output_name

        return exec_result 
開發者ID:jupytercalpoly,項目名稱:reactivepy,代碼行數:17,代碼來源:execute.py

示例10: test_lazycache_smoke

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def test_lazycache_smoke(self):
        lines = linecache.getlines(NONEXISTENT_FILENAME, globals())
        linecache.clearcache()
        self.assertEqual(
            True, linecache.lazycache(NONEXISTENT_FILENAME, globals()))
        self.assertEqual(1, len(linecache.cache[NONEXISTENT_FILENAME]))
        # Note here that we're looking up a nonexistent filename with no
        # globals: this would error if the lazy value wasn't resolved.
        self.assertEqual(lines, linecache.getlines(NONEXISTENT_FILENAME)) 
開發者ID:ShikyoKira,項目名稱:Project-New-Reign---Nemesis-Main,代碼行數:11,代碼來源:test_linecache.py

示例11: extract

# 需要導入模塊: import linecache [as 別名]
# 或者: from linecache import lazycache [as 別名]
def extract(klass, frame_gen, *, limit=None, lookup_lines=True,
            capture_locals=False):
        """Create a StackSummary from a traceback or stack object.

        :param frame_gen: A generator that yields (frame, lineno) tuples to
            include in the stack.
        :param limit: None to include all frames or the number of frames to
            include.
        :param lookup_lines: If True, lookup lines for each frame immediately,
            otherwise lookup is deferred until the frame is rendered.
        :param capture_locals: If True, the local variables from each frame will
            be captured as object representations into the FrameSummary.
        """
        if limit is None:
            limit = getattr(sys, 'tracebacklimit', None)
            if limit is not None and limit < 0:
                limit = 0
        if limit is not None:
            if limit >= 0:
                frame_gen = itertools.islice(frame_gen, limit)
            else:
                frame_gen = collections.deque(frame_gen, maxlen=-limit)

        result = klass()
        fnames = set()
        for f, lineno in frame_gen:
            co = f.f_code
            filename = co.co_filename
            name = co.co_name

            fnames.add(filename)
            linecache.lazycache(filename, f.f_globals)
            # Must defer line lookups until we have called checkcache.
            if capture_locals:
                f_locals = f.f_locals
            else:
                f_locals = None
            result.append(FrameSummary(
                filename, lineno, name, lookup_line=False, locals=f_locals))
        for filename in fnames:
            linecache.checkcache(filename)
        # If immediate lookup was desired, trigger lookups now.
        if lookup_lines:
            for f in result:
                f.line
        return result 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:48,代碼來源:traceback.py


注:本文中的linecache.lazycache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。