-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!python | ||
"""Uses hansel.Crumb to copy one file tree to another file tree. The | ||
structure of the destination tree can be modified. | ||
Examples: | ||
crumb_copy --link /data/hansel/cobre/{sid}/{session}/{img} /data/hansel/cobre2/{sid}/{img} | ||
crumb_copy cobre/{sid}/{session}/{img:anat*} cobre_anat/{sid}/{img} | ||
""" | ||
|
||
def call_crumb_copy(src, dst, **kwargs): | ||
""" Make a Crumb out of `src` and `dst` and call `hansel.crumb_copy` | ||
with these and the extra kwargs parameters.""" | ||
from hansel import Crumb, crumb_copy | ||
|
||
src_cr = Crumb(src) | ||
dst_cr = Crumb(dst) | ||
|
||
crumb_copy(src_cr, dst_cr, **kwargs) | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
from argparse import ArgumentParser, RawTextHelpFormatter | ||
|
||
defstr = ' (default %(default)s)' | ||
parser = ArgumentParser(prog='crumb_copy', | ||
description=__doc__, | ||
formatter_class=RawTextHelpFormatter) | ||
|
||
parser.add_argument('src', metavar='<source crumb path>', type=str, | ||
help='The source crumb path.') | ||
parser.add_argument('dst', metavar='<dest crumb path>', type=str, | ||
help='The destination crumb path') | ||
parser.add_argument('--link', dest='link', default=False, action='store_true', | ||
help='Flag to indicate to whether make links instead of copying.') | ||
parser.add_argument('--quiet', dest='quiet', default=False, action='store_true', | ||
help='Flag to remove verbose.') | ||
parser.add_argument('--exist_ok', dest='exist_ok', default=False, action='store_true', | ||
help='Flag to allow overwriting destination path.') | ||
|
||
args = parser.parse_args() | ||
|
||
if len(sys.argv) == 1: | ||
parser.print_help() | ||
exit(0) | ||
|
||
call_crumb_copy(args.src, args.dst, | ||
make_links=args.link, | ||
exist_ok=args.exist_ok, | ||
verbose=(not args.quiet)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters