Skip to content

Commit

Permalink
fix: enum
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Dec 31, 2024
1 parent b43151e commit 8f8a20f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion .dev/update-hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@

from sd_webui_pnginfo_injection.bundle_hashes import myBundleHashesSettings

class ANSI:
RESET,BOLD,FAINT,ITALIC,UNDERLINE,INVERSE,STRIKE,NO_BOLD,NO_FAINT,NO_ITALIC,NO_UNDERLINE,NO_INVERSE,NO_STRIKE,\
BLACK,RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITE,BBLACK,BRED,BGREEN,BYELLOW,BBLUE,BMAGENTA,BCYAN,BWHITE\
= ["\x1b[%im"%i for i in (0,1,2,3,4,7,9,21,22,23,24,27,29,30,31,32,33,34,35,36,37,90,91,92,93,94,95,96,97)]

@staticmethod
def rgb(r,g,b): return "\x1b[38;2;%i;%i;%im"%(r,g,b)

def printColor(text, color: str = None):
print(f"{color}{text}{ANSI.RESET}") if color else print(text)

def get_model_hashes(id: str | int, api_key: str = None):
# token = api_key
# if not token:
Expand Down Expand Up @@ -75,16 +86,23 @@ def update_bundle_hashes(api_key: str = None):
script_path = os.path.abspath(__file__)
bundle_hashes_file = os.path.join(os.path.dirname(script_path), "../sd_webui_pnginfo_injection/bundle_hashes.py")

print(f"bundle_hashes_file: {bundle_hashes_file}")

if len(my_map):
with open(bundle_hashes_file, "r") as file:
lines = file.readlines()

for i, line in enumerate(lines):

for hashes_name, auto_v2_hash in my_map.items():
old_hash = hashes_name.value
hashes_name = hashes_name.name
if f"{hashes_name} = " in line:
lines[i] = f' {hashes_name} = "{auto_v2_hash}"\n'
print(f"Updated {hashes_name} value to {auto_v2_hash} in {bundle_hashes_file}")
if old_hash != auto_v2_hash:
printColor(f"Updated {hashes_name} value {old_hash} to {auto_v2_hash}", ANSI.RED)
else:
printColor(f"Skipped {hashes_name} value {old_hash}", ANSI.BLUE)

# if C0rn_Fl4k3s:
# hashes_name = 'C0rn_Fl4k3s'
Expand Down
4 changes: 2 additions & 2 deletions sd_webui_pnginfo_injection/bundle_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EnumBundleHashes(Enum):
#

# https://civitai.com/models/449400
lazy_wildcards = "566FACEC5D"
lazy_wildcards = "A89E1CB606"

#

Expand All @@ -38,7 +38,7 @@ class EnumBundleHashes(Enum):
#

# https://civitai.com/models/989125
tglove = "C751EFD866"
tglove = "C0203E2711"

#

Expand Down

0 comments on commit 8f8a20f

Please sign in to comment.