Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Aug 8, 2024
1 parent c3a11c7 commit 18661d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
10 changes: 2 additions & 8 deletions docs/make_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,15 @@ 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 ""

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)
Expand Down
27 changes: 15 additions & 12 deletions ogcore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 18661d1

Please sign in to comment.