MCPcopy Index your code
hub / github.com/StackStorm/st2 / format

Method format

st2client/st2client/formatters/doc.py:34–59  ·  view source on GitHub ↗
(self, subject, *args, **kwargs)

Source from the content-addressed store, hash-verified

32class BaseFormatter(formatters.Formatter):
33 @classmethod
34 def format(self, subject, *args, **kwargs):
35 attributes = kwargs.get("attributes", None)
36 if type(subject) is str:
37 subject = orjson.loads(subject)
38 elif not isinstance(subject, (list, tuple)) and not hasattr(
39 subject, "__iter__"
40 ):
41 doc = subject if isinstance(subject, dict) else subject.__dict__
42 keys = (
43 list(doc.keys())
44 if not attributes or "all" in attributes
45 else attributes
46 )
47 docs = jsutil.get_kvps(doc, keys)
48 else:
49 docs = []
50 for item in subject:
51 doc = item if isinstance(item, dict) else item.__dict__
52 keys = (
53 list(doc.keys())
54 if not attributes or "all" in attributes
55 else attributes
56 )
57 docs.append(jsutil.get_kvps(doc, keys))
58
59 return docs
60
61
62class JsonFormatter(BaseFormatter):

Callers 15

json_2_yaml_convertFunction · 0.45
git_rmFunction · 0.45
mainFunction · 0.45
setup.pyFile · 0.45
pre_runMethod · 0.45
_get_sessionMethod · 0.45
_winrm_ps_cmdMethod · 0.45
_winrm_run_psMethod · 0.45
_make_tmp_dirMethod · 0.45
_rm_dirMethod · 0.45
_uploadMethod · 0.45

Calls 2

keysMethod · 0.80
getMethod · 0.45

Tested by 15

write_generate_filesFunction · 0.36
write_validate_filesFunction · 0.36
write_filesFunction · 0.36
write_filesFunction · 0.36
test_token_modelMethod · 0.36
setUpClassMethod · 0.36
test_ui_history_queryMethod · 0.36