本文整理匯總了Python中source.Source.add_function方法的典型用法代碼示例。如果您正苦於以下問題:Python Source.add_function方法的具體用法?Python Source.add_function怎麽用?Python Source.add_function使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類source.Source
的用法示例。
在下文中一共展示了Source.add_function方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _parse
# 需要導入模塊: from source import Source [as 別名]
# 或者: from source.Source import add_function [as 別名]
def _parse(self):
funclines = {}
source = None
with open(self.filename) as f:
for line in f:
line = line.strip()
if line == 'end_of_record':
if source is not None:
directory, filename = os.path.split(source.filename)
self.sources[directory][filename] = source
source = None
else:
key, argstr = tuple(line.split(':'))
args = argstr.split(',')
if key == 'SF':
fname = args[0]
if fname.startswith(self.basepath):
source = Source(args[0])
else:
source = None
elif source is not None:
if key == 'FN':
name = args[1]
funclines[name] = int(args[0])
elif key == 'FNDA':
hits = int(args[0])
name = args[1]
func = Function(funclines[name], name, hits)
source.add_function(func)
elif key == 'BRDA':
line = int(args[0])
path = int(args[2])
hits = 0 if args[3] == '-' else int(args[3])
source.add_branch(Branch(line, path, hits))
elif key == 'DA':
line = int(args[0])
hits = int(args[1])
source.add_line(Line(line, hits))