Convert config object to query string for LIT URL.
(self)
| 68 | datapoints: Optional[Sequence[JsonDict]] = None |
| 69 | |
| 70 | def get_query_str(self): |
| 71 | """Convert config object to query string for LIT URL.""" |
| 72 | def _encode(v): |
| 73 | if isinstance(v, (list, tuple)): |
| 74 | return ','.join(v) |
| 75 | return v |
| 76 | |
| 77 | string_params = { |
| 78 | k: _encode(v) |
| 79 | for k, v in attr.asdict(self).items() |
| 80 | if (v is not None and k != 'datapoints') |
| 81 | } |
| 82 | if self.datapoints: |
| 83 | for i, ex in enumerate(self.datapoints): |
| 84 | for field in ex: |
| 85 | string_params[f'data{i}_{field}'] = _encode(ex[field]) |
| 86 | |
| 87 | return '?' + urllib.parse.urlencode(string_params) |
| 88 | |
| 89 | |
| 90 | class LitWidget(object): |
no outgoing calls
no test coverage detected