Skip to content

Commit

Permalink
Added registry for saved penpot designs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Panchenko committed May 27, 2024
1 parent a6d9548 commit 53a5954
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/penai/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ def remote_storage(self) -> RemoteStorageConfig:
return RemoteStorageConfig(**storage_config)

def data_basedir(
self, stage: DataStage = "raw", relative: bool = False, check_existence: bool = False
self,
stage: DataStage = "raw",
relative: bool = False,
check_existence: bool = False,
) -> str:
result = self._data_basedir(stage)
return self._adjusted_path(result, relative=relative, check_existence=check_existence)

def penpot_designs_basedir(self, relative: bool = False, check_existence: bool = False) -> str:
result = self.datafile_path("designs", stage="raw")
return self._adjusted_path(result, relative=relative, check_existence=check_existence)

@property
def openai_api_key(self) -> str:
return cast(str, self._get_non_empty_entry("openai_api_key"))
Expand Down
36 changes: 36 additions & 0 deletions src/penai/registries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import logging
import os
from enum import Enum

from penai.config import get_config, pull_from_remote

log = logging.getLogger(__name__)


# Turn above list into an Enum
class SavedPenpotDesign(Enum):
AVATAAARS = "Avataaars by Pablo Stanley"
BLACK_AND_WHITE_MOBILE_TEMPLATES = "Black & White Mobile Templates"
COMMUNITY_CARDS_GRID_THEME = "Community - Cards grid theme"
INTERACTIVE_MUSIC_APP = "Interactive music app"
MASTODON_SOCIAL_APP = "Mastodon Social App"
MATERIAL_DESIGN_3 = "Material Design 3"
NEXTCLOUD_DESIGN_SYSTEM = "Nextcloud design system"
PLANTS_APP = "Plants app"
UX_NOTES = "UX Notes"
WIREFRAMING_KIT = "Wireframing kit"

def get_project_name(self) -> str:
return self.value

def get_path(self, pull: bool = False) -> str:
result = os.path.join(get_config().penpot_designs_basedir(), self.get_project_name())
if pull:
log.info(f"Pulling data for project {self.get_project_name()} to {result}")
pull_from_remote(result)
return result

@classmethod
def pull_all(cls) -> None:
for design in cls:
design.get_path(pull=True)

0 comments on commit 53a5954

Please sign in to comment.