From 2ce5fcd423a13f07ee6c721fbcff4998575b2496 Mon Sep 17 00:00:00 2001 From: John Pennycook Date: Tue, 5 Nov 2024 14:38:18 +0000 Subject: [PATCH] Remove unused functions from util.py Signed-off-by: John Pennycook --- codebasin/util.py | 64 ----------------------------------------------- 1 file changed, 64 deletions(-) diff --git a/codebasin/util.py b/codebasin/util.py index 6082324..938f097 100644 --- a/codebasin/util.py +++ b/codebasin/util.py @@ -13,7 +13,6 @@ import pkgutil import tomllib import typing -import warnings from collections.abc import Iterable from os.path import splitext @@ -36,35 +35,6 @@ def ensure_png(fname): return ensure_ext(fname, ".png") -def ensure_source(fname): - """Return true if the path passed in specifies a source file""" - extensions = [ - ".s", - ".asm", - ".c", - ".cpp", - ".cxx", - ".c++", - ".cc", - ".h", - ".hpp", - ".hxx", - ".h++", - ".hh", - ".inc", - ".inl", - ".tcc", - ".icc", - ".ipp", - ] - return ensure_ext(fname, extensions) - - -def ensure_json(fname): - """Return true if the path passed in specifies a JSON file""" - return ensure_ext(fname, ".json") - - def safe_open_write_binary(fname): """Open fname for (binary) writing. Truncate if not a symlink.""" fpid = os.open( @@ -235,37 +205,3 @@ def _load_toml(file_object: typing.TextIO, schema_name: str) -> object: toml_object = tomllib.load(file_object) _validate_json(toml_object, schema_name) return toml_object - - -def validate_coverage_json(json_string: str) -> bool: - """ - Validate coverage JSON string against schema. - - Parameters - ---------- - json_string : String - The JSON string to validate. - - Returns - ------- - bool - True if the JSON string is valid. - - Raises - ------ - ValueError - If the JSON string fails to validate. - - TypeError - If the JSON string is not a string. - """ - warnings.warn( - "Direct access to JSON validation is deprecated.", - DeprecationWarning, - ) - - if not isinstance(json_string, str): - raise TypeError("Coverage must be a JSON string.") - - instance = json.loads(json_string) - return _validate_json(instance, "coverage")