-
Notifications
You must be signed in to change notification settings - Fork 6
Refactor side methods #27
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
Conversation
|
@lvrfrc87 ping me when you are available and we can talk about it. |
|
Meeting set-up for 11th Jan at 11.30 GMT +1 |
lvrfrc87
left a comment
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.
Few comments/notes
| Returns: | ||
| Evaluated data, may be anything depending on JMESPath used. | ||
| """ | ||
| if exclude and isinstance(output, Dict): |
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.
NOTE: would need to test what is returned if exclude is an empty list or enforce list length
| if not any(isinstance(i, list) for i in values): # check for multi-nested lists if not found return here | ||
| return values | ||
|
|
||
| for element in values: # process elements to check is lists should be flatten |
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.
If I am not mistaken, this data structure (nested list) is required in order to associate the reference key with each value. FYI: @grelleum
| # TODO: Not sure how this is working becasyse from `jmespath.search` it's supposed to get a flat list | ||
| # of str or Decimals, not another list... | ||
| for item in element: | ||
| if isinstance(item, dict): # raise if there is a dict, path must be more specific to extract data |
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.
what about if not isinstance(item, list) ?
netcompare/check_type.py
Outdated
| values = flatten_list(values) # flatten list and rewrite values | ||
| break # items are the same, need to check only first to see if this is a nested list | ||
|
|
||
| paired_key_value = associate_key_of_my_value(jmspath_value_parser(path), values) |
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.
Better rename in key_value_association ?
|
|
||
| result_item = {} | ||
|
|
||
| # TODO: Why the 'value' dict has always ONE single element? we have to explain |
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.
@chadell are you saying that user can specify more than one parameter to be evaluated?
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.
why not? the method signature supports it accepting a "list of"
|
To fix the failing tolerance checks, I had to remove: from |
pszulczewski
left a comment
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.
LGMT, ship it as this is mainly file structure change.
Changes to naming and other refactors can be done with subsequent PRs.
* Consolidate extract_values_from_output into CheckType.get_value * Simplify evaluator's file to contain only entrypoints * Small changes to improve comprehension * Small code refactor and comments * rename check_type name and include the main class in package init for easier import * Consolidate utils functions into less files, with some purpose Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com>
Summary of changes:
CheckTypefrom the package initFor sure, this is not perfect, but it's a first step
This PR addresses #20 and #21, proposing a simpler way to interact with helper functions needed by CheckType.