mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-22 15:59:45 +08:00
Move ParseLogicError into comfy.parse.
Don't catch ParseError in comfy.choices.
This commit is contained in:
parent
5a673ee930
commit
dcb4bdfb9b
@ -3,14 +3,8 @@
|
||||
import os
|
||||
import random
|
||||
|
||||
import comfy.parse
|
||||
from comfy.parse import ParseError
|
||||
|
||||
class ParseLogicError(ParseError):
|
||||
# something that shouldn't be possible occurred in the code
|
||||
# not the user's fault
|
||||
pass
|
||||
|
||||
import comfy.parse as parse
|
||||
from comfy.parse import ParseError, ParseLogicError
|
||||
|
||||
def get_random_seed():
|
||||
return int.from_bytes(os.urandom(8))
|
||||
@ -133,12 +127,7 @@ def translate(text, seed=None, strict=True, reescape=frozenset()):
|
||||
# init our local random number generator
|
||||
rng = random.Random(seed)
|
||||
|
||||
try:
|
||||
input = comfy.parse.Cursor(text)
|
||||
out = parse_text_with_choices_outer(input)
|
||||
return out
|
||||
except (ParseError) as e:
|
||||
# alternative: re-throw the error
|
||||
stdout.write(f'Error parsing prompt: {e}');
|
||||
return text
|
||||
input = parse.Cursor(text)
|
||||
out = parse_text_with_choices_outer(input)
|
||||
return out
|
||||
|
||||
|
||||
@ -10,6 +10,12 @@ class ParseError(Exception):
|
||||
def __str__(self):
|
||||
return f'{self.message} {self.input.loc()}'
|
||||
|
||||
class ParseLogicError(ParseError):
|
||||
# like a ParseError, in that it has an associated cursor position which will help in understanding the error
|
||||
# but unlike a ParseError, because it wasn't the user's fault
|
||||
# something that shouldn't be possible occurred in the code
|
||||
pass
|
||||
|
||||
|
||||
class Cursor:
|
||||
def __init__(self, text, skip_space=False, consume=True, space=r'\s+'):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user