Skip to content

Commit f8dbf25

Browse files
committed
added support for measures and hierarchies
1 parent 3d71629 commit f8dbf25

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

src/sempy_labs/_icons.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
green_dot = "\U0001F7E2"
2-
yellow_dot = "\U0001F7E1"
3-
red_dot = "\U0001F534"
1+
green_dot = "\U0001f7e2"
2+
yellow_dot = "\U0001f7e1"
3+
red_dot = "\U0001f534"
44
in_progress = "⌛"
55
checked = "\u2611"
66
unchecked = "\u2610"
77
start_bold = "\033[1m"
88
end_bold = "\033[0m"
99
bullet = "\u2022"
1010
warning = "⚠️"
11-
error = "\u274C"
11+
error = "\u274c"
1212
info = "ℹ️"
1313
measure_icon = "\u2211"
14-
table_icon = "\u229E"
15-
column_icon = "\u229F"
14+
table_icon = "\u229e"
15+
column_icon = "\u229f"
1616
model_bpa_name = "ModelBPA"
1717
report_bpa_name = "ReportBPA"
1818
severity_mapping = {warning: "Warning", error: "Error", info: "Info"}

src/sempy_labs/report/_report_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def report_dependency_tree(workspace: Optional[str | UUID] = None):
119119
dfR.rename(columns={"Name": "Report Name"}, inplace=True)
120120
dfR = dfR[["Report Name", "Dataset Name"]]
121121

122-
report_icon = "\U0001F4F6"
123-
dataset_icon = "\U0001F9CA"
124-
workspace_icon = "\U0001F465"
122+
report_icon = "\U0001f4f6"
123+
dataset_icon = "\U0001f9ca"
124+
workspace_icon = "\U0001f465"
125125

126126
node_dict = {}
127127
rootNode = Node(workspace_name)

src/sempy_labs/tom/_model.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4842,7 +4842,7 @@ def _get_synonym_info(
48424842
def set_synonym(
48434843
self,
48444844
culture: str,
4845-
object: Union["TOM.Table", "TOM.Column"],
4845+
object: Union["TOM.Table", "TOM.Column", "TOM.Measure", "TOM.Hierarchy"],
48464846
synonym_name: str,
48474847
weight: Optional[Decimal] = None,
48484848
):
@@ -4851,12 +4851,12 @@ def set_synonym(
48514851

48524852
object_type = object.ObjectType
48534853

4854-
if not any(c.Name == culture for c in self.model.Cultures):
4855-
raise ValueError(
4856-
f"{icons.red_dot} The '{culture}' culture does not exist within the semantic model."
4857-
)
4858-
4859-
if object_type not in [TOM.ObjectType.Table, TOM.ObjectType.Column]:
4854+
if object_type not in [
4855+
TOM.ObjectType.Table,
4856+
TOM.ObjectType.Column,
4857+
TOM.ObjectType.Measure,
4858+
TOM.ObjectType.Hierarchy,
4859+
]:
48604860
raise ValueError(
48614861
f"{icons.red_dot} This function only supports adding synonyms for tables or columns."
48624862
)
@@ -4865,9 +4865,7 @@ def set_synonym(
48654865
self._add_linguistic_schema(culture=culture)
48664866

48674867
# Extract linguistic metadata content
4868-
c = self.model.Cultures[culture]
4869-
lm_content = c.LinguisticMetadata.Content
4870-
lm = json.loads(lm_content)
4868+
lm = json.loads(self.model.Cultures[culture].LinguisticMetadata.Content)
48714869

48724870
# Generate synonym dictionary
48734871
_validate_weight(weight)
@@ -4916,7 +4914,9 @@ def set_synonym(
49164914
del lm["Entities"][obj]["State"]
49174915

49184916
if updated:
4919-
c.LinguisticMetadata.Content = json.dumps(lm, indent=4)
4917+
self.model.Cultures[culture].LinguisticMetadata.Content = json.dumps(
4918+
lm, indent=4
4919+
)
49204920
if object_type == TOM.ObjectType.Table:
49214921
print(
49224922
f"{icons.green_dot} The '{synonym_name}' synonym was set for the '{object.Name}' table."
@@ -4929,7 +4929,7 @@ def set_synonym(
49294929
def delete_synonym(
49304930
self,
49314931
culture: str,
4932-
object: Union["TOM.Table", "TOM.Column"],
4932+
object: Union["TOM.Table", "TOM.Column", "TOM.Measure", "TOM.Hierarchy"],
49334933
synonym_name: str,
49344934
):
49354935

@@ -4940,14 +4940,17 @@ def delete_synonym(
49404940
f"{icons.red_dot} The '{culture}' culture does not exist within the semantic model."
49414941
)
49424942

4943-
if object.ObjectType not in [TOM.ObjectType.Table, TOM.ObjectType.Column]:
4943+
if object.ObjectType not in [
4944+
TOM.ObjectType.Table,
4945+
TOM.ObjectType.Column,
4946+
TOM.ObjectType.Measure,
4947+
TOM.ObjectType.Hierarchy,
4948+
]:
49444949
raise ValueError(
49454950
f"{icons.red_dot} This function only supports tables or columns."
49464951
)
49474952

4948-
c = self.model.Cultures[culture]
4949-
lm_content = c.LinguisticMetadata.Content
4950-
lm = json.loads(lm_content)
4953+
lm = json.loads(self.model.Cultures[culture].LinguisticMetadata.Content)
49514954

49524955
if "Entities" not in lm:
49534956
print(
@@ -4971,7 +4974,9 @@ def delete_synonym(
49714974
None,
49724975
)
49734976

4974-
c.LinguisticMetadata.Content = json.dumps(lm, indent=4)
4977+
self.model.Cultures[culture].LinguisticMetadata.Content = json.dumps(
4978+
lm, indent=4
4979+
)
49754980
print(
49764981
f"{icons.green_dot} The '{synonym_name}' synonym was marked as status 'Deleted' for the '{object.Name}' object."
49774982
)

0 commit comments

Comments
 (0)