Skip to content

Commit

Permalink
few edits to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Aug 26, 2024
1 parent a204b95 commit 0d3a1c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
6 changes: 3 additions & 3 deletions templates/usgs-location-oriented.j2
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@

"measurementMethod": {

{# Can't say if it is a gaging station or another type since this is not provided in the raw jsonld#}
{# "url": "https://doi.org/10.3133/tm3A8" #}
{# Can't say if it is a gaging station or another type since this is not provided in the raw jsonld.
Also do not have enough info to link to a remote URL for the doi #}
{# "url": "https://doi.org/10.3133/tm3A8", #}

"name": "{{ typeOfData }} Measurements",
"publisher": "U.S. Geological Survey"
{# "url": "https://doi.org/10.3133/tm3A8" #}
}
},
{% if stream['observedArea'] is defined and stream['observedArea']['phenomenonTime'] %}
Expand Down
12 changes: 2 additions & 10 deletions tests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,39 @@
import json
from jinja2 import Environment, FileSystemLoader

# Set up Jinja2 environment
template_dir = 'templates'
env = Environment(loader=FileSystemLoader(template_dir))

def apply_template_to_json(template_path, json_path):
# Load the template
template = env.get_template(template_path)

# Load the JSON data
with open(json_path) as json_file:
data = json.load(json_file)
# pygeoapi templates use data as the key where all the properties are stored
# so we just rename the key
data["data"] = data["properties"]

# Render the template with the JSON data
result = template.render(data)

return result

# Iterate over each template
for template_filename in os.listdir(template_dir):
if template_filename.endswith('.j2'):
# Determine the template name without the extension
template_name = template_filename.replace('.j2', '')

# Set the corresponding test directory
test_dir = os.path.abspath(os.path.join('tests', template_name))

if not os.path.isdir(test_dir):
print(f"No test directory found for template {template_name}")
continue

# Iterate over JSON files in the test directory
for file_name in os.listdir(test_dir):
if file_name.endswith('.json'):
json_path = os.path.join(test_dir, file_name)
template_path = template_filename

# Apply the template to the JSON file
result = apply_template_to_json(template_path, json_path)

# Print the result
print(f"Result for {file_name} using {template_filename}:")
print(result)
print("-" * 40)

0 comments on commit 0d3a1c4

Please sign in to comment.