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

feature_request(dry): get variables from another YAML files #206

Open
Kristinita opened this issue Mar 14, 2019 · 1 comment
Open

feature_request(dry): get variables from another YAML files #206

Kristinita opened this issue Mar 14, 2019 · 1 comment

Comments

@Kristinita
Copy link

#199 — partially related issue

1. Summary

It would be nice, if peru can get variables from another YAML files.

2. Argumentation

Don't Repeat Yourself.

At the time I need to write duplicate code for using Peru.

3. Example

3.1. Structure and files

Part of my real project structure:

peru.yaml
site_variables.yaml
pelican-config/
  pelican_plugins_settings.yaml
  • peru.yaml:
imports:
  pelican-plugins: plugins/

git module pelican-plugins:
  url: https://github.com/getpelican/pelican-plugins
  pick:
  - filetime_from_git
  - interlinks
  - just_table
  - neighbors
  - pelican-open_graph
  - section_number
  - sitemap
  • part of site_variables.yaml:
PLUGIN_PATHS:
- plugins
  • part of pelican-config/pelican_plugins_settings.yaml:
PLUGINS:
- filetime_from_git
- interlinks
- just_table
- neighbors
- pelican-open_graph
- section_number
- sitemap

3.2. Problem

I use duplicate values for:

  1. pick variable in peru and PLUGINS variable for Pelican.
  2. imports.pelican-plugins — peru; PLUGIN_PATHS — Pelican.

If I change Pelican variable, I need manually make the same change for peru. I need to repeat myself.

4. Not helped

  1. Unfortunately, YAML doesn't support any kind of include or import statement. I can't find, how I can solve my problem use third-party tools.
  2. Pelican required, for example, PLUGINS variable name. I can't change it to git module pelican-plugins.pick for using peru with --file-basename flag.

5. Example of expected behavior

  • peru.yaml:
include: site_variables.yaml
include: pelican-config/pelican_plugins_settings.yaml

imports:
  pelican-plugins: site-variables.PLUGIN_PATHS

git module pelican-plugins:
  url: https://github.com/getpelican/pelican-plugins
  pick: pelican_plugins_settings.PLUGINS

Thanks.

@oconnor663
Copy link
Member

Have you considered writing a program to generate one YAML file from the other. Or maybe generating both YAML files from some other shared input file?

The peru.yaml format is intended to be relatively simple, both to read and to write. I'm a little wary of adding more complicated behavior to it, because that would make it harder for other programs to parse it and figure out what it's doing.

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

2 participants