Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pysock/sorterer/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ def find_start_and_end_line_indexes(self, lines):
line_index += 1

def feed_records(self, lines):
line_index = self.start_line_index + 1

while (line_index < self.end_line_index):
record = Record(lines, line_index)
self.records.append(record)
line_index += len(record.property_lines)
if self.start_line_index is None:
AssertionError('Section %s does not contain starting line index.' % self.key)
else:
line_index = self.start_line_index + 1

while (line_index < self.end_line_index):
record = Record(lines, line_index)
self.records.append(record)
line_index += len(record.property_lines)


28 changes: 14 additions & 14 deletions pysock/sorterer/sorterer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ def sort_lines_in_section(section_key, lines):
section = Section(key=section_key, lines=lines)

if section.start_line_index is None or section.end_line_index is None:
AssertionError('Section %s does not contain starting or ending line index.' % section_key)

section.records.sort(key=lambda x: x.name, reverse=False)

for record in section.records:
for line in record.property_lines:
del lines[section.start_line_index + 1]

line_index = section.start_line_index + 1
for record in section.records:
sort_deep_records_in_record(record)
for line in record.property_lines:
lines.insert(line_index, line)
line_index += 1
AssertionError('Section %s does not contain starting or ending line index.' % section_key)
else:
section.records.sort(key=lambda x: x.name, reverse=False)

for record in section.records:
for line in record.property_lines:
del lines[section.start_line_index + 1]

line_index = section.start_line_index + 1
for record in section.records:
sort_deep_records_in_record(record)
for line in record.property_lines:
lines.insert(line_index, line)
line_index += 1


def sort_deep_records_in_record(record):
Expand Down