Пример #1
0
 def _find_left(self, opened_file):
     left = 0
     right = ReadUtils.size_of_opened_file(opened_file)
     while left + 1 < right:
         curr = (left + right) // 2
         line, line_begin, line_end = ReadUtils.get_line_containing_offset(
             opened_file, curr, ReadUtils.STANDARD_BUFFER_SIZE
         )
         groups = self._super_parser.get_ordered_groups(line)
         assert len(groups) <= 1
         if self._investigation_step.compare_with_bound(
             InvestigationStep.LEFT_BOUND, groups
         ) == CompareResult.LT:
             # omit actual line and go right
             left = line_end + 1
         else:
             # going left, omit actual line, but maybe it will be returned
             right = line_begin
     return right
Пример #2
0
 def _find_right(self, opened_file):
     left = 0
     right = ReadUtils.size_of_opened_file(opened_file)
     while left + 1 < right:
         curr = (left + right) // 2
         line, line_begin, line_end = ReadUtils.get_line_containing_offset(
             opened_file, curr, ReadUtils.STANDARD_BUFFER_SIZE
         )
         groups = self._super_parser.get_ordered_groups(line)
         assert len(groups) <= 1
         if self._investigation_step.compare_with_bound(InvestigationStep.RIGHT_BOUND, groups)\
                 in [CompareResult.LT, CompareResult.EQ]:
             # go to the end of current line, maybe it will be returned
             left = line_end
         else:
             # going left, current line is not interesting
             right = line_begin - 1
     if right == 0:
         return 0
     _, _, end_offset = ReadUtils.get_line_containing_offset(
         opened_file, right - 1, ReadUtils.STANDARD_BUFFER_SIZE
     )
     return end_offset + 1
Пример #3
0
 def _find_right(self, opened_file, value, super_parser):
     return ReadUtils.binary_search_right(
         opened_file, 0, ReadUtils.size_of_opened_file(opened_file), value,
         super_parser)
Пример #4
0
 def _find_right(self, opened_file, value, super_parser):
     return ReadUtils.binary_search_right(
         opened_file, 0, ReadUtils.size_of_opened_file(opened_file), value, super_parser
     )