wip: add metadata mapping, reading and writing

applying data after reading currently not functional for A1111
This commit is contained in:
Manuel Schmid
2024-01-28 05:35:44 +01:00
parent 051faf78b8
commit f3010313fc
8 changed files with 434 additions and 285 deletions
+12 -1
View File
@@ -178,6 +178,7 @@ def get_files_from_folder(folder_path, exensions=None, name_filter=None):
return sorted(filenames, key=lambda x: -1 if os.sep in x else 1)
def calculate_sha256(filename):
hash_sha256 = sha256()
blksize = 1024 * 1024
@@ -188,8 +189,18 @@ def calculate_sha256(filename):
return hash_sha256.hexdigest()
def quote(text):
if ',' not in str(text) and '\n' not in str(text) and ':' not in str(text):
return text
return json.dumps(text, ensure_ascii=False)
return json.dumps(text, ensure_ascii=False)
def is_json(data: str) -> bool:
try:
loaded_json = json.loads(data)
assert isinstance(loaded_json, dict)
except ValueError:
return False
return True