From 88abfbef888fee1c07c2a6aecbe998cc1fd05ce8 Mon Sep 17 00:00:00 2001 From: Ruge Li Date: Thu, 7 Sep 2023 11:56:04 -0700 Subject: [PATCH] integrate DATABASE_NAMES into interface_objects --- cellpack/autopack/__init__.py | 13 +++++-------- cellpack/autopack/interface_objects/database_ids.py | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cellpack/autopack/__init__.py b/cellpack/autopack/__init__.py index 7ceeaebcc..79907f02e 100755 --- a/cellpack/autopack/__init__.py +++ b/cellpack/autopack/__init__.py @@ -49,8 +49,8 @@ import json from cellpack.autopack.DBRecipeHandler import DBRecipeLoader from cellpack.autopack.FirebaseHandler import FirebaseHandler +from cellpack.autopack.interface_objects.database_ids import DATABASE_IDS -from cellpack.autopack.interface_objects.meta_enum import MetaEnum from cellpack.autopack.loaders.utils import read_json_file, write_json_file @@ -196,19 +196,16 @@ def checkPath(): autopackdir = pref_path["autopackdir"] -class DATABASE_NAME(MetaEnum): - GITHUB = "github:" - FIREBASE = "firebase:" - REPLACE_PATH = { "autoPACKserver": autoPACKserver, "autopackdir": autopackdir, "autopackdata": appdata, - DATABASE_NAME.GITHUB: autoPACKserver, - DATABASE_NAME.FIREBASE: None, + f"{DATABASE_IDS.GITHUB}:": autoPACKserver, + f"{DATABASE_IDS.FIREBASE}:": None, } + global CURRENT_RECIPE_PATH CURRENT_RECIPE_PATH = appdata # we keep the file here, it come with the distribution @@ -284,7 +281,7 @@ def is_remote_path(file_path): """ @param file_path: str """ - for ele in DATABASE_NAME: + for ele in DATABASE_IDS.with_colon(): if ele in file_path: return True diff --git a/cellpack/autopack/interface_objects/database_ids.py b/cellpack/autopack/interface_objects/database_ids.py index 688ad5198..a85fbb968 100644 --- a/cellpack/autopack/interface_objects/database_ids.py +++ b/cellpack/autopack/interface_objects/database_ids.py @@ -4,3 +4,7 @@ class DATABASE_IDS(MetaEnum): FIREBASE = "firebase" GITHUB = "github" + + @classmethod + def with_colon(cls): + return [f"{ele}:" for ele in cls.values()]