-
Notifications
You must be signed in to change notification settings - Fork 782
JavaScript parser improvement #1176
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
918b48e to
eae867d
Compare
|
Fixes #323 |
|
Need to take a look on few things:
|
pekkaklarck
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.
Looks good. Some nitpickey line notes added. I'll review the code related to finding JS code and arguments when I got time.
| return self.driver.execute_script(js) | ||
| js_code, js_args = self._get_javascript_to_execute(code) | ||
| self.info('Executing JavaScript:\n%s\nBy using argument(s):\n"%s"' | ||
| % (js_code, ', '.join(js_args))) |
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.
Logging could be enhanced a little:
- Better not to mention anything about arguments if there are none. Current
""looks odd. - Instead of
"argument(s):"it's possible to use"argument%s:" % robot.utils.plural_or_not(js_args)to get the trailingswhen needed. - Quotes around arguments like
"first, second"look a bit strange. I'd consider omitting them altogether or alternatively quoting each argument separately. In the latter caserobot.utils.seq2strorseq2str2might be worth a look. Just loggingjs_argsas-is would be fine otherwise as well, but theuprefixes with Unicode strings inside a list in Python 2 are annoying.
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 did not know that such utils did exist. I definitely will take a look.
| return code | ||
| js_code, js_args = self._get_javascript_to_execute(code) | ||
| self.info('Executing Asynchronous JavaScript:\n%s\nBy using argument(s):\n"%s"' | ||
| % (js_code, ', '.join(js_args))) |
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.
Same comment about logging as above. Logging should probably be done using a helper.
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.
Helper is good idea. Will definitely take a look.
| js_code.append(line) | ||
| if get_args: | ||
| js_args.append(line) | ||
| return js_code, js_args |
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.
This looks a bit complicated. Don't have time to look at more closely could it be improved. Will look again later.
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.
Yes, it's complicated. At least raising an error could be moved to a separate method. Need to think what else could be done.
No description provided.