From 18661d1b42e06d3ed46df4ba3c7e210805664ccc Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 8 Aug 2024 12:36:54 -0400 Subject: [PATCH] format --- docs/make_params.py | 10 ++-------- ogcore/utils.py | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/docs/make_params.py b/docs/make_params.py index 0bf503add..f0d9c5c9e 100644 --- a/docs/make_params.py +++ b/docs/make_params.py @@ -131,11 +131,7 @@ def valid_range_one(row): except KeyError: # case of no validators, or also non-numeric ones? try: r = row.validators["choice"] - return ( - "_Valid Choices:_" - + str(r["choices"]) - + " \n" - ) + return "_Valid Choices:_" + str(r["choices"]) + " \n" except KeyError: return "" @@ -143,9 +139,7 @@ def valid_range(df): return df.apply(valid_range_one, axis=1) text = title(df) - text += description( - df - ) + text += description(df) text += notes(df) text += value_type(df) text += valid_range(df) diff --git a/ogcore/utils.py b/ogcore/utils.py index 549deaedc..1bf48cc91 100644 --- a/ogcore/utils.py +++ b/ogcore/utils.py @@ -1386,21 +1386,24 @@ def json_to_dict(json_text): JSON data expressed as an ordered Python dictionary. """ try: - ordered_dict = json.loads(json_text, - object_pairs_hook=collections.OrderedDict) + ordered_dict = json.loads( + json_text, object_pairs_hook=collections.OrderedDict + ) except ValueError as valerr: - text_lines = json_text.split('\n') - msg = 'Text below contains invalid JSON:\n' - msg += str(valerr) + '\n' - msg += 'Above location of the first error may be approximate.\n' - msg += 'The invalid JSON text is between the lines:\n' - bline = ('XXXX----.----1----.----2----.----3----.----4' - '----.----5----.----6----.----7') - msg += bline + '\n' + text_lines = json_text.split("\n") + msg = "Text below contains invalid JSON:\n" + msg += str(valerr) + "\n" + msg += "Above location of the first error may be approximate.\n" + msg += "The invalid JSON text is between the lines:\n" + bline = ( + "XXXX----.----1----.----2----.----3----.----4" + "----.----5----.----6----.----7" + ) + msg += bline + "\n" linenum = 0 for line in text_lines: linenum += 1 - msg += '{:04d}{}'.format(linenum, line) + '\n' - msg += bline + '\n' + msg += "{:04d}{}".format(linenum, line) + "\n" + msg += bline + "\n" raise ValueError(msg) return ordered_dict