-
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
base: master
Are you sure you want to change the base?
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.25% 91.92% -0.34%
==========================================
Files 376 376
Lines 22054 21057 -997
==========================================
- Hits 20346 19356 -990
+ Misses 1708 1701 -7 ☔ View full report in Codecov by Sentry. |
also added new jinja filter for sorting dict lists by key
bdfc638
to
29b877e
Compare
No description provided.