def _find_longest_move_range(self, r_move_ranges): # Go through every range of lines we've found and find the longest. # # The longest move range wins. If we find two ranges that are equal, # though, we'll ignore both. The idea is that if we have two identical # moves, then it's probably common enough code that we don't want to # show the move. An example might be some standard part of a comment # block, with no real changes in content. # # Note that with the current approach, finding duplicate moves doesn't # cause us to reset the winning range to the second-highest identical # match. We may want to do that down the road, but it means additional # state, and this is hopefully uncommon enough to not be a real # problem. r_move_range = None for iter_move_range in six.itervalues(r_move_ranges): if not r_move_range: r_move_range = iter_move_range else: len1 = r_move_range[1] - r_move_range[0] len2 = iter_move_range[1] - iter_move_range[0] if len1 < len2: r_move_range = iter_move_range elif len1 == len2: # If there are two that are the same, it may be common # code that we don't want to see moves for. Comments, # for example. r_move_range = None return r_move_range
def full_clean(self): super(AuthenticationSettingsForm, self).full_clean() if self.data: # Note that this isn't validated yet, but that's okay given our # usage. It's a bit of a hack though. auth_backend = (self['auth_backend'].data or self.fields['auth_backend'].initial) if auth_backend in self.auth_backend_forms: self.auth_backend_forms[auth_backend].full_clean() else: for form in six.itervalues(self.auth_backend_forms): form.full_clean()
def _close_file_handles(self, post_data): for value in six.itervalues(post_data): if isinstance(value, file): value.close()