SeparateDiff#

diffparser.separate_diff.get_file_start_indices(diff)[source]#
Parameters

diff

diffparser.separate_diff.separate_by_files(diff)[source]#
Parameters

diff

diffparser.separate_diff.separate_diff(diff, path_included=False)[source]#

This function calls one of the two functions for separating the diffs based on whether the path is included or not.

Parameters
  • string (diff) – String with the diff.

  • bool (path_included) – True if the path is included in the diff, otherwise False.

Returns

Dictionary based on the diff created using either separate_multi_file_diff or separate_single_file_diff based on whether the path variable (bool) is True or False.

Return type

separated_diff dict

diffparser.separate_diff.separate_multi_file_diff(diff)[source]#

Takes a string with this format: ‘— a/path/filename

+++ b/path/filename @@ -10,7 +10,7 @@ code’

The output of this function looks like this: {‘fileName’: {‘oldCode’:[], ‘newCode’:[]}}

diffstring

A string with information about the path as well as the code of the changes.

parsed_dictdict

A dict with a key for each filename and the value as a nested list. Each list in the nested list is a code- snippet appropriately parsed.

diffparser.separate_diff.separate_single_file_diff(diff)[source]#

Takes a diff in the format like this: “@@ -10,7 +10,7 @@ class ClassName(ParentClass):

“, and separates it into

the format like this: {‘oldCode’: [], ‘newCode’: []}.

diff string

The diff to be parsed.

separated_single_file_diff dict

Dictionary with entries for the old and new code.