Python linecache.clearcache() Examples
The following are 30
code examples of linecache.clearcache().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
linecache
, or try the search function
.
Example #1
Source File: references.py From LSP with MIT License | 6 votes |
def _group_references_by_file(self, references: List[ReferenceDict] ) -> Dict[str, List[Tuple[Point, str]]]: """ Return a dictionary that groups references by the file it belongs. """ grouped_references = {} # type: Dict[str, List[Tuple[Point, str]]] for reference in references: file_path = uri_to_filename(reference["uri"]) point = Point.from_lsp(reference['range']['start']) # get line of the reference, to showcase its use reference_line = get_line(self.view.window(), file_path, point.row) if grouped_references.get(file_path) is None: grouped_references[file_path] = [] grouped_references[file_path].append((point, reference_line)) # we don't want to cache the line, we always want to get fresh data linecache.clearcache() return grouped_references
Example #2
Source File: dataloader.py From models with MIT License | 6 votes |
def __init__(self, intervals_file, fasta_file, dnase_file, use_linecache=True): # intervals if use_linecache: linecache.clearcache() BT = BedToolLinecache else: BT = BedTool self.bt = BT(intervals_file) # Fasta self.fasta_file = fasta_file self.fasta_extractor = None # initialize later # DNase self.dnase_file = dnase_file self.dnase_extractor = None
Example #3
Source File: dataloader.py From models with MIT License | 6 votes |
def __init__(self, intervals_file, fasta_file, dnase_file, use_linecache=True): # intervals if use_linecache: linecache.clearcache() BT = BedToolLinecache else: BT = BedTool self.bt = BT(intervals_file) # Fasta self.fasta_file = fasta_file self.fasta_extractor = None # initialize later # DNase self.dnase_file = dnase_file self.dnase_extractor = None
Example #4
Source File: dataloader.py From models with MIT License | 6 votes |
def __init__(self, intervals_file, fasta_file, dnase_file, use_linecache=True): # intervals if use_linecache: linecache.clearcache() BT = BedToolLinecache else: BT = BedTool self.bt = BT(intervals_file) # Fasta self.fasta_file = fasta_file self.fasta_extractor = None # initialize later # DNase self.dnase_file = dnase_file self.dnase_extractor = None
Example #5
Source File: dataloader.py From models with MIT License | 6 votes |
def __init__(self, intervals_file, fasta_file, dnase_file, use_linecache=True): # intervals if use_linecache: linecache.clearcache() BT = BedToolLinecache else: BT = BedTool self.bt = BT(intervals_file) # Fasta self.fasta_file = fasta_file self.fasta_extractor = None # initialize later # DNase self.dnase_file = dnase_file self.dnase_extractor = None
Example #6
Source File: methods.py From dyc with MIT License | 6 votes |
def is_first_line_documented(self, result): """ A boolean function that determines weather the first line has a docstring or not Parameters ---------- MethodInterface result: Is a method interface class that could be subject to be taking a docstring str line: The line of the found method """ returned = False for x in range(result.start, result.end): line = linecache.getline(result.filename, x) if self.config.get("open") in line: returned = True break linecache.clearcache() return returned
Example #7
Source File: dataloader.py From models with MIT License | 6 votes |
def __init__(self, intervals_file, fasta_file, dnase_file, use_linecache=True): # intervals if use_linecache: linecache.clearcache() BT = BedToolLinecache else: BT = BedTool self.bt = BT(intervals_file) # Fasta self.fasta_file = fasta_file self.fasta_extractor = None # initialize later # DNase self.dnase_file = dnase_file self.dnase_extractor = None
Example #8
Source File: dataloader.py From models with MIT License | 6 votes |
def __init__(self, intervals_file, fasta_file, dnase_file, use_linecache=True): # intervals if use_linecache: linecache.clearcache() BT = BedToolLinecache else: BT = BedTool self.bt = BT(intervals_file) # Fasta self.fasta_file = fasta_file self.fasta_extractor = None # initialize later # DNase self.dnase_file = dnase_file self.dnase_extractor = None
Example #9
Source File: pydevd_dont_trace.py From PyDev.Debugger with Eclipse Public License 1.0 | 6 votes |
def clear_trace_filter_cache(): ''' Clear the trace filter cache. Call this after reloading. ''' global should_trace_hook try: # Need to temporarily disable a hook because otherwise # _filename_to_ignored_lines.clear() will never complete. old_hook = should_trace_hook should_trace_hook = None # Clear the linecache linecache.clearcache() _filename_to_ignored_lines.clear() finally: should_trace_hook = old_hook
Example #10
Source File: test_linecache.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_clearcache(self): cached = [] for entry in TESTS: filename = os.path.join(TEST_PATH, entry) + '.py' cached.append(filename) linecache.getline(filename, 1) # Are all files cached? cached_empty = [fn for fn in cached if fn not in linecache.cache] self.assertEqual(cached_empty, []) # Can we clear the cache? linecache.clearcache() cached_empty = [fn for fn in cached if fn in linecache.cache] self.assertEqual(cached_empty, [])
Example #11
Source File: test_zipimport_support.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): linecache.clearcache() zipimport._zip_directory_cache.clear() ImportHooksBaseTestCase.setUp(self)
Example #12
Source File: test_linecache.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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))
Example #13
Source File: test_traceback.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)
Example #14
Source File: test_zipimport_support.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def setUp(self): linecache.clearcache() zipimport._zip_directory_cache.clear() self.path = sys.path[:] self.meta_path = sys.meta_path[:] self.path_hooks = sys.path_hooks[:] sys.path_importer_cache.clear()
Example #15
Source File: test_zipimport.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def setUp(self): # We're reusing the zip archive path, so we must clear the # cached directory info and linecache. linecache.clearcache() zipimport._zip_directory_cache.clear() ImportHooksBaseTestCase.setUp(self)
Example #16
Source File: test_linecache.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_memoryerror(self): lines = linecache.getlines(FILENAME) self.assertTrue(lines) def raise_memoryerror(*args, **kwargs): raise MemoryError with support.swap_attr(linecache, 'updatecache', raise_memoryerror): lines2 = linecache.getlines(FILENAME) self.assertEqual(lines2, lines) linecache.clearcache() with support.swap_attr(linecache, 'updatecache', raise_memoryerror): lines3 = linecache.getlines(FILENAME) self.assertEqual(lines3, []) self.assertEqual(linecache.getlines(FILENAME), lines)
Example #17
Source File: test_linecache.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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))
Example #18
Source File: test_linecache.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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]))
Example #19
Source File: test_linecache.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_clearcache(self): cached = [] for entry in TESTS: filename = os.path.join(TEST_PATH, entry) + '.py' cached.append(filename) linecache.getline(filename, 1) # Are all files cached? cached_empty = [fn for fn in cached if fn not in linecache.cache] self.assertEqual(cached_empty, []) # Can we clear the cache? linecache.clearcache() cached_empty = [fn for fn in cached if fn in linecache.cache] self.assertEqual(cached_empty, [])
Example #20
Source File: test_linecache.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_lazycache_bad_filename(self): linecache.clearcache() self.assertEqual(False, linecache.lazycache('', globals())) self.assertEqual(False, linecache.lazycache('<foo>', globals()))
Example #21
Source File: test_linecache.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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))
Example #22
Source File: test_zipimport_support.py From oss-ftp with MIT License | 5 votes |
def setUp(self): linecache.clearcache() zipimport._zip_directory_cache.clear() ImportHooksBaseTestCase.setUp(self)
Example #23
Source File: test_linecache.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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))
Example #24
Source File: test_linecache.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_clearcache(self): cached = [] for entry in TESTS: filename = os.path.join(TEST_PATH, entry) + '.py' cached.append(filename) linecache.getline(filename, 1) # Are all files cached? cached_empty = [fn for fn in cached if fn not in linecache.cache] self.assertEqual(cached_empty, []) # Can we clear the cache? linecache.clearcache() cached_empty = [fn for fn in cached if fn in linecache.cache] self.assertEqual(cached_empty, [])
Example #25
Source File: test_zipimport.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def setUp(self): # We're reusing the zip archive path, so we must clear the # cached directory info and linecache linecache.clearcache() zipimport._zip_directory_cache.clear() ImportHooksBaseTestCase.setUp(self)
Example #26
Source File: template.py From QMusic with GNU Lesser General Public License v2.1 | 5 votes |
def generate(self, **kwargs): """Generate this template with the given arguments.""" namespace = { "escape": escape.xhtml_escape, "xhtml_escape": escape.xhtml_escape, "url_escape": escape.url_escape, "json_encode": escape.json_encode, "squeeze": escape.squeeze, "linkify": escape.linkify, "datetime": datetime, "_tt_utf8": escape.utf8, # for internal use "_tt_string_types": (unicode_type, bytes), # __name__ and __loader__ allow the traceback mechanism to find # the generated source code. "__name__": self.name.replace('.', '_'), "__loader__": ObjectDict(get_source=lambda name: self.code), } namespace.update(self.namespace) namespace.update(kwargs) exec_in(self.compiled, namespace) execute = namespace["_tt_execute"] # Clear the traceback module's cache of source data now that # we've generated a new template (mainly for this module's # unittests, where different tests reuse the same name). linecache.clearcache() return execute()
Example #27
Source File: template.py From teleport with Apache License 2.0 | 5 votes |
def generate(self, **kwargs: Any) -> bytes: """Generate this template with the given arguments.""" namespace = { "escape": escape.xhtml_escape, "xhtml_escape": escape.xhtml_escape, "url_escape": escape.url_escape, "json_encode": escape.json_encode, "squeeze": escape.squeeze, "linkify": escape.linkify, "datetime": datetime, "_tt_utf8": escape.utf8, # for internal use "_tt_string_types": (unicode_type, bytes), # __name__ and __loader__ allow the traceback mechanism to find # the generated source code. "__name__": self.name.replace(".", "_"), "__loader__": ObjectDict(get_source=lambda name: self.code), } namespace.update(self.namespace) namespace.update(kwargs) exec_in(self.compiled, namespace) execute = typing.cast(Callable[[], bytes], namespace["_tt_execute"]) # Clear the traceback module's cache of source data now that # we've generated a new template (mainly for this module's # unittests, where different tests reuse the same name). linecache.clearcache() return execute()
Example #28
Source File: template.py From teleport with Apache License 2.0 | 5 votes |
def generate(self, **kwargs: Any) -> bytes: """Generate this template with the given arguments.""" namespace = { "escape": escape.xhtml_escape, "xhtml_escape": escape.xhtml_escape, "url_escape": escape.url_escape, "json_encode": escape.json_encode, "squeeze": escape.squeeze, "linkify": escape.linkify, "datetime": datetime, "_tt_utf8": escape.utf8, # for internal use "_tt_string_types": (unicode_type, bytes), # __name__ and __loader__ allow the traceback mechanism to find # the generated source code. "__name__": self.name.replace(".", "_"), "__loader__": ObjectDict(get_source=lambda name: self.code), } namespace.update(self.namespace) namespace.update(kwargs) exec_in(self.compiled, namespace) execute = typing.cast(Callable[[], bytes], namespace["_tt_execute"]) # Clear the traceback module's cache of source data now that # we've generated a new template (mainly for this module's # unittests, where different tests reuse the same name). linecache.clearcache() return execute()
Example #29
Source File: template.py From teleport with Apache License 2.0 | 5 votes |
def generate(self, **kwargs): """Generate this template with the given arguments.""" namespace = { "escape": escape.xhtml_escape, "xhtml_escape": escape.xhtml_escape, "url_escape": escape.url_escape, "json_encode": escape.json_encode, "squeeze": escape.squeeze, "linkify": escape.linkify, "datetime": datetime, "_tt_utf8": escape.utf8, # for internal use "_tt_string_types": (unicode_type, bytes), # __name__ and __loader__ allow the traceback mechanism to find # the generated source code. "__name__": self.name.replace('.', '_'), "__loader__": ObjectDict(get_source=lambda name: self.code), } namespace.update(self.namespace) namespace.update(kwargs) exec_in(self.compiled, namespace) execute = namespace["_tt_execute"] # Clear the traceback module's cache of source data now that # we've generated a new template (mainly for this module's # unittests, where different tests reuse the same name). linecache.clearcache() return execute()
Example #30
Source File: template.py From viewfinder with Apache License 2.0 | 5 votes |
def generate(self, **kwargs): """Generate this template with the given arguments.""" namespace = { "escape": escape.xhtml_escape, "xhtml_escape": escape.xhtml_escape, "url_escape": escape.url_escape, "json_encode": escape.json_encode, "squeeze": escape.squeeze, "linkify": escape.linkify, "datetime": datetime, "_tt_utf8": escape.utf8, # for internal use "_tt_string_types": (unicode_type, bytes_type), # __name__ and __loader__ allow the traceback mechanism to find # the generated source code. "__name__": self.name.replace('.', '_'), "__loader__": ObjectDict(get_source=lambda name: self.code), } namespace.update(self.namespace) namespace.update(kwargs) exec_in(self.compiled, namespace) execute = namespace["_tt_execute"] # Clear the traceback module's cache of source data now that # we've generated a new template (mainly for this module's # unittests, where different tests reuse the same name). linecache.clearcache() return execute()