Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
import os
|
|
|
|
from .utils import load_json_file, path_exists, save_json_file
|
|
|
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
USERDATA = os.path.join(THIS_DIR, '..', 'userdata')
|
|
|
|
|
|
def read_userdata_file(rel_path: str):
|
|
"""Reads a file from the userdata directory."""
|
|
file_path = clean_path(rel_path)
|
|
if path_exists(file_path):
|
|
with open(file_path, 'r', encoding='UTF-8') as file:
|
|
return file.read()
|
|
return None
|
|
|
|
|
|
def save_userdata_file(rel_path: str, content: str):
|
|
"""Saves a file from the userdata directory."""
|
|
file_path = clean_path(rel_path)
|
|
with open(file_path, 'w+', encoding='UTF-8') as file:
|
|
file.write(content)
|
|
|
|
|
|
def delete_userdata_file(rel_path: str):
|
|
"""Deletes a file from the userdata directory."""
|
|
file_path = clean_path(rel_path)
|
|
if os.path.isfile(file_path):
|
|
os.remove(file_path)
|
|
|
|
|
|
def read_userdata_json(rel_path: str):
|
|
"""Reads a json file from the userdata directory."""
|
|
file_path = clean_path(rel_path)
|
|
return load_json_file(file_path)
|
|
|
|
|
|
def save_userdata_json(rel_path: str, data: dict):
|
|
"""Saves a json file from the userdata directory."""
|
|
file_path = clean_path(rel_path)
|
|
return save_json_file(file_path, data)
|
|
|
|
|
|
def clean_path(rel_path: str):
|
|
"""Cleans a relative path by splitting on forward slash and os.path.joining."""
|
|
cleaned = USERDATA
|
|
paths = rel_path.split('/')
|
|
for path in paths:
|
|
cleaned = os.path.join(cleaned, path)
|
|
return cleaned
|