30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
import bpy
|
|
from . import bpkg
|
|
from pathlib import Path
|
|
import logging
|
|
|
|
from collections import OrderedDict
|
|
|
|
def fmt_version(version_number: tuple) -> str:
|
|
"""Take version number as a tuple and format it as a string"""
|
|
vstr = str(version_number[0])
|
|
for component in version_number[1:]:
|
|
vstr += "." + str(component)
|
|
return vstr
|
|
|
|
def sanitize_repository_url(url: str) -> str:
|
|
"""Sanitize repository url"""
|
|
from urllib.parse import urlsplit, urlunsplit
|
|
parsed_url = urlsplit(url)
|
|
# new_path = parsed_url.path.rstrip("repo.json")
|
|
new_path = parsed_url.path
|
|
return urlunsplit((parsed_url.scheme, parsed_url.netloc, new_path, parsed_url.query, parsed_url.fragment))
|
|
|
|
def add_repojson_to_url(url: str) -> str:
|
|
"""Add `repo.json` to the path component of a url"""
|
|
from urllib.parse import urlsplit, urlunsplit
|
|
parsed_url = urlsplit(url)
|
|
new_path = str(Path(parsed_url.path) / "repo.json")
|
|
return urlunsplit((parsed_url.scheme, parsed_url.netloc, new_path, parsed_url.query, parsed_url.fragment))
|
|
|