mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-11 13:58:58 +00:00
feat(agent): Release agent SDK (#1396)
This commit is contained in:
30
dbgpt/agent/util/cmp.py
Normal file
30
dbgpt/agent/util/cmp.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Compare string utility functions."""
|
||||
import string
|
||||
|
||||
|
||||
def cmp_string_equal(
|
||||
a: str,
|
||||
b: str,
|
||||
ignore_case: bool = False,
|
||||
ignore_punctuation: bool = False,
|
||||
ignore_whitespace: bool = False,
|
||||
) -> bool:
|
||||
"""Compare two strings are equal or not.
|
||||
|
||||
Args:
|
||||
a(str): The first string.
|
||||
b(str): The second string.
|
||||
ignore_case(bool): Ignore case or not.
|
||||
ignore_punctuation(bool): Ignore punctuation or not.
|
||||
ignore_whitespace(bool): Ignore whitespace or not.
|
||||
"""
|
||||
if ignore_case:
|
||||
a = a.lower()
|
||||
b = b.lower()
|
||||
if ignore_punctuation:
|
||||
a = a.translate(str.maketrans("", "", string.punctuation))
|
||||
b = b.translate(str.maketrans("", "", string.punctuation))
|
||||
if ignore_whitespace:
|
||||
a = "".join(a.split())
|
||||
b = "".join(b.split())
|
||||
return a == b
|
Reference in New Issue
Block a user