def linkcode_resolve(domain, info):
module_name = info['<STR_LIT>']<EOL>fullname = info['<STR_LIT>']<EOL>attribute_name = fullname.split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL>base_url = '<STR_LIT>'<EOL>if release.endswith('<STR_LIT>'):<EOL><INDENT>base_url += '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>base_url += version + '<STR_LIT:/>'<EOL><DEDENT>filename = module_name.replace('<STR_LIT:.>', '<STR_LIT:/>') + '<STR_LIT>'<EOL>module = sys.modules.get(module_name)<EOL>try:<EOL><INDENT>actual_object = module<EOL>for obj in fullname.split('<STR_LIT:.>'):<EOL><INDENT>parent = actual_object<EOL>actual_object = getattr(actual_object, obj)<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>return None<EOL><DEDENT>if isinstance(actual_object, property):<EOL><INDENT>actual_object = actual_object.fget<EOL><DEDENT>try:<EOL><INDENT>source, start_line = inspect.getsourcelines(actual_object)<EOL><DEDENT>except TypeError:<EOL><INDENT>parent_source, parent_start_line = inspect.getsourcelines(parent)<EOL>for i, line in enumerate(parent_source):<EOL><INDENT>if line.strip().startswith(attribute_name):<EOL><INDENT>start_line = parent_start_line + i<EOL>end_line = start_line<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>end_line = start_line + len(source) - <NUM_LIT:1><EOL><DEDENT>line_anchor = '<STR_LIT>' % (start_line, end_line)<EOL>return base_url + filename + line_anchor<EOL>
A simple function to find matching source code.