@contextmanager
def reviewboardrc(self, config, use_temp_dir=False):
    'Populate a temporary .reviewboardrc file.\n\n        This will create a :file:`.reviewboardrc` file, either in the current\n        directory or in a new temporary directory (if ``use_temp_dir`` is set).\n        The file will contain the provided configuration.\n\n        Version Added:\n            3.0\n\n        Args:\n            config (dict):\n                A dictionary of key-value pairs to write into the\n                :file:`.reviewboardrc` file.\n\n                A best effort attempt will be made to write each configuration\n                to the file.\n\n            use_temp_dir (bool, optional):\n                Whether a temporary directory should be created and set as\n                the current directory. If set, the file will be written there,\n                and the directory will be removed after the context manager\n                finishes.\n\n        Context:\n            The code being run will have a :file:`.reviewboardrc` in the\n            current directory.\n        '
    if use_temp_dir:
        temp_dir = tempfile.mkdtemp()
        cwd = os.getcwd()
        os.chdir(temp_dir)
    with open('.reviewboardrc', 'w') as fp:
        for (key, value) in six.iteritems(config):
            fp.write(('%s = %r\n' % (key, value)))
    try:
        (yield)
    finally:
        if use_temp_dir:
            os.chdir(cwd)
            shutil.rmtree(temp_dir)
Populate a temporary .reviewboardrc file.

This will create a :file:`.reviewboardrc` file, either in the current
directory or in a new temporary directory (if ``use_temp_dir`` is set).
The file will contain the provided configuration.

Version Added:
    3.0

Args:
    config (dict):
        A dictionary of key-value pairs to write into the
        :file:`.reviewboardrc` file.

        A best effort attempt will be made to write each configuration
        to the file.

    use_temp_dir (bool, optional):
        Whether a temporary directory should be created and set as
        the current directory. If set, the file will be written there,
        and the directory will be removed after the context manager
        finishes.

Context:
    The code being run will have a :file:`.reviewboardrc` in the
    current directory.
@contextmanager
def reviewboardrc(self, config, use_temp_dir=False):
    'Populate a temporary .reviewboardrc file.\n\n        This will create a :file:`.reviewboardrc` file, either in the current\n        directory or in a new temporary directory (if ``use_temp_dir`` is set).\n        The file will contain the provided configuration.\n\n        Version Added:\n            3.0\n\n        Args:\n            config (dict):\n                A dictionary of key-value pairs to write into the\n                :file:`.reviewboardrc` file.\n\n                A best effort attempt will be made to write each configuration\n                to the file.\n\n            use_temp_dir (bool, optional):\n                Whether a temporary directory should be created and set as\n                the current directory. If set, the file will be written there,\n                and the directory will be removed after the context manager\n                finishes.\n\n        Context:\n            The code being run will have a :file:`.reviewboardrc` in the\n            current directory.\n        '
    if use_temp_dir:
        temp_dir = tempfile.mkdtemp()
        cwd = os.getcwd()
        os.chdir(temp_dir)
    with open('.reviewboardrc', 'w') as fp:
        for (key, value) in six.iteritems(config):
            fp.write(('%s = %r\n' % (key, value)))
    try:
        (yield)
    finally:
        if use_temp_dir:
            os.chdir(cwd)
            shutil.rmtree(temp_dir)