benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf d20dd1b3-38fb-53aa-b785-4a810e99c059

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import os
import shutil


def task_func(src_folder, backup_dir):
    """
    Backs up a given source folder to the specified backup directory, then deletes the source folder.
    
    Parameters:
    src_folder (str): The path of the source folder to be backed up and deleted.
    backup_dir (str): The path of the directory where the source folder will be backed up.
    
    Returns:
    bool: True if the operation is successful, False otherwise.
    
    Requirements:
    - os
    - shutil
    
    Raises:
    - ValueError: If the source folder does not exist.
    - Exception: If an error occurs while deleting the source folder.
    
    Example:
    >>> import tempfile
    >>> src_folder = tempfile.mkdtemp()
    >>> backup_dir = tempfile.mkdtemp()
    >>> with open(os.path.join(src_folder, 'sample.txt'), 'w') as f:
    ...     _ = f.write('This is a sample file.')
    >>> task_func(src_folder, backup_dir)
    True
    """

instruct prompt

Backs up a given source folder to the specified backup directory, then deletes the source folder.
The function should raise the exception for: ValueError: If the source folder does not exist. Exception: If an error occurs while deleting the source folder.
The function should output with:
    bool: True if the operation is successful, False otherwise.
You should write self-contained code starting with:

Code

import os
import shutil
def task_func(src_folder, backup_dir):

code prompt

Code

import os
import shutil
def task_func(src_folder, backup_dir):

entry point

task_func

libs

  • shutil
  • os

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import