-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d9472c
commit 0305fc0
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import json | ||
import os | ||
from pathlib import Path | ||
|
||
from scripts.lib.lobe_log import LobeLog | ||
|
||
EXTENSION_FOLDER = Path(__file__).parent.parent.parent | ||
PACKAGE_FILENAME = Path(EXTENSION_FOLDER, "package.json") | ||
|
||
|
||
LobeLog.debug(f"EXTENSION_FOLDER: {EXTENSION_FOLDER}") | ||
LobeLog.debug(f"PACKAGE_FILENAME: {PACKAGE_FILENAME}") | ||
|
||
|
||
class LobePackage: | ||
def __init__(self): | ||
self.package_file = PACKAGE_FILENAME | ||
self.package = None | ||
self.load_package() | ||
|
||
def load_package(self): | ||
if os.path.exists(self.package_file): | ||
LobeLog.debug(f"Loading package from package.json") | ||
|
||
with open(self.package_file, 'r') as f: | ||
self.package = json.load(f) | ||
else: | ||
LobeLog.debug(f"Package file not found") | ||
self.package = LobeConfig.default() | ||
|
||
def is_empty(self): | ||
return "empty" in self.package and self.package['empty'] | ||
|
||
def json(self): | ||
return json.dumps(self.package) | ||
|
||
@staticmethod | ||
def default(): | ||
# default package is handled from client side @see src/store/index.tsx | ||
return {'empty': True} |