Skip to content

Slightly better implementation of "copytree" for Python 2.7

License

Notifications You must be signed in to change notification settings

joykabir/py-copytree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-copytree

Build Status

A slightly better implementation python copytree that copies recursively source contents to a destination.

Features

  • Destination path is created automatically if it does not exists
  • Possible to specify force flag to overwrite destination contents
  • Possible to specify which files to copy and not to copy to destination

How it works

The function takes six arguments. Positional arguments - src and dest -are mandatory. Third positional argument ignore takes a function which takes list of items to ignore by using ignore_patterns function. The same ignore also accepts list of items to copy by using include_patterns function. Specify true to copy symlinks. If force is set to true, destination contents will be overwritten.

ignore_patterns() example
-------------------------

copy_tree(src, dest, ignore=ignore_patterns('*.pyc', '*.class'), force=False)

include_patterns() example
--------------------------

copy_tree(src, dest, ignore=include_patterns('*.py', '*.sh'), symlink=True, force=True)

Test and lint

The function is unit tested (not fully covered) and ran through pylint.

Acknowledgements

https://stackoverflow.com/a/35161407

License

MIT License

About

Slightly better implementation of "copytree" for Python 2.7

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published