'Setting file path location in yaml

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/


Solution 1:[1]

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")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ty Hitzeman