Skip to content

Commit

Permalink
Merge pull request #41 from TasmanAnalytics/fix/existing-files-functi…
Browse files Browse the repository at this point in the history
…on-indentation

🚑 Fix try block indentation to be in for loop
  • Loading branch information
jurrigerretsen authored Jan 23, 2024
2 parents 12324d5 + 98927a3 commit b70a7e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
43 changes: 22 additions & 21 deletions datadict/datadict_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,28 @@ def updated_existing_files(yaml_obj, existing_file_yamls, models_to_be_updated,
for file in existing_file_yamls:
file_yaml = file["file_yaml"]
path = file["file_path"]
try:
for model_num, model in enumerate(file_yaml["models"]):
for model_to_be_updated in models_to_be_updated:
if model_to_be_updated["name"] == model["name"]:
logging.info(f"Model {model['name']} is being checked...")
combined_columns = combine_column_lists(
model, model_to_be_updated
)
file_yaml["models"][model_num] = combined_columns["yaml"]
updated = combined_columns["updated"]
if updated:
updated_count += 1
else:
logging.info(f"Model {model['name']} is correct")

if updated_count > 0:
datadict_helpers.output_model_file(yaml_obj, path, file_yaml, sort)
except Exception as error:
logging.error(
f"There was an issue processing file '{path}'. This is likely a badly formatted YAML file. Error: {error}"
)

try:
for model_num, model in enumerate(file_yaml["models"]):
for model_to_be_updated in models_to_be_updated:
if model_to_be_updated["name"] == model["name"]:
logging.info(f"Model {model['name']} is being checked...")
combined_columns = combine_column_lists(
model, model_to_be_updated
)
file_yaml["models"][model_num] = combined_columns["yaml"]
updated = combined_columns["updated"]
if updated:
updated_count += 1
else:
logging.info(f"Model {model['name']} is correct")

if updated_count > 0:
datadict_helpers.output_model_file(yaml_obj, path, file_yaml, sort)
except Exception as error:
logging.error(
f"There was an issue processing file '{path}'. This is likely a badly formatted YAML file. Error: {error}"
)


def add_missing_models(yaml_obj, path, models, sort):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dbt-datadict"
version = "0.1.0"
version = "0.2.1"
description = "Python CLI for automating the application of consistent field definitions to large multi-layered dbt projects."
authors = ["tom <tom@tasman.ai>"]
readme = "README.md"
Expand Down

0 comments on commit b70a7e8

Please sign in to comment.