-
Notifications
You must be signed in to change notification settings - Fork 225
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
feat: converted ipc plugin to new base class #1263
Conversation
937bc7e
to
41ba3b6
Compare
'targets': [ | ||
{'name': 'whoami', 'ipc_calls': [{'type': 'system', 'arguments': ['']}]}, | ||
{'name': 'ls', 'ipc_calls': [{'type': 'system', 'arguments': ['-l']}]}, | ||
{'name': 'echo', 'ipc_calls': [{'type': 'system', 'arguments': ['hello']}]}, | ||
{'name': 'id', 'ipc_calls': [{'type': 'system', 'arguments': ['']}]}, | ||
{'name': 'pwd', 'ipc_calls': [{'type': 'system', 'arguments': ['']}]}, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target of the IPC (usually a file path or address)
How do these names (whoami
, ls
, etc.) match the documentation?
src/web_interface/filter.py
Outdated
def sort_dict_list_by_key(dict_list: list[dict], key: Any) -> list[dict]: | ||
types = {type(d.get(key)) for d in dict_list if key in d} | ||
if types not in [set(), {str}, {int}]: | ||
raise ValueError(f'Dict values must be of the same type, not {types}') | ||
return sorted(dict_list, key=lambda d: d.get(key, -9999 if types == {int} else '')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -9999 looks suspicious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure what would be appropriate here. I was hesitant to use 0 (in case there actually are negative entries) and there is no minimum int in python 3. I'm open for suggestions. The 9999 just seemed funny 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use -float("inf")
but why should this function support this at all?
I think sorting by a key that does not exist should not be supported.
IIUC the function is only used by a single plugin which guarantees this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it so that it converts the values to string while sorting which makes everything easier
41ba3b6
to
a6093ed
Compare
a6093ed
to
943948f
Compare
d83630a
to
bdfc638
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1263 +/- ##
==========================================
- Coverage 92.42% 91.85% -0.57%
==========================================
Files 379 378 -1
Lines 23661 20998 -2663
==========================================
- Hits 21869 19288 -2581
+ Misses 1792 1710 -82 ☔ View full report in Codecov by Sentry. |
bdfc638
to
29b877e
Compare
29b877e
to
f587e95
Compare
f587e95
to
b365e3c
Compare
also added new jinja filter for sorting dict lists by key
b365e3c
to
629bb50
Compare
No description provided.