Create a fake config file
(path, dotfiles, profile,
dotpath, actions, transs)
| 22 | |
| 23 | |
| 24 | def fake_config(path, dotfiles, profile, |
| 25 | dotpath, actions, transs): |
| 26 | """Create a fake config file""" |
| 27 | with open(path, 'w', encoding='utf-8') as file: |
| 28 | file.write('actions:\n') |
| 29 | for action in actions: |
| 30 | file.write(f' {action.key}: {action.action}\n') |
| 31 | file.write('trans_install:\n') |
| 32 | for trans in transs: |
| 33 | file.write(f' {trans.key}: {trans.action}\n') |
| 34 | file.write('config:\n') |
| 35 | file.write(' backup: true\n') |
| 36 | file.write(' create: true\n') |
| 37 | file.write(f' dotpath: {dotpath}\n') |
| 38 | file.write('dotfiles:\n') |
| 39 | for dotfile in dotfiles: |
| 40 | linkval = dotfile.link.name.lower() |
| 41 | file.write(f' {dotfile.key}:\n') |
| 42 | file.write(f' dst: {dotfile.dst}\n') |
| 43 | file.write(f' src: {dotfile.src}\n') |
| 44 | file.write(f' link: {linkval}\n') |
| 45 | if len(dotfile.actions) > 0: |
| 46 | file.write(' actions:\n') |
| 47 | for action in dotfile.actions: |
| 48 | file.write(f' - {action.key}\n') |
| 49 | if dotfile.trans_install: |
| 50 | for trans in dotfile.trans_install: |
| 51 | file.write(f' trans_install: {trans.key}\n') |
| 52 | file.write('profiles:\n') |
| 53 | file.write(f' {profile}:\n') |
| 54 | file.write(' dotfiles:\n') |
| 55 | for dotfile in dotfiles: |
| 56 | file.write(f' - {dotfile.key}\n') |
| 57 | return path |
| 58 | |
| 59 | |
| 60 | def get_workdir(): |