rfhub2
rfhub2 copied to clipboard
Refactor statistics extractor to use Robot API visitor
It's proposal of refactor for extracting keywords from result using Robot parsing API visitors.
It should be tiny bit faster on larger files (150Mb+). I did not test it thorougly yet - it's draft.
Thanks @bhirsz, it looks good! If you could also add tests for that it would be great.
@bhirsz I was looking into that one, and one thing is bottering me. Which robotframework version is intended to use with this feature? 3.2.2 seems to be not enough:
File "C:\repo\rfhub2\rfhub2\cli\statistics\statistics_extractor.py", line 15, in visit_keyword
keyword.body.visit(self)
AttributeError: 'Keyword' object has no attribute 'body'
If this feature needs RFWK 4.0 I will mark it appropriate Milestone.
@MaciejWiczk I apologise for leaving this PR - I was bit busy recently. It should support 3.2 with one change - in RF4 "keywords" attribute was renamed to body. So depending on version you should access it with different name
But when I think about it its possible we could replace that line with self.generic_visit (and it should work for both 3.2 and 4)
I apologise for leaving this PR - I was bit busy recently.
You've been busy, with great results! :)
But when I think about it its possible we could replace that line with self.generic_visit (and it should work for both 3.2 and 4)
Oh cool, I will take a look at this approach and see what's what :)
@bhirsz is this what You mean:
def visit_keyword(self, keyword):
try:
keyword.body.visit(self)
except AttributeError:
keyword.keywords.visit(self)
self.statistics[keyword.name].append(keyword)