def setup(self): args = self.args() append_filename = args.string_arg('-a') replace_filename = args.string_arg('-f') filename = None mode = None if append_filename and replace_filename: self.usage() elif append_filename: mode = 'a' filename = append_filename elif replace_filename: mode = 'w' filename = replace_filename self._csv = args.flag('-c') self._terminal = args.flag('-t') if args.has_next(): self._format = args.next_string() if args.has_next(): self.usage() if self._csv and self._format: self.usage() if filename: self._output = open(filename, mode) else: self._output = sys.stdout
def setup(self): args = self.args() scp_options = "" for option in "Crp": if args.flag("-" + option): scp_options += option if scp_options: self._scp_options = "-" + scp_options else: self._scp_options = "" self._use_subdirs = not args.flag("-x") if args.has_next(): self._file = args.next_string() if args.has_next(): self._local_dir = args.next_string() if not self._file or not self._local_dir or args.has_next(): self.usage() if not self._file.startswith("/"): self.usage()