Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not look for layer_name in preview info for multiformat resources… #180

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions bcdata/bcdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,28 @@ def get_table_definition(table_name):
# multiple format resource
elif resource["format"] == "multiple":
# if multiple format, check for table name match in this location
if resource[
"preview_info"
]: # first check that the key is not empty
if (
json.loads(resource["preview_info"])["layer_name"]
== table_name
):
if "object_table_comments" in resource.keys():
table_comments = resource["object_table_comments"]
else:
table_comments = None
# only add to matches if schema details found
if resource["preview_info"]:
# check that layer_name key is present
if "layer_name" in json.loads(resource["preview_info"]):
# then check if it matches the table name
if (
"details" in resource.keys()
and resource["details"] != ""
json.loads(resource["preview_info"])["layer_name"]
== table_name
):
table_details = resource["details"]
matches.append((notes, table_comments, table_details))
log.debug(resource)
if "object_table_comments" in resource.keys():
table_comments = resource["object_table_comments"]
else:
table_comments = None
# only add to matches if schema details found
if (
"details" in resource.keys()
and resource["details"] != ""
):
table_details = resource["details"]
matches.append(
(notes, table_comments, table_details)
)
log.debug(resource)

# uniquify the result
if len(matches) > 0:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_bcdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,12 @@ def test_get_table_definition_format_multi_nopreview():
assert table_definition["description"]
assert table_definition["comments"]
assert table_definition["schema"]


def test_get_table_definition_format_multi_nolayer():
table_definition = bcdc.get_table_definition(
"WHSE_HUMAN_CULTURAL_ECONOMIC.HIST_HISTORIC_ENVIRONMENTS_SP"
)
assert table_definition["description"]
assert table_definition["comments"]
assert table_definition["schema"]