def main(self):
    parser = argparse.ArgumentParser(description = self.description, formatter_class = argparse.RawDescriptionHelpFormatter,)

    # Source
    parser.add_argument(
      'source',
      help = 'The .mbtiles file source.  If used with the --mapbox-source flag, then this should be a Mapbox map identifier.'
    )

    # Bucket
    parser.add_argument(
      'bucket',
      help = 'The S3 bucket to send to.'
    )

    # Bucket path
    parser.add_argument(
      '-p', '--path',
      dest = 'path',
      help = 'Path in bucket to send to.',
      default = ''
    )

    # Option to add jsonp wrapper
    parser.add_argument(
      '-g', '--grid-callback',
      dest = 'callback',
      help = 'Control JSONP callback for UTFGrid tiles.  Defaults to `grid`, use blank to remove JSONP',
      default = 'grid'
    )

    # Tileset name
    parser.add_argument(
      '-t', '--tileset-name',
      dest = 'tileset_name',
      help = 'The name of the tileset to use.  By default, this will be the file name of the source.',
      default = ''
    )

    # Concurency
    parser.add_argument(
      '-c', '--concurrency',
      dest = 'concurrency',
      help = 'Number of concurrent uploads.  Default is 32',
      type = int,
      default = 32
    )

    # Option to use Mapbox file
    parser.add_argument(
      '-m', '--mapbox-source',
      action = 'store_true',
      help = 'Interpret the source as a Mapbox map, usually in the format of `user.map_id`.'
    )

    # Remove old parts
    parser.add_argument(
      '-r', '--remove-first',
      action = 'store_true',
      help = 'Remove old files first.  This is good if for some reason the map boundary has changed.'
    )

    # Do not upload mbtiles
    parser.add_argument(
      '--dont-upload-mbtiles',
      action = 'store_true',
      help = 'Do not upload the original mbtiles file.  This is desierable for archivable purposes.'
    )

    # Do not upload image tiles
    parser.add_argument(
      '--dont-upload-image-tiles',
      action = 'store_true',
      help = 'Do not upload the image tiles.'
    )

    # Do not upload grid tiles
    parser.add_argument(
      '--dont-upload-grid-tiles',
      action = 'store_true',
      help = 'Do not upload the grid tiles.'
    )

    # Turn on debugging
    parser.add_argument(
      '-d', '--debug',
      action = 'store_true',
      help = 'Turn on debugging.'
    )

    # Parse options
    args = parser.parse_args()

    # Set some properties
    self.args = args
    self.source = args.source
    self.bucket_name = args.bucket
    self.path = args.path

    # Debugging
    if self.args.debug:
      logging.basicConfig(level = logging.DEBUG)

    # If mapbox option, handle that
    if self.args.mapbox_source:
      self.get_mapbox_mbtiles()

    # Ensure that the file exists
    if not os.path.exists(self.source) or not os.path.isfile(self.source):
      self.error('The source file is not a file or does not exist.\n')
      sys.exit(1)

    # Ensure that we have AWS credentials set up
    if 'AWS_ACCESS_KEY_ID' not in os.environ or 'AWS_SECRET_ACCESS_KEY' not in os.environ:
      self.error('AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY not found in the environment.\n')
      sys.exit(1)

    # Determine tileset name
    self.tileset = self.args.tileset_name
    if self.tileset is None or self.tileset == '':
      self.tileset = os.path.splitext(os.path.basename(self.source))[0]

    # Normalize the path
    self.path = os.path.normcase(self.path.strip('/'))

    # Make initial connection to S3
    self.connect_s3()

    # Make initial connection to mbtiles
    self.connect_mbtiles()

    # Remove first
    if self.args.remove_first:
      self.remove_export()

    # Upload metadata
    self.mbtiles_metadata()

    # Upload tiles
    if not self.args.dont_upload_image_tiles:
      self.mbtiles_image_tiles()
    if not self.args.dont_upload_grid_tiles:
      self.mbtiles_grid_tiles()

    # Upload mbtiles
    if not self.args.dont_upload_mbtiles:
      self.mbtiles_mbtiles()

    # Done
    self.out('- Done.\n')



# Handle execution
The main execution of the class and handles CLI arguments.
dataset/ETHPy150Open MinnPost/mbtiles2s3/mbtiles2s3/mbtiles2s3.py/MBTiles2S3.main