SeparateSnippets#
- diffparser.separate_snippets.sep_by_snippets(un_separated)[source]#
Takes in an unfiltered list of code-lines like this: [@@ -10,5 +10,7@@ line1, line2, …], and returns it in a dictionary formatted like this: {‘oldCode’: [oldLine1, oldLine2], ‘newCode’: [newLine1, newLine2]}.
This function use the @@ -10,5 +10,7@@ part to distinguish between different code-snippets. We have information about what lines the alterations occur on: -digit indicated at which line the removal starts, and +digit indicates where the adding starts. The number after the comma indicates how many lines is described in the diff. Because this structure occurs between each code-snippet, we use a regex to find these and split the lines between them, before separating the code as explained above.
- Parameters
un_separated (list) – A list containing lines of code.
- Returns
sep_dict – A dictionary containing separated code.
- Return type
dict