Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn this into a generic copy method #177

Closed
alichtman opened this issue Nov 4, 2018 · 2 comments
Closed

Turn this into a generic copy method #177

alichtman opened this issue Nov 4, 2018 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@alichtman
Copy link
Owner

alichtman commented Nov 4, 2018

def copy_dir_if_valid(source_dir, backup_path):

This should work for both files and directories. There should just be one method for this...

import shutil, errno

def copy(src, dst):
    try:
        shutil.copytree(src, dst)
    except OSError as exc: # python >2.5
        if exc.errno == errno.ENOTDIR:
            shutil.copy2(src, dst)
        else: raise

Add one more level of error checking for if the file doesn't exist at all. Fail gracefully by printing an error message.

@alichtman alichtman added this to the v2.0 milestone Nov 4, 2018
@alichtman alichtman assigned alichtman and unassigned alichtman Nov 4, 2018
@alichtman alichtman added help wanted Extra attention is needed good first issue Good for newcomers labels Nov 4, 2018
@alichtman alichtman removed this from the v2.0 milestone Nov 8, 2018
@alichtman
Copy link
Owner Author

This works fine as it is so it's not getting in the next release, but it's going to block #125.

@alichtman alichtman added this to the v2.1 milestone Nov 11, 2018
@alichtman alichtman removed this from the v2.1 milestone Nov 14, 2018
@alichtman
Copy link
Owner Author

Jk, symlinking is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant