def get_version(filename, pattern):
with open(filename) as f:<EOL><INDENT>match = re.search(r"<STR_LIT>" % pattern, f.read())<EOL><DEDENT>if match:<EOL><INDENT>before, version, after = match.groups()<EOL>return version<EOL><DEDENT>fail('<STR_LIT>'.format(pattern, filename))<EOL>
Gets the current version from the specified file.

    This function assumes the file includes a string of the form::

        <pattern> = <version>