def _GetDiscoveryDocFromFlags(args):
    """Get the discovery doc from flags."""
    if args.discovery_url:
        try:
            return util.FetchDiscoveryDoc(args.discovery_url)
        except exceptions.CommunicationError:
            raise exceptions.GeneratedClientError(
                'Could not fetch discovery doc')

    infile = os.path.expanduser(args.infile) or '/dev/stdin'
    with io.open(infile, encoding='utf8') as f:
        return json.loads(util.ReplaceHomoglyphs(f.read()))
Get the discovery doc from flags.