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

Support lists in --arguments #404

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions homeassistant_cli/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from http.client import HTTPConnection
import json
import logging
import ast
import shlex
from typing import Any, Dict, Generator, List, Optional, Tuple, Union, cast

Expand All @@ -25,9 +26,16 @@ def to_attributes(entry: str) -> Dict[str, str]:
lexer.whitespace_split = True
lexer.whitespace = ','
attributes_dict = {} # type: Dict[str, str]
attributes_dict = dict(
pair.split('=', 1) for pair in lexer # type: ignore
)
for pair in lexer:
if '=' not in pair:
continue
key, value = pair.split('=', 1)
if value.strip().startswith('[') and value.strip().endswith(']'):
try:
value = ast.literal_eval(value)
except Exception:
pass
attributes_dict[key] = value
return attributes_dict


Expand Down