Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop no longer used tmt.utils.listify() #2576

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading