def main(argv=None, stdout=None, stdin=None, HTML=HTML):  # noqa: N803
    """The ``weasyprint`` program takes at least two arguments:

    .. code-block:: sh

        weasyprint [options] <input> <output>

    """
    args = PARSER.parse_args(argv)

    if args.input == '-':
        source = stdin or sys.stdin.buffer
        if args.base_url is None:
            args.base_url = '.'  # current directory
        elif args.base_url == '':
            args.base_url = None  # no base URL
    else:
        source = args.input

    if args.output == '-':
        output = stdout or sys.stdout.buffer
    else:
        output = args.output

    url_fetcher = default_url_fetcher
    if args.timeout is not None:
        url_fetcher = partial(default_url_fetcher, timeout=args.timeout)

    options = {
        key: value for key, value in vars(args).items() if key in DEFAULT_OPTIONS}

    # Default to logging to stderr.
    if args.debug:
        LOGGER.setLevel(logging.DEBUG)
    elif args.verbose:
        LOGGER.setLevel(logging.INFO)
    if not args.quiet:
        handler = logging.StreamHandler()
        if args.debug:
            # Add extra information when debug logging
            handler.setFormatter(
                logging.Formatter(
                    '%(levelname)s: %(filename)s:%(lineno)d '
                    '(%(funcName)s): %(message)s'))
        else:
            handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
        LOGGER.addHandler(handler)

    html = HTML(
        source, base_url=args.base_url, encoding=args.encoding,
        media_type=args.media_type, url_fetcher=url_fetcher)
    html.write_pdf(output, **options)
The ``weasyprint`` program takes at least two arguments:

.. code-block:: sh

weasyprint [options] <input> <output>
weasyprint/__main__.py