/usr/lib/python2.7/dist-packages/pyvows/runner/utils.py is in python-pyvows 2.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | # -*- coding: utf-8 -*-
'''Utility functions for all implementations of pyvows.runner.
'''
import os.path as path
#-------------------------------------------------------------------------------------------------
def get_code_for(obj):
# FIXME: Add Comment description
code = None
if hasattr(obj, '__code__'):
code = obj.__code__
elif hasattr(obj, '__func__'):
code = obj.__func__.__code__
return code
def get_file_info_for(member):
# FIXME: Add Docstring
code = get_code_for(member)
filename = code.co_filename
lineno = code.co_firstlineno
return filename, lineno
def get_topics_for(topic_function, ctx_obj):
# FIXME: Add Docstring
if not ctx_obj.parent:
return []
# check for decorated topic function
if hasattr(topic_function, '_original'):
# _wrapper_type is 'async_topic' or 'capture_error'
async = (getattr(topic_function, '_wrapper_type', None) == 'async_topic')
topic_function = topic_function._original
else:
async = False
code = get_code_for(topic_function)
if not code:
raise RuntimeError(
'Function %s does not have a code property' % topic_function)
expected_args = code.co_argcount - 1
# taking the callback argument into consideration
if async:
expected_args -= 1
# prepare to create `topics` list
topics = []
child = ctx_obj
context = ctx_obj.parent
# populate `topics` list
for i in range(expected_args):
topic = context.topic_value
if context.generated_topic:
topic = topic[child.index]
topics.append(topic)
if not context.parent:
break
context = context.parent
child = child.parent
return topics
|