Skip to content

Commit

Permalink
Drop no longer used tmt.utils.listify()
Browse files Browse the repository at this point in the history
I suppose it was replaced by other "listify me this" functions, but it's
no longer used.
  • Loading branch information
happz authored and psss committed Jan 4, 2024
1 parent 8bc3273 commit 15cc721
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
11 changes: 0 additions & 11 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
filter_paths,
git_add,
inject_auth_git_url,
listify,
public_git_url,
validate_git_status,
wait,
Expand Down Expand Up @@ -195,16 +194,6 @@ def test_inject_auth_git_url(monkeypatch) -> None:
inject_auth_git_url('https://example.com/broken/something')


def test_listify():
""" Check listify functionality """
assert listify(['abc']) == ['abc']
assert listify('abc') == ['abc']
assert listify('a b c') == ['a b c']
assert listify('a b c', split=True) == ['a', 'b', 'c']
assert listify({'a': 1, 'b': 2}) == {'a': [1], 'b': [2]}
assert listify({'a': 1, 'b': 2}, keys=['a']) == {'a': [1], 'b': 2}


def test_config():
""" Config smoke test """
run = Path('/var/tmp/tmt/test')
Expand Down
24 changes: 0 additions & 24 deletions tmt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,30 +1935,6 @@ def ascii(text: Any) -> bytes:
return unicodedata.normalize('NFKD', text).encode('ascii', 'ignore')


def listify(
data: Union[tuple[Any, ...], list[Any], str, dict[Any, Any]],
split: bool = False,
keys: Optional[list[str]] = None) -> Union[list[Any], dict[Any, Any]]:
"""
Ensure that variable is a list, convert if necessary
For dictionaries check all items or only those with provided keys.
Also split strings on white-space/comma if split=True.
"""
separator = re.compile(r'[\s,]+')
if isinstance(data, tuple):
data = list(data)
if isinstance(data, list):
return fmf.utils.split(data, separator) if split else data
if isinstance(data, str):
return fmf.utils.split(data, separator) if split else [data]
if isinstance(data, dict):
for key in keys or data:
if key in data:
data[key] = listify(data[key], split=split)
return data
return [data]


def copytree(
src: Path,
dst: Path,
Expand Down

0 comments on commit 15cc721

Please sign in to comment.