Skip to content

Commit

Permalink
Merge branch 'm-kovalsky/issue165'
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kovalsky committed Oct 1, 2024
2 parents d89779e + a22f9ca commit 2f2fcd5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 46 deletions.
47 changes: 2 additions & 45 deletions src/sempy_labs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
)
from sempy_labs._capacities import (
create_fabric_capacity,
# get_capacity_resource_governance,
# list_vcores,
resume_fabric_capacity,
suspend_fabric_capacity,
update_fabric_capacity,
Expand Down Expand Up @@ -107,27 +105,14 @@
list_shortcuts,
get_object_level_security,
list_capacities,
# list_annotations,
# list_columns,
list_dashboards,
# list_datamarts,
# list_datapipelines,
# list_eventstreams,
# list_kpis,
# list_kqldatabases,
# list_kqlquerysets,
list_lakehouses,
# list_mirroredwarehouses,
# list_mlexperiments,
# list_mlmodels,
# list_relationships,
# list_sqlendpoints,
# list_tables,
list_warehouses,
create_warehouse,
update_item,
)
from sempy_labs._helper_functions import (
convert_to_friendly_case,
resolve_environment_id,
resolve_capacity_id,
resolve_warehouse_id,
Expand All @@ -150,10 +135,7 @@
get_capacity_id,
get_capacity_name,
resolve_capacity_name,
# language_validate
)

# from sempy_labs._model_auto_build import model_auto_build
from sempy_labs._model_bpa_bulk import (
run_model_bpa_bulk,
create_model_bpa_semantic_model,
Expand Down Expand Up @@ -184,7 +166,6 @@
from sempy_labs._translations import translate_semantic_model
from sempy_labs._vertipaq import (
vertipaq_analyzer,
# visualize_vertipaq,
import_vertipaq_analyzer,
)

Expand Down Expand Up @@ -218,23 +199,9 @@
"deploy_semantic_model",
"get_semantic_model_bim",
"get_object_level_security",
#'list_annotations',
#'list_columns',
"list_dashboards",
"list_dataflow_storage_accounts",
#'list_datamarts',
#'list_datapipelines',
#'list_eventstreams',
#'list_kpis',
#'list_kqldatabases',
#'list_kqlquerysets',
"list_lakehouses",
#'list_mirroredwarehouses',
#'list_mlexperiments',
#'list_mlmodels',
#'list_relationships',
#'list_sqlendpoints',
#'list_tables',
"list_warehouses",
"list_workspace_role_assignments",
"create_warehouse",
Expand All @@ -251,8 +218,6 @@
"resolve_dataset_name",
"resolve_report_id",
"resolve_report_name",
# 'language_validate',
# "model_auto_build",
"model_bpa_rules",
"run_model_bpa",
"measure_dependency_tree",
Expand Down Expand Up @@ -327,17 +292,9 @@
"migrate_capacities",
"create_fabric_capacity",
"migrate_capacity_settings",
# "get_capacity_resource_governance",
# "list_vcores",
"migrate_disaster_recovery_settings",
"migrate_notification_settings",
"migrate_access_settings",
"migrate_delegated_tenant_settings",
"resume_fabric_capacity",
"suspend_fabric_capacity",
"update_fabric_capacity",
"delete_fabric_capacity",
"check_fabric_capacity_name_availablility",
"delete_embedded_capacity",
"delete_premium_capacity",
"convert_to_friendly_case",
]
24 changes: 24 additions & 0 deletions src/sempy_labs/_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,3 +1056,27 @@ def resolve_environment_id(environment: str, workspace: Optional[str] = None) ->
def make_clickable(val):

return f'<a target="_blank" href="{val}">{val}</a>'


def convert_to_friendly_case(text: str) -> str:
"""
Converts a string of pascal/camel/snake case to business-friendly case.
Parameters
----------
text : str
The text to convert.
Returns
-------
str
Text converted into a business-friendly text.
"""
if text is not None:
text = text.replace("_", " ")
# Insert space before each capital letter, avoiding double spaces
text = re.sub(r"(?<!\s)(?=[A-Z])", " ", text)
# Strip leading/trailing whitespace and capitalize the first letter of each word
text = text.strip().title()

return text
11 changes: 11 additions & 0 deletions tests/test_friendly_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from sempy_labs._helper_functions import convert_to_friendly_case


def test_convert_to_friendly_case():

assert convert_to_friendly_case('MyNewTable34') == 'My New Table34'

assert convert_to_friendly_case('Testing_my_new function') == 'Testing My New Function'

assert convert_to_friendly_case('testingMyNewFunction') == 'Testing My New Function'
assert convert_to_friendly_case(None) is None
2 changes: 1 addition & 1 deletion tests/test_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def resolve_workspace_id_mock_side_effect(workspace_name):

if workspace_name == "destination_workspace":
return "00000000-0000-0000-0000-000000000002"

assert False, f"Unexpected workspace: {workspace_name}"

resolve_workspace_id_mock.side_effect = resolve_workspace_id_mock_side_effect
Expand Down

0 comments on commit 2f2fcd5

Please sign in to comment.