diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-01 11:38:29 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-01 11:38:29 +0000 |
commit | d613cd17c72c753bd1e314dff74dc22d9a949374 (patch) | |
tree | 9523536c55f94938bbc0f15748e798f106eca9b3 /modules/infotext_versions.py | |
parent | d859cec696a953dbfd6f69f7735e68661748d579 (diff) | |
download | stable-diffusion-webui-gfx803-d613cd17c72c753bd1e314dff74dc22d9a949374.tar.gz stable-diffusion-webui-gfx803-d613cd17c72c753bd1e314dff74dc22d9a949374.tar.bz2 stable-diffusion-webui-gfx803-d613cd17c72c753bd1e314dff74dc22d9a949374.zip |
add automatic backwards version compatibility
Diffstat (limited to 'modules/infotext_versions.py')
-rw-r--r-- | modules/infotext_versions.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/infotext_versions.py b/modules/infotext_versions.py new file mode 100644 index 00000000..01e885a2 --- /dev/null +++ b/modules/infotext_versions.py @@ -0,0 +1,35 @@ +from modules import shared
+from packaging import version
+import re
+
+
+v160 = version.parse("1.6.0")
+
+
+def parse_version(text):
+ if text is None:
+ return None
+
+ m = re.match(r'([^-]+-[^-]+)-.*', text)
+ if m:
+ text = m.group(1)
+
+ try:
+ return version.parse(text)
+ except Exception as e:
+ return None
+
+
+def backcompat(d):
+ """Checks infotext Version field, and enables backwards compatibility options according to it."""
+
+ if not shared.opts.auto_backcompat:
+ return
+
+ ver = parse_version(d.get("Version"))
+ if ver is None:
+ return
+
+ if ver < v160:
+ d["Old prompt editing timelines"] = True
+
|