Skip to content

Commit

Permalink
chore: move get_asset to base class
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 1, 2023
1 parent 4a4f94f commit 418966c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mknodes/utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ def resolved_filename(self) -> str:
else f"{hashed}{self.EXTENSION}"
)

def get_asset(self) -> Asset:
return Asset(filename=self.resolved_filename, content=self.content)

def __hash__(self):
return hash(self.content)

Expand All @@ -176,6 +179,9 @@ def to_html(self) -> str:
# content = self.content.replace("\n", "")
return f"<style>\n{self.content}\n</style>"

def get_cssfile(self) -> CSSFile:
return CSSFile(link=self.resolved_filename)


@dataclasses.dataclass(frozen=True, repr=False)
class JSText(TextResource):
Expand All @@ -200,9 +206,6 @@ def get_jsfile(self) -> JSFile:
is_library=self.is_library,
)

def get_asset(self) -> Asset:
return Asset(filename=self.resolved_filename, content=self.content)


class Asset:
"""An asset resource."""
Expand Down

0 comments on commit 418966c

Please sign in to comment.