-
Notifications
You must be signed in to change notification settings - Fork 21
Python Solution #7
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
base: master
Are you sure you want to change the base?
Conversation
challenge.py
Outdated
| regex_Del = "^-(?!--).*" | ||
| regex_Add = "^\+(?!\+\+).*" | ||
| regex_region = "^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)?\ @@[ ]?.*" | ||
| regex_functionCall = "([\w]+)(?=\()" |
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 won't catch functions calls. Something like (?![a-z])[^\:,>,\.]([a-z,A-Z]+[_]*[a-z,A-Z]*)+[(] would.
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.
Hi Mathieu,
I did a comment of my approach,
I tried to use your Regex, but it took so much time in the script without giving result,
Actually, I used my regex using some example here on the following link: https://regex101.com/r/n7B3ox/5
it is catching statement too, but I filter them in the code.
Kind regards,
Amine
…will be wiped in the writing process
Hi,
I presented here a solution in Python. Where I use Regular expressions to catch (FileName, number of deleted lines, number of added lines, number of regions and the called functions and their occurrence).
The function result takes one diff file path, then it starts reading it line by line, and testing on each line if we found a match with the regular expressions that we are collecting. Even more for optimisation, we are ignoring lines where we are sure that we will not have a match with any of our regular expressions. In the end, this function returns a list of founded files, the number of deleted, added and region lines and a list of functions that were called in the diff file.
In the main function, we are considering files in the repository diffs, and read them one by one and executing result function to collect needed information. Then, combine all results together. For the list of called functions, we used a dictionary to map the occurrence of each function with the function name.
Finally, we report all results in files.
After putting results of python script in files, we used Golang main function to read these files and putting results in the result struct.
Sincerely,
Amine Barrak
Research master in Software Engineering
[email protected]