From a1c544b5a048cdca94e9ac286cfa6d0895e3211c Mon Sep 17 00:00:00 2001 From: Danil Tolmachev Date: Thu, 24 Nov 2022 00:16:08 +0300 Subject: [PATCH] renaming --- dictdatabase/io_unsafe.py | 4 ++-- dictdatabase/searching.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dictdatabase/io_unsafe.py b/dictdatabase/io_unsafe.py index 83a85a9..fbc405b 100644 --- a/dictdatabase/io_unsafe.py +++ b/dictdatabase/io_unsafe.py @@ -88,7 +88,7 @@ def partial_read_only(db_name: str, key: str) -> dict | None: # Not found in index file, search for key in the entire file all_file_bytes = io_bytes.read(db_name) - start, end, found = searching.search_value_by_key(all_file_bytes, key) + start, end, found = searching.search_value_position_in_db(all_file_bytes, key) if not found: return None value_bytes = all_file_bytes[start:end] @@ -185,7 +185,7 @@ def get_partial_file_handle(db_name: str, key: str) -> PartialFileHandle: return partial_handle # Not found in index file, search for key in the entire file - key_start, key_end, found = searching.search_key(all_file_bytes, key) + key_start, key_end, found = searching.search_key_position_in_db(all_file_bytes, key) if not found: raise KeyError(f"Key \"{key}\" not found in db \"{db_name}\"") diff --git a/dictdatabase/searching.py b/dictdatabase/searching.py index f661bde..62ed857 100644 --- a/dictdatabase/searching.py +++ b/dictdatabase/searching.py @@ -6,7 +6,7 @@ from dictdatabase import utils -def find_start_end_in_bytes(file: bytes, key: str) -> Tuple[int, int, bool]: +def find_key_position_in_bytes(file: bytes, key: str) -> Tuple[int, int, bool]: """ It finds the start and end indices of the value of a key in a JSON file @@ -25,7 +25,7 @@ def find_start_end_in_bytes(file: bytes, key: str) -> Tuple[int, int, bool]: return start, end, True -def search_key(file: bytes, key: str, glom_searching=True) -> Tuple[int, int, bool]: +def search_key_position_in_db(file: bytes, key: str, glom_searching=True) -> Tuple[int, int, bool]: original_value_start = 0 original_value_end = len(file) original_key_start = 0 @@ -36,14 +36,14 @@ def search_key(file: bytes, key: str, glom_searching=True) -> Tuple[int, int, bo return -1, -1, False original_key_end = original_value_start + key_end original_key_start = original_value_start + key_start - value_start, value_end, found = find_start_end_in_bytes(file, k) + value_start, value_end, found = find_key_position_in_bytes(file, k) original_value_end = original_value_start + original_value_end original_value_start += value_start file = file[original_value_start:original_value_end] return original_key_start, original_key_end, True -def search_value_by_key( +def search_value_position_in_db( all_file_bytes: bytes, key: str, glom_searching=True ) -> Tuple[int, int, bool]: """ @@ -61,7 +61,7 @@ def search_value_by_key( original_start = 0 original_end = len(all_file_bytes) for k in key.split(".") if glom_searching else [key]: - start, end, found = find_start_end_in_bytes( + start, end, found = find_key_position_in_bytes( all_file_bytes[original_start:original_end], k ) if not found: