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

Separate options for Key and Value representation #22

Open
srnliveops opened this issue May 2, 2024 · 0 comments
Open

Separate options for Key and Value representation #22

srnliveops opened this issue May 2, 2024 · 0 comments

Comments

@srnliveops
Copy link

Hello:

Is there an option to set separate formatting/representation for keys and values in the yaml.dump call?

The closest thing to setting the values separately that I have found is this snippet from represent_mapping in the class BaseRepresenter. Since represent_data is called for both key and value, I'm guessing the answer is "no", but thought I'd be thorough.

 for item_key, item_value in mapping:
      node_key = self.represent_data(item_key)
      node_value = self.represent_data(item_value)
      if not (isinstance(node_key, ScalarNode) and not node_key.style):
          best_style = False
      if not (isinstance(node_value, ScalarNode) and not node_value.style):
          best_style = False
      value.append((node_key, node_value))

For context, my requirement is the yaml file must quote every value, irrespective of key or depth as they are all sql code fragments that are being passed into the AutomateDV package for dbt.

Many thanks,
Simon Norton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant