From d9685d75888526514bc66aa3ccf6ad69a5387642 Mon Sep 17 00:00:00 2001 From: Antti Kaihola Date: Sun, 12 Sep 2021 11:49:08 +0300 Subject: [PATCH] Better varname for merge sorter. Also sorted imports. --- pgtricks/pg_dump_splitsort.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pgtricks/pg_dump_splitsort.py b/pgtricks/pg_dump_splitsort.py index 7c82926..30d236c 100755 --- a/pgtricks/pg_dump_splitsort.py +++ b/pgtricks/pg_dump_splitsort.py @@ -5,7 +5,7 @@ import os import re import sys -from typing import IO, List, Match, Optional, Pattern, Tuple, Union, cast, Iterable +from typing import IO, Iterable, List, Match, Optional, Pattern, Tuple, Union, cast from pgtricks.mergesort import MergeSort @@ -75,13 +75,13 @@ def new_output(filename: str) -> IO[str]: output.close() return open(os.path.join(directory, filename), 'w') - copy_lines: Optional[MergeSort] = None + sorted_data_lines: Optional[MergeSort] = None counter = 0 output = new_output('0000_prologue.sql') matcher = Matcher() for line in open(sql_filepath): - if copy_lines is None: + if sorted_data_lines is None: if line in ('\n', '--\n'): buf.append(line) elif line.startswith('SET search_path = '): @@ -95,7 +95,7 @@ def new_output(filename: str) -> IO[str]: schema=matcher.group('schema'), table=matcher.group('table'))) elif COPY_RE.match(line): - copy_lines = MergeSort( + sorted_data_lines = MergeSort( key=functools.cmp_to_key(linecomp), max_memory=max_memory ) elif SEQUENCE_SET_RE.match(line): @@ -106,11 +106,11 @@ def new_output(filename: str) -> IO[str]: writelines([line]) else: if line == "\\.\n": - writelines(copy_lines) + writelines(sorted_data_lines) writelines(line) - copy_lines = None + sorted_data_lines = None else: - copy_lines.append(line) + sorted_data_lines.append(line) flush()