benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b7ed76e6-116c-521f-be79-6ebe814694f4

Problem

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

complete prompt

import shutil
import pathlib


def task_func(source_path, destination_path):
    """
    Lists files in the specified source directory without descending into subdirectories and copies them to a
    destination directory.

    Parameters:
    - source_path (str):      The source directory path to analyze. Must be an existing, accessible directory.
    - destination_path (str): The destination directory path where files will be copied.
                              If it does not exist, this function will create it.

    Returns:
    Tuple[str, List[str]]: A tuple containing the name of the source directory and a list of filenames (not
                           full paths) that were copied.

    Raises:
    - ValueError: If source_path does not exist or is not a directory.

    Requirements:
    - shutil
    - pathlib

    Example:
    >>> x = task_func('/Docs/src/Scripts')
    >>> type(x)
    <class 'tuple'>
    >>> x
    ('Scripts', ['file_1_in_scripts_dir.txt', 'file_2_in_scripts_dir.txt'])
    """

instruct prompt

Lists files in the specified source directory without descending into subdirectories and copies them to a destination directory.
The function should raise the exception for: ValueError: If source_path does not exist or is not a directory.
The function should output with:
    Tuple[str, List[str]]: A tuple containing the name of the source directory and a list of filenames (not
    full paths) that were copied.
You should write self-contained code starting with:

Code

import shutil
import pathlib
def task_func(source_path, destination_path):

code prompt

Code

import shutil
import pathlib
def task_func(source_path, destination_path):

entry point

task_func

libs

  • shutil
  • pathlib

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