本文整理汇总了Python中linecache.clearcache方法的典型用法代码示例。如果您正苦于以下问题:Python linecache.clearcache方法的具体用法?Python linecache.clearcache怎么用?Python linecache.clearcache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linecache
的用法示例。
在下文中一共展示了linecache.clearcache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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
示例2: is_first_line_documented
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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
示例3: clear_trace_filter_cache
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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
示例4: _group_references_by_file
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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
示例5: __init__
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
def __init__(self,
intervals_file,
fasta_file,
dnase_file,
mappability_file=None,
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
# mappability
if mappability_file is None:
# download the mappability file if not existing
common_dl_dir = os.path.join(this_dir, "../../template/downloaded/dataloader_files")
makedir_exist_ok(common_dl_dir)
rf = RemoteFile(url="http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeMapability/wgEncodeDukeMapabilityUniqueness35bp.bigWig",
md5="1d15ddafe2c8df51cf08495db96679e7")
mappability_file = os.path.join(common_dl_dir, "wgEncodeDukeMapabilityUniqueness35bp.bigWig")
if not os.path.exists(mappability_file) or not rf.validate(mappability_file):
# download the path
rf.get_file(mappability_file)
self.mappability_file = mappability_file
self.mappability_extractor = None
示例6: load_module
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
def load_module(self, fullname):
if self.mod is None:
self.mod = mod = imp.new_module(fullname)
else:
mod = self.mod
mod.__file__ = '<%s>' % self.name
mod.__loader__ = self
mod.__project__ = self.project
mod.__package__ = ''
code = self.get_code(fullname)
six.exec_(code, mod.__dict__)
linecache.clearcache()
if sys.version_info[:2] == (3, 3):
sys.modules[fullname] = mod
return mod
示例7: generate
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
def generate(self, **kwargs):
"""用给定参数生成此模板."""
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()
示例8: __BuildFromException
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
def __BuildFromException(self, site, type , value, tb):
if debugging:
import linecache
linecache.clearcache()
try:
if issubclass(type, SyntaxError):
self._BuildFromSyntaxError(site, value, tb)
else:
self._BuildFromOther(site, type, value, tb)
except: # Error extracting traceback info!!!
traceback.print_exc()
# re-raise.
raise
示例9: GetActiveFileName
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
def GetActiveFileName(bAutoSave = 1):
"""Gets the file name for the active frame, saving it if necessary.
Returns None if it cant be found, or raises KeyboardInterrupt.
"""
pathName = None
active = GetActiveView()
if active is None:
return None
try:
doc = active.GetDocument()
pathName = doc.GetPathName()
if bAutoSave and \
(len(pathName)>0 or \
doc.GetTitle()[:8]=="Untitled" or \
doc.GetTitle()[:6]=="Script"): # if not a special purpose window
if doc.IsModified():
try:
doc.OnSaveDocument(pathName)
pathName = doc.GetPathName()
# clear the linecache buffer
linecache.clearcache()
except win32ui.error:
raise KeyboardInterrupt
except (win32ui.error, AttributeError):
pass
if not pathName:
return None
return pathName
示例10: setUp
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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)
示例11: test_clearcache
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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, [])
示例12: test_memoryerror
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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)
示例13: generate
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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()
示例14: setUp
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
def setUp(self):
linecache.clearcache()
zipimport._zip_directory_cache.clear()
ImportHooksBaseTestCase.setUp(self)
示例15: generate
# 需要导入模块: import linecache [as 别名]
# 或者: from linecache import clearcache [as 别名]
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()