Create a fake config file
(directory, configname='config.yaml',
dotpath='dotfiles', backup=True, create=True,
import_configs=(), import_actions=(),
import_variables=())
| 209 | |
| 210 | |
| 211 | def create_fake_config(directory, configname='config.yaml', |
| 212 | dotpath='dotfiles', backup=True, create=True, |
| 213 | import_configs=(), import_actions=(), |
| 214 | import_variables=()): |
| 215 | """Create a fake config file""" |
| 216 | path = os.path.join(directory, configname) |
| 217 | workdir = os.path.join(directory, 'workdir') |
| 218 | with open(path, 'w', encoding='utf-8') as file: |
| 219 | file.write('config:\n') |
| 220 | file.write(f' backup: {backup}\n') |
| 221 | file.write(f' create: {create}\n') |
| 222 | file.write(f' dotpath: {dotpath}\n') |
| 223 | file.write(f' workdir: {workdir}\n') |
| 224 | if import_actions: |
| 225 | file.write(' import_actions:\n') |
| 226 | file.write(yaml_dashed_list(import_actions, 4)) |
| 227 | if import_configs: |
| 228 | file.write(' import_configs:\n') |
| 229 | file.write(yaml_dashed_list(import_configs, 4)) |
| 230 | if import_variables: |
| 231 | file.write(' import_variables:\n') |
| 232 | file.write(yaml_dashed_list(import_variables, 4)) |
| 233 | file.write('dotfiles:\n') |
| 234 | file.write('profiles:\n') |
| 235 | file.write('actions:\n') |
| 236 | return path |
| 237 | |
| 238 | |
| 239 | def create_yaml_keyval(pairs, parent_dir=None, top_key=None): |