docs: def mainloop(self):
          """ The main loop.
          """
          if not self.args:
              self.parser.print_help()
              self.parser.exit()
  
          for idx, filename in enumerate(self.args):
              torrent = metafile.Metafile(filename)
              if idx and not self.options.output:
                  print
                  print "~" * 79
  
              try:
                  # Read and check metafile
                  try:
                      data = metafile.checked_open(filename, log=self.LOG if self.options.skip_validation else None,
                          quiet=(self.options.quiet and (self.options.output or self.options.raw)))
                  except EnvironmentError, exc:
                      self.fatal("Can't read '%s' (%s)" % (
                          filename, str(exc).replace(": '%s'" % filename, ""),
                      ))
                      raise
  
                  listing = None
  
                  if self.options.raw:
                      if not self.options.reveal and "info" in data:
                          # Shorten useless binary piece hashes
                          data["info"]["pieces"] = "<%d piece hashes>" % (
                              len(data["info"]["pieces"]) / len(hashlib.sha1().digest()) # bogus pylint: disable=E1101
                          )
  
                      pprinter = (pprint.PrettyPrinter if self.options.reveal else metafile.MaskingPrettyPrinter)()
                      listing = pprinter.pformat(data)
                  elif self.options.output:
                      def splitter(fields):
                          "Yield single names for a list of comma-separated strings."
                          for flist in fields:
                              for field in flist.split(','):
                                  yield field.strip()
  
                      data["__file__"] = filename
                      if 'info' in data:
                          data["__hash__"] = metafile.info_hash(data)
                          data["__size__"] = metafile.data_size(data)
                      values = []
                      for field in splitter(self.options.output):
                          try:
                              val = data
                              for key in field.split('.'):
                                  val = val[key]
                          except KeyError, exc:
                              self.LOG.error("%s: Field %r not found (%s)" % (filename, field, exc))
                              break
                          else:
                              values.append(str(val))
                      else:
                          listing = '\t'.join(values)
                  else:
                      listing = '\n'.join(torrent.listing(masked=not self.options.reveal))
              except (ValueError, KeyError, bencode.BencodeError), exc:
                  if self.options.debug:
                      raise
                  self.LOG.warning("Bad metafile %r (%s: %s)" % (filename, type(exc).__name__, exc))
              else:
                  if listing is not None:
                      print(fmt.to_utf8(listing))