示例#1
0
def test_str_to_list():
    data = """
A # 1
b

c
b
    """
    assert str_to_list(data) == ["A # 1", "b", "c", "b"]
    assert str_to_list(data, lower=True, remove_comments=True, unique=True) == ["a", "b", "c"]
示例#2
0
def parse_nodes(value: Union[list[str], str]) -> list[str]:
    if isinstance(value, list):
        return pydash.union(value)
    elif isinstance(value, str):
        return str_to_list(value, unique=True)
    else:
        raise ValueError(f"wrong nodes type: {type(value)}")
示例#3
0
 def to_list(cls, v):
     if v is None:
         return []
     if isinstance(v, str):
         return str_to_list(v, unique=True, remove_comments=True)
     return v
示例#4
0
 def list_validator(cls, v):
     if isinstance(v, str):
         return str_to_list(v, unique=True)
     return v