def _parse_cmdlineoptions_compat200(arglist): # noqa: C901 """ Parse argument list and set global preferences, compatibility function between old and new way of parsing parameters. """ if arglist.action in ('backup', 'restore'): Globals.set("acls_active", arglist.acls) Globals.set("win_acls_active", arglist.acls) Globals.set("carbonfile_active", arglist.carbonfile) Globals.set("compare_inode", arglist.compare_inode) Globals.set("eas_active", arglist.eas) Globals.set("preserve_hardlinks", arglist.hard_links) Globals.set("resource_forks_active", arglist.resource_forks) Globals.set("never_drop_acls", arglist.never_drop_acls) if arglist.action in ('backup', 'regress', 'restore'): Globals.set("compression", arglist.compression) Globals.set("no_compression_regexp_string", os.fsencode(arglist.not_compressed_regexp)) else: Globals.set("no_compression_regexp_string", os.fsencode(actions.DEFAULT_NOT_COMPRESSED_REGEXP)) if arglist.action in ('server'): Globals.server = True if arglist.action in ('backup'): Globals.set("file_statistics", arglist.file_statistics) Globals.set("print_statistics", arglist.print_statistics) if arglist.action in ('regress'): Globals.set("allow_duplicate_timestamps", arglist.allow_duplicate_timestamps) Globals.set("null_separator", arglist.null_separator) Globals.set("use_compatible_timestamps", arglist.use_compatible_timestamps) Globals.set("do_fsync", arglist.fsync) if arglist.current_time is not None: Globals.set_integer('current_time', arglist.current_time) if arglist.chars_to_quote is not None: Globals.set('chars_to_quote', os.fsencode(arglist.chars_to_quote)) if arglist.api_version is not None: # FIXME Globals.set_api_version(arglist.api_version)
def _parse_cmdlineoptions_compat200(arglist): # noqa: C901 """ Parse argument list and set global preferences, compatibility function between old and new way of parsing parameters. """ global _args, _action def normalize_path(path): """Used below to normalize the security paths before setting""" return rpath.RPath(Globals.local_connection, path).normalize().path if arglist.action in ('backup', 'restore'): Globals.set("acls_active", arglist.acls) Globals.set("win_acls_active", arglist.acls) Globals.set("carbonfile_active", arglist.carbonfile) Globals.set("compare_inode", arglist.compare_inode) Globals.set("eas_active", arglist.eas) Globals.set("preserve_hardlinks", arglist.hard_links) Globals.set("resource_forks_active", arglist.resource_forks) Globals.set("never_drop_acls", arglist.never_drop_acls) if arglist.action in ('backup', 'regress', 'restore'): Globals.set("compression", arglist.compression) Globals.set("no_compression_regexp_string", os.fsencode(arglist.not_compressed_regexp)) else: Globals.set("no_compression_regexp_string", os.fsencode(actions.DEFAULT_NOT_COMPRESSED_REGEXP)) if arglist.action in ('server'): Globals.server = True if arglist.action in ('backup'): Globals.set("file_statistics", arglist.file_statistics) Globals.set("print_statistics", arglist.print_statistics) if arglist.action in ('regress'): Globals.set("allow_duplicate_timestamps", arglist.allow_duplicate_timestamps) Globals.set("null_separator", arglist.null_separator) Globals.set("use_compatible_timestamps", arglist.use_compatible_timestamps) Globals.set("do_fsync", arglist.fsync) if arglist.current_time is not None: Globals.set_integer('current_time', arglist.current_time) if arglist.chars_to_quote is not None: Globals.set('chars_to_quote', os.fsencode(arglist.chars_to_quote)) if arglist.remote_tempdir is not None: Globals.remote_tempdir = os.fsencode(arglist.remote_tempdir) if arglist.restrict_path is not None: Globals.restrict_path = normalize_path(arglist.restrict_path) if arglist.restrict_mode == "read-write": Globals.security_level = "all" else: Globals.security_level = arglist.restrict_mode if arglist.api_version is not None: # FIXME Globals.set_api_version(arglist.api_version) if arglist.terminal_verbosity is not None: log.Log.setterm_verbosity(arglist.terminal_verbosity) log.Log.setverbosity(arglist.verbosity) if arglist.tempdir is not None: if not os.path.isdir(arglist.tempdir): log.Log.FatalError( "Temporary directory '{dir}' doesn't exist.".format( dir=arglist.tempdir)) # At least until Python 3.10, the module tempfile doesn't work properly, # especially under Windows, if tempdir is stored as bytes. # See https://github.com/python/cpython/pull/20442 tempfile.tempdir = arglist.tempdir if arglist.action in ('info', 'server'): _args = [] else: _args = arglist.locations