Reputation: 99
I have three directories which are in the root directory of my machine: yaml, data and json.
Within my yaml directory I have a configuration yaml file which points to the json directory. Now I want to be able to get out of the yaml directory and then in to the json directory in order to point the json_location
to this.
So far I have the following in my yaml file, but it is an absolute path. If someone else was to use my code, they would need to change the file path to meet their User profile name.
# configuration
config:
json_location: /Users/jaymiee/Desktop/json/
Upvotes: 4
Views: 36284
Reputation: 21
If you have something that processes the yaml check the documentation for variables. For Instance on serverless they use variables to make it dynamic, it involves using "$" but other systems use different notation:
# configuration
config:
json_location: ${file(./config.json):PATH}
Upvotes: 0
Reputation: 1069
Option 1. Get the user's home path as a variable and store that into your config
Option 2. let your app code handle directory changes. In Python, you could do something like:
from pathlib import Path
home = str(Path.home()) # python 3.5+
yaml_location = os.path.join(home, "yaml")
Upvotes: -1