def extract_version(path):
<EOL>_version_re = re.compile(r'<STR_LIT>')<EOL>with open(path + '<STR_LIT>', '<STR_LIT:r>', encoding='<STR_LIT:utf-8>') as f:<EOL><INDENT>version = f.read()<EOL><DEDENT>if version:<EOL><INDENT>version = _version_re.search(version)<EOL>if version:<EOL><INDENT>version = version.group(<NUM_LIT:1>)<EOL>version = str(ast.literal_eval(version.rstrip()))<EOL>extracted = version<EOL><DEDENT>else:<EOL><INDENT>extracted = None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>extracted = None<EOL><DEDENT>return extracted<EOL>
Reads the file at the specified path and returns the version contained in it.

This is meant for reading the __init__.py file inside a package, and so it
expects a version field like:

__version__ = '1.0.0'

:param path: path to the Python file
:return: the version inside the file