Skip to content

Commit

Permalink
🔧 MAINTAIN: Add Node.base
Browse files Browse the repository at this point in the history
This is a pre-cursor to moving methods off of the `Node` top level
namespace.
  • Loading branch information
chrisjsewell authored and sphuber committed Apr 6, 2022
1 parent e56b3cc commit aa2c1ac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions aiida/orm/nodes/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""Package for node ORM classes."""
import copy
import datetime
from functools import cached_property
import importlib
from logging import Logger
from typing import (
Expand Down Expand Up @@ -101,6 +102,14 @@ def iter_repo_keys(self,
yield key


class NodeBase:
"""A namespace for node related functionality, that is not directly related to its user-facing properties."""

def __init__(self, node: 'Node') -> None:
"""Construct a new instance of the base namespace."""
self._node: 'Node' = node


class Node(
Entity['BackendNode'], NodeRepositoryMixin, EntityAttributesMixin, EntityExtrasMixin, metaclass=AbstractNodeMeta
):
Expand Down Expand Up @@ -177,6 +186,11 @@ def __init__(
)
super().__init__(backend_entity)

@cached_property
def base(self) -> NodeBase:
"""Return the node base namespace."""
return NodeBase(self)

def __eq__(self, other: Any) -> bool:
"""Fallback equality comparison by uuid (can be overwritten by specific types)"""
if isinstance(other, Node) and self.uuid == other.uuid:
Expand Down

0 comments on commit aa2c1ac

Please sign in to comment.