Skip to content

Commit

Permalink
Allows for checking whether page.some_property exists more easily, wi…
Browse files Browse the repository at this point in the history
…thout hasattr.
  • Loading branch information
arjun-menon committed Nov 23, 2024
1 parent 8989f95 commit 87004ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions alteza/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ def gitFirstAuthDate(self) -> Optional[date]:
return None
return None

def __getattr__(self, attr: str) -> None:
"""Allows for checking whether page.some_property exists more easily (without `hasattr`)."""
return None


class PyPageNode(PageNode):
def __init__(self, parent: Optional[DirNode], dirPath: str, fileName: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion test_content/sectionK/sectionM/index.py.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h4>
{{file.title}}
</a>
{{
if hasattr(file, 'x1y'):
if file.x1y:
write('&nbsp; &nbsp;' + file.x1y)
}}
</li>
Expand Down

0 comments on commit 87004ea

Please sign in to comment.