This is the main module for the script.  The script will accept a file, or a directory, and then
    encrypt it with a provided key before pushing it to S3 into a specified bucket.

def main():
    """
    This is the main module for the script.  The script will accept a file, or a directory, and then
    encrypt it with a provided key before pushing it to S3 into a specified bucket.
    """
    parser = argparse.ArgumentParser(description=main.__doc__, add_help=True)
    parser.add_argument('-M', '--master_key', dest='master_key', help='Path  to the master key ' +
                        'used for the encryption.  Data is transferred without encryption if this' +
                        'is not provided.', type=str, required=False, default=None)
    parser.add_argument('-B', '--bucket', dest='bucket', help='S3 bucket.', type=str, required=True)
    parser.add_argument('-R', '--remote_dir', dest='remote_dir', help='Pseudo directory within ' +
                        'the bucket to store the file(s).  NOTE: Folder structure below ' +
                        'REMOTE_DIR will be retained.', type=str, required=False, default='')
    parser.add_argument('data', help='File(s) or folder(s) to transfer to S3.', type=str, nargs='+')
    params = parser.parse_args()
    # Input handling
    if params.master_key and not os.path.exists(params.master_key):
        raise InputParameterError('The master key was not found at ' +
                                  params.master_key)
    #  If the user doesn't have ~/.boto , it doesn't even make sense to go ahead
    if not os.path.exists(os.path.expanduser('~/.boto')):
        raise RuntimeError('~/.boto not found')
    # Ensure that the remote directory doesn't start with a /
    if params.remote_dir.startswith('/'):
        raise InputParameterError('The remote dir cannot start with a \'/\'')

    # Process each of the input arguments.
    for datum in params.data:
        datum = os.path.abspath(datum)
        if not os.path.exists(datum):
            print('ERROR: %s could not be found.' % datum, file=sys.stderr)
            continue
        write_to_s3(datum, params.master_key, params.bucket, params.remote_dir)
    return None