def match_version_pattern(filename, pattern):
  """
  Matches a single version upgrade pattern in the specified *filename*
  and returns the match information. Returns a #Match object or #None
  if the *pattern* did not match.
  """

  if "{VERSION}" not in pattern:
    raise ValueError("pattern does not contain a {VERSION} reference")
  pattern = pattern.replace('{VERSION}', '(?P<v>[\d\w\.\-_]+)')
  expr = re.compile(pattern)
  with open(filename) as fp:
    lines = fp.read().split('\n')
  for i, line in enumerate(lines):
    match = expr.search(line)
    if match:
      return Match(filename, lines, line_index=i,
          version=Version(match.group('v')), span=match.span('v'))
  return None