'Get a file from the control dir with a specific name.
Although the filename should be interpreted as a filename relative to
the control dir in a disk-based Repo, the object returned need not be
pointing to a file in that location.
:param path: The path to the file, relative to the control dir.
:param basedir: Optional argument that specifies an alternative to the
control dir.
:return: An open file object, or None if the file does not exist.'

def get_named_file(self, path, basedir=None):

    if (basedir is None):
        basedir = self.controldir()
    path = path.lstrip(os.path.sep)
    try:
        return open(os.path.join(basedir, path), 'rb')
    except (IOError, OSError) as e:
        if (e.errno == errno.ENOENT):
            return None
        raise
