def main():
  general_setup()

  if not sys.argv[0]: sys.argv[0] = ""  # Workaround for running with optparse from egg

  version_str = "version %s (repository version %s, Boto version %s)" % (ZINC_VERSION, REPO_VERSION, BOTO_VERSION)
  commands_str = "|".join(sorted(list(_COMMAND_LIST_REPO + _COMMAND_LIST_WORK), key=lambda s: s.replace("_", "~")))

  usage = "%%prog %s [options] [arg1] [arg2]\n\n" % commands_str + \
          "Zinc: Simple and scalable versioned data storage\n%s" % version_str

  parser = optparse.OptionParser(usage=usage)
  parser.add_option('-w', '--work-dir', help='working directory (current dir is default)', dest='work_dir', action='store', type='string', default=None)
  parser.add_option('-R', '--repository', help='URI of repository (e.g. s3://mybucket/path)', dest='root_uri', action='store', type='string', default=None)
  parser.add_option('-s', '--scope', help='scope', dest='scope', action='store', type='string')
  parser.add_option('-r', '--rev', help='revision or revision range', dest='rev', action='store', type='string', default=None)
  parser.add_option('-d', '--date', help='date specifier, e.g. <2010-10-10 13:30', dest='date', action='store', type='string', default=None)
  parser.add_option('-u', '--user', help='user name, to appear in commit messages', dest='user', action='store', type='string')
  parser.add_option('-m', '--message', help='commit message', dest='message', action='store', type='string', default=None)
  parser.add_option('-f', '--force', help='force destructive operations', dest='force', action='store_true')
  parser.add_option('-v', '--verbose', help='verbose output', dest='verbose', action='store_true')
  parser.add_option('-a', '--recursive', help='copy recursively (for list, copy)', dest='recursive', action='store_true')
  parser.add_option('--all', help='perform operation on all scopes (for checkout, update)', dest='all', action='store_true')
  parser.add_option('--work', help='perform operation on checked out (working) scopes (for status, update, commit, tag, track, untrack)', dest='work', action='store_true')
  parser.add_option('--mod-all', help='mark every file as modified, skipping content checks (for commit, status)', dest='mod_all', action='store_true')
  parser.add_option('--compression', help='compression scheme to use (e.g. "raw" or "lzo")', dest='compression')
  parser.add_option('--short-paths', help='do not include scope part of path in "list", "status", etc.', dest='short_paths', action='store_true')
  parser.add_option('--suppress', help='suppress harmless failures (e.g. empty commits)', dest='suppress', action='store_true')
  parser.add_option('--no-cache', help='do not cache files locally', dest='no_cache', action='store_true')
  parser.add_option('--no-s3cfg', help='do not look for S3 keys in $HOME/.s3cfg (default: do this as a fallback)', dest='no_s3cfg', action='store_true')
  parser.add_option('--s3-ssl', help='use SSL with S3 (slower)', dest='s3_ssl', action='store_true')
  parser.add_option('--utc', help='when parsing times, assume UTC if not specified', dest='assume_utc', action='store_true')
  parser.add_option('--debug', help='verbose output with debugging details', dest='debug', action='store_true')
  parser.add_option('--version', help='show version information', dest='version', action='store_true')
  parser.add_option('--mode', help='specify tracking mode: %s (for checkout, track, untrack)' % Mode.values(), dest='mode', action='store', type='string', default=None)
  parser.add_option('--no-download', help='track files without copying them to working directory (for track)', dest='no_download', action='store_true')
  parser.add_option('--full', help='show full status when in "%s" tracking mode (for status)' % Mode.PARTIAL, dest='full', action='store_true')
  parser.add_option('--minimal', help='minimal log output', dest='minimal', action='store_true')
  parser.add_option('--verbosity', help='Logging verbosity: 0 = minimal, 1 = normal, 2 = verbose, 3 = debug.', dest='verbosity', action='store', type='int', default=1)

  (options, args) = parser.parse_args()

  if options.version:
    print version_str % "%s"
    sys.exit(0)

  if options.debug:
    log_setup(verbosity=3)
    log.debug("this is %s", version_str)
  elif options.verbose:
    log_setup(verbosity=2)
  elif options.minimal:
    log_setup(verbosity=0)
  else:
    log_setup(verbosity=options.verbosity)

  if len(args) < 1:
    fail("specify a command, or run with -h for help")

  command = args[0]
  command_args = args[1:]

  if command not in _COMMAND_LIST_REPO and command not in _COMMAND_LIST_WORK and command not in _COMMAND_ABBREVS:
    fail("unrecognized command: run with -h for help")

  try:
    run_command(command, command_args, options)  
  except InvalidArgument, e:
    log.debug("exception in command '%s'", command, exc_info=e)
    fail(str(e), prefix="invalid argument", exc_info=e, suppress=(options.suppress and e.suppressable))
  except InvalidOperation, e:
    log.debug("exception in command '%s'", command, exc_info=e)
    fail(str(e), prefix="invalid operation", exc_info=e, suppress=(options.suppress and e.suppressable))
  except Failure, e:
    log.debug("exception in command '%s'", command, exc_info=e)
    fail(str(e), prefix="error", exc_info=e, suppress=(options.suppress and e.suppressable))
  except AssertionError, e:
    log.debug("assertion error in command '%s'", command, exc_info=e)
    fail("assertion failure: %s\nrun with --debug for details" % e.message, exc_info=e)
  except boto.exception.S3ResponseError, e:
    log.debug("S3 error in command '%s'", command, exc_info=e)
    fail(str(e), prefix="S3 error", exc_info=e)
  except IOError, e:
    log.debug("I/O error in command '%s'", command, exc_info=e)
    if e.errno == errno.EPIPE:
      fail(status=1)
    else:
      fail(str(e), status=1)
  except KeyboardInterrupt, e:
    log.debug("(interrupt)")
    fail(status=2)
  except Exception, e:
    log.debug("exception in command '%s'", command, exc_info=e)
    fail("%s: %s" % (type(e).__name__, e), exc_info=e)
dataset/ETHPy150Open bloomreach/zinc/zinc.py/main/swapped operands of `%`