Skip to content

Commit

Permalink
chore: prep
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 11, 2023
1 parent ad1afd4 commit c53d148
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion mknodes/info/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import abc

from collections.abc import Callable, Mapping
from collections.abc import Callable, Mapping, MutableMapping
import dataclasses
import datetime
import pathlib
Expand Down Expand Up @@ -263,6 +263,31 @@ class GitHubContext(Context):
"""The twitter username."""


@dataclasses.dataclass
class EnvironmentContext(MutableMapping, metaclass=abc.ABCMeta):
loader: dict = dataclasses.field(default_factory=dict)
block_start_string: str | None = None
block_end_string: str | None = None
variable_start_string: str | None = None
variable_end_string: str | None = None
undefined: str | None = None

def __getitem__(self, value):
return getattr(self, value)

def __setitem__(self, index, value):
setattr(self, index, value)

def __delitem__(self, index):
setattr(self, index, None)

def __len__(self):
return len(dataclasses.fields(self))

def __iter__(self):
return iter(i.name for i in dataclasses.fields(self))


@dataclasses.dataclass
class ContextConfig(Mapping, metaclass=abc.ABCMeta):
repo_url: str = "."
Expand Down

0 comments on commit c53d148

Please sign in to comment.