Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = 'semantic-link-labs'
copyright = '2024, Microsoft and community'
author = 'Microsoft and community'
release = '0.10.0'
release = '0.10.1'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name="semantic-link-labs"
authors = [
{ name = "Microsoft Corporation" },
]
version="0.10.0"
version="0.10.1"
description="Semantic Link Labs for Microsoft Fabric"
readme="README.md"
requires-python=">=3.10,<3.12"
Expand Down
32 changes: 24 additions & 8 deletions src/sempy_labs/_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@
from uuid import UUID
import sempy_labs._icons as icons
from azure.core.credentials import TokenCredential, AccessToken
import urllib.parse
import numpy as np
from IPython.display import display, HTML
import requests
import sempy_labs._authentication as auth
from jsonpath_ng.ext import parse
from jsonpath_ng.jsonpath import Fields, Index
from urllib.parse import urlparse, urlunparse, urlencode, quote


def _build_url(url: str, params: dict) -> str:
"""
Build the url with a list of parameters
"""
url_parts = list(urllib.parse.urlparse(url))
url_parts[4] = urllib.parse.urlencode(params)
url = urllib.parse.urlunparse(url_parts)
url_parts = list(urlparse(url))
url_parts[4] = urlencode(params)
url = urlunparse(url_parts)

return url


def _encode_user(user: str) -> str:

return urllib.parse.quote(user, safe="@")
return quote(user, safe="@")


def create_abfss_path(
Expand Down Expand Up @@ -94,7 +94,7 @@ def _get_default_file_path() -> str:

def _split_abfss_path(path: str) -> Tuple[UUID, UUID, str]:

parsed_url = urllib.parse.urlparse(path)
parsed_url = urlparse(path)

workspace_id = parsed_url.netloc.split("@")[0]
item_id = parsed_url.path.lstrip("/").split("/")[0]
Expand Down Expand Up @@ -1092,7 +1092,7 @@ def resolve_workspace_capacity(
from sempy_labs._capacities import list_capacities

(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
filter_condition = urllib.parse.quote(workspace_id)
filter_condition = quote(workspace_id)
dfW = fabric.list_workspaces(filter=f"id eq '{filter_condition}'")
capacity_id = dfW["Capacity Id"].iloc[0]
dfC = list_capacities()
Expand Down Expand Up @@ -1126,7 +1126,7 @@ def get_capacity_id(workspace: Optional[str | UUID] = None) -> UUID:
capacity_id = _get_fabric_context_setting(name="trident.capacity.id")
else:
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
filter_condition = urllib.parse.quote(workspace_id)
filter_condition = quote(workspace_id)
dfW = fabric.list_workspaces(filter=f"id eq '{filter_condition}'")
if len(dfW) == 0:
raise ValueError(f"{icons.red_dot} The '{workspace_name}' does not exist'.")
Expand Down Expand Up @@ -2435,3 +2435,19 @@ def remove_json_value(path: str, payload: dict, json_path: str, verbose: bool =
print(f"{icons.green_dot} Removed index [{index}] from '{path}'.")

return payload


def fix_github_url(url: str) -> str:
parsed = urlparse(url)

# Check for valid scheme and correct host
if parsed.scheme in ("http", "https") and parsed.netloc == "github.com":
path_parts = parsed.path.split("/")
if len(path_parts) > 4 and path_parts[3] == "blob":
# Convert to raw.githubusercontent.com
new_netloc = "raw.githubusercontent.com"
new_path = "/".join(path_parts[:3] + path_parts[4:]) # remove 'blob'
new_url = urlunparse(("https", new_netloc, new_path, "", "", ""))
return new_url

return url # return original if not a valid GitHub blob URL
Loading