Skip to content

Commit

Permalink
Override boolean operator in Rules to return True when all lines in a…
Browse files Browse the repository at this point in the history
… rule are commented
  • Loading branch information
vmitsenko committed Apr 20, 2024
1 parent 7a16703 commit 0221f3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TM1py/Objects/Cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _construct_body(self) -> str:
body_as_dict['[email protected]'] = [format_url("Dimensions('{}')", dimension)
for dimension
in self.dimensions]
if str(self.rules):
if self.has_rules:
body_as_dict['Rules'] = str(self.rules)
return json.dumps(body_as_dict, ensure_ascii=False)

Expand Down
5 changes: 5 additions & 0 deletions TM1py/Objects/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@ def __iter__(self):

def __str__(self):
return self.text

def __bool__(self):
if len(self.text):
return True
return False

0 comments on commit 0221f3b

Please sign in to comment.