Exemplo n.º 1
0
 def run(self):
     self.num_lines = self.options.num
     vlog_option('number of lines', self.num_lines)
     self.quiet = self.options.quiet
     vlog_option('quiet', self.quiet)
     if not self.args:
         self.args.append('-')
     for arg in self.args:
         if arg == '-':
             continue
         if not os.path.exists(arg):
             print("'%s' not found" % arg)
             sys.exit(ERRORS['WARNING'])
         if os.path.isfile(arg):
             vlog_option('file', arg)
         elif os.path.isdir(arg):
             vlog_option('directory', arg)
         else:
             die("path '%s' could not be determined as either a file or directory" % arg)
     for filename in self.args:
         if filename == '-':
             self.headtail(sys.stdin.read())
         else:
             with open(filename) as _:
                 self.headtail(_.read())
         if not self.quiet and len(self.args) > 1:
             print(self.docsep)
Exemplo n.º 2
0
 def run(self):
     if not self.args:
         self.args.append('-')
     args = uniq_list_ordered(self.args)
     for arg in args:
         if arg == '-':
             continue
         if not os.path.exists(arg):
             print("'%s' not found" % arg)
             sys.exit(ERRORS['WARNING'])
         if os.path.isfile(arg):
             vlog_option('file', arg)
         elif os.path.isdir(arg):
             vlog_option('directory', arg)
         else:
             die("path '%s' could not be determined as either a file or directory" % arg)
     for arg in args:
         self.check_path(arg)
Exemplo n.º 3
0
 def run(self):
     self.delimiter = self.options.delimiter
     self.quotechar = self.options.quotechar
     vlog_option('delimiter', self.delimiter)
     vlog_option('quotechar', self.quotechar)
     if not self.args:
         self.args.append('-')
     args = uniq_list_ordered(self.args)
     for arg in args:
         if arg == '-':
             continue
         if not os.path.exists(arg):
             print("'%s' not found" % arg)
             sys.exit(ERRORS['WARNING'])
         if os.path.isfile(arg):
             vlog_option('file', arg)
         elif os.path.isdir(arg):
             vlog_option('directory', arg)
         else:
             die("path '%s' could not be determined as either a file or directory" % arg)
     for arg in args:
         self.check_path(arg)
     if self.failed:
         sys.exit(ERRORS['CRITICAL'])