in gslib/commands/cp.py [0:0]
def _ParseOpts(self):
# TODO: Arrange variables initialized here in alphabetical order.
perform_mv = False
# exclude_symlinks is handled by Command parent class, so save in Command
# state rather than CopyHelperOpts.
self.exclude_symlinks = False
no_clobber = False
# continue_on_error is handled by Command parent class, so save in Command
# state rather than CopyHelperOpts.
self.continue_on_error = False
daisy_chain = False
read_args_from_stdin = False
print_ver = False
use_manifest = False
preserve_acl = False
self.preserve_posix_attrs = False
canned_acl = None
# canned_acl is handled by a helper function in parent
# Command class, so save in Command state rather than CopyHelperOpts.
self.canned = None
self.all_versions = False
self.skip_unsupported_objects = False
# Files matching these extensions should be compressed.
# The gzip_encoded flag marks if the files should be compressed during
# the upload. The gzip_local flag marks if the files should be compressed
# before uploading. Files compressed prior to uploaded are stored
# compressed, while files compressed during the upload are stored
# uncompressed. These flags cannot be mixed.
gzip_encoded = False
gzip_local = False
gzip_arg_exts = None
gzip_arg_all = None
test_callback_file = None
dest_storage_class = None
self.use_stet = False
# self.recursion_requested initialized in command.py (so can be checked
# in parent class for all commands).
self.manifest = None
if self.sub_opts:
for o, a in self.sub_opts:
if o == '-a':
canned_acl = a
self.canned = True
if o == '-A':
self.all_versions = True
if o == '-c':
self.continue_on_error = True
elif o == '-D':
daisy_chain = True
elif o == '-e':
self.exclude_symlinks = True
elif o == '--testcallbackfile':
# File path of a pickled class that implements ProgressCallback.call.
# Used for testing transfer interruptions and resumes.
test_callback_file = a
elif o == '-I':
read_args_from_stdin = True
elif o == '-j':
gzip_encoded = True
gzip_arg_exts = [x.strip() for x in a.split(',')]
elif o == '-J':
gzip_encoded = True
gzip_arg_all = GZIP_ALL_FILES
elif o == '-L':
use_manifest = True
self.manifest = Manifest(a)
elif o == '-M':
# Note that we signal to the cp command to perform a move (copy
# followed by remove) and use directory-move naming rules by passing
# the undocumented (for internal use) -M option when running the cp
# command from mv.py.
perform_mv = True
elif o == '-n':
no_clobber = True
elif o == '-p':
preserve_acl = True
elif o == '-P':
self.preserve_posix_attrs = True
InitializePreservePosixData()
elif o == '-r' or o == '-R':
self.recursion_requested = True
elif o == '-s':
dest_storage_class = NormalizeStorageClass(a)
elif o == '-U':
self.skip_unsupported_objects = True
elif o == '-v':
print_ver = True
elif o == '-z':
gzip_local = True
gzip_arg_exts = [x.strip() for x in a.split(',')]
elif o == '-Z':
gzip_local = True
gzip_arg_all = GZIP_ALL_FILES
elif o == '--stet':
self.use_stet = True
if preserve_acl and canned_acl:
raise CommandException(
'Specifying both the -p and -a options together is invalid.')
if self.all_versions and self.parallel_operations:
raise CommandException(
'The gsutil -m option is not supported with the cp -A flag, to '
'ensure that object version ordering is preserved. Please re-run '
'the command without the -m option.')
if gzip_encoded and gzip_local:
raise CommandException(
'Specifying both the -j/-J and -z/-Z options together is invalid.')
if gzip_arg_exts and gzip_arg_all:
if gzip_encoded:
raise CommandException(
'Specifying both the -j and -J options together is invalid.')
else:
raise CommandException(
'Specifying both the -z and -Z options together is invalid.')
self.gzip_exts = gzip_arg_exts or gzip_arg_all
self.gzip_encoded = gzip_encoded
return CreateCopyHelperOpts(
perform_mv=perform_mv,
no_clobber=no_clobber,
daisy_chain=daisy_chain,
read_args_from_stdin=read_args_from_stdin,
print_ver=print_ver,
use_manifest=use_manifest,
preserve_acl=preserve_acl,
canned_acl=canned_acl,
skip_unsupported_objects=self.skip_unsupported_objects,
test_callback_file=test_callback_file,
dest_storage_class=dest_storage_class)