filepreviews/__main__.py
def generate(ctx, url, *args, **kwargs):
    """
    Generate preview for URL.
    """
    file_previews = ctx.obj['file_previews']

    options = {}
    metadata = kwargs['metadata']
    width = kwargs['width']
    height = kwargs['height']
    output_format = kwargs['format']

    if metadata:
        options['metadata'] = metadata.split(',')

    if width:
        options.setdefault('size', {})
        options['size']['width'] = width

    if height:
        options.setdefault('size', {})
        options['size']['height'] = height

    if output_format:
        options['format'] = output_format

    results = file_previews.generate(url, **options)

    click.echo(results)
def generate(ctx, url, *args, **kwargs):
    file_previews = ctx.obj['file_previews']

    options = {}
    metadata = kwargs['metadata']
    width = kwargs['width']
    height = kwargs['height']
    output_format = kwargs['format']

    if metadata:
        options['metadata'] = metadata.split(',')

    if width:
        options.setdefault('size', {})
        options['size']['width'] = width

    if height:
        options.setdefault('size', {})
        options['size']['height'] = height

    if output_format:
        options['format'] = output_format

    results = file_previews.generate(url, **options)

    click.echo(results)
def generate ( ctx , url , * args , * * kwargs ) : file_previews = ctx . obj [ 'file_previews' ] options = { } metadata = kwargs [ 'metadata' ] width = kwargs [ 'width' ] height = kwargs [ 'height' ] output_format = kwargs [ 'format' ] if metadata : options [ 'metadata' ] = metadata . split ( ',' ) if width : options . setdefault ( 'size' , { } ) options [ 'size' ] [ 'width' ] = width if height : options . setdefault ( 'size' , { } ) options [ 'size' ] [ 'height' ] = height if output_format : options [ 'format' ] = output_format results = file_previews . generate ( url , * * options ) click . echo ( results )
Generate preview for URL.
Generate preview for URL .