Skip to content

url (3)

fsspec_url

fsspec_url(string: str | os.PathLike[str]) -> bool

Returns true if the given URL looks like an fsspec protocol, except http/https.

Example

Jinja call:

{% if "github://some.path" is fsspec_url %}
True!
{% endif %}
Result:
True!

DocStrings

Parameters:

Name Type Description Default
string str | PathLike[str]

The URL to check

required
Source code in src/jinjarope/envtests.py
155
156
157
158
159
160
161
162
163
164
165
def is_fsspec_url(string: str | os.PathLike[str]) -> bool:
    """Returns true if the given URL looks like an fsspec protocol, except http/https.

    Args:
        string: The URL to check
    """
    return (
        isinstance(string, str)
        and bool(_RFC_3986_PATTERN.match(string))
        and not string.startswith(("http://", "https://"))
    )

http_url

http_url(string: str) -> bool

Return true when given string represents a HTTP url.

Example

Jinja call:

{% if "http://some.url" is http_url %}
True!
{% endif %}
Result:
True!

DocStrings

Parameters:

Name Type Description Default
string str

The string to check

required
Source code in src/jinjarope/envtests.py
107
108
109
110
111
112
113
def is_http_url(string: str) -> bool:
    """Return true when given string represents a HTTP url.

    Args:
        string: The string to check
    """
    return string.startswith(("http://", "https://", "www.")) and "\n" not in string

url

url(string: str) -> bool

Return true when given string represents any type of URL.

Example

Jinja call:

{% if "abc://" is url %}
True!
{% endif %}
Result:
True!

DocStrings

Parameters:

Name Type Description Default
string str

The string to check

required
Source code in src/jinjarope/envtests.py
116
117
118
119
120
121
122
def is_protocol_url(string: str) -> bool:
    """Return true when given string represents any type of URL.

    Args:
        string: The string to check
    """
    return "://" in string and "\n" not in string