Skip to content

Commit

Permalink
Fix config mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
alichtman committed Nov 14, 2018
1 parent 60472fb commit 57f6075
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 35 deletions.
5 changes: 5 additions & 0 deletions docs/Troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Troubleshooting

Try removing the config file `$ rm ~/.shallow-backup` and running the program again.

If that doesn't work, open an issue with the error and we'll work through it.
2 changes: 1 addition & 1 deletion docs/design-guide.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Design Guidelines
## Design Guide

**Philosophy**

Expand Down
4 changes: 3 additions & 1 deletion shallow_backup/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ def backup_configs(backup_path, skip=False):

print_blue_bold("Backing up configs...")

# backup config files + dirs in backup_path/configs/<target>/
# backup config files + dirs in backup_path/<target>/
for path_to_backup, target in config["config_mapping"].items():
print("BACKUP:", path_to_backup)
print("TARGET:", target)
dest = os.path.join(backup_path, target)
if os.path.isdir(path_to_backup):
# TODO: Exclude Sublime/Atom/VS Code Packages here to speed things up
Expand Down
21 changes: 9 additions & 12 deletions shallow_backup/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,23 @@ def get_config_paths():
Returns a dict of config paths for the correct OS.
"""
if "darwin" == get_os_name():
sublime2_path = os.path.join(get_home(), "Library/Application Support/Sublime Text 2")
sublime3_path = os.path.join(get_home(), "Library/Application Support/Sublime Text 3")
atom_path = os.path.join(get_home(), ".atom")
terminal_path = os.path.join(get_home(), "Library/Preferences/com.apple.Terminal.plist")

return {
"sublime2": os.path.join(get_home(), "Library/Application Support/Sublime Text 2"),
"sublime3": os.path.join(get_home(), "Library/Application Support/Sublime Text 3"),
"atom": os.path.join(get_home(), ".atom"),
"terminal_plist": os.path.join(get_home(), "Library/Preferences/com.apple.Terminal.plist")
# "intelliJIdea2018.2": os.path.join(get_home(), "Library/Preferences/IntelliJIdea2018.2"),
# "pycharm2018.2": os.path.join(get_home(), "Library/Preferences/PyCharm2018.2"),
# "clion2018.2": os.path.join(get_home(), "Library/Preferences/CLion2018.2"),
# "phpStorm2018.2": os.path.join(get_home(), "Library/Preferences/PhpStorm2018.2"),
sublime2_path: "sublime2",
sublime3_path: "sublime3",
atom_path: "atom",
terminal_path: "terminal_plist"
}
else:
return {
# TODO: Double check these paths. Not sure these are right.
"sublime2": "/.config/sublime-text-2",
"sublime3": "/.config/sublime-text-3",
"atom": os.path.join(get_home(), ".atom"),
# "intelliJIdea2018.2": os.path.join(get_home(), ".IntelliJIdea2018.2"),
# "pyCharm2018.2": os.path.join(get_home(), ".PyCharm2018.2"),
# "clion2018.2": os.path.join(get_home(), ".CLion2018.2"),
# "phpStorm2018.2": os.path.join(get_home(), ".PhpStorm2018.2"),
}


Expand Down
23 changes: 2 additions & 21 deletions shallow_backup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,6 @@ def write_config(config):
json.dump(config, f, indent=4)


# TODO: Refactor to `prepare_config_map()`
def prepare_config_path():
"""
Get compatible config paths, format them as [(LOC, DEST), ...]
"""
config_paths = get_config_paths()
translations = {
"terminal_plist": "plist/com.apple.Terminal.plist"
}

# Swap out keys for dest_paths
for key, dest_path in translations.items():
if key in config_paths:
config_paths[dest_path] = config_paths[key]
del config_paths[key]

return dict([(v, k) for k, v in config_paths.items()])


def get_default_config():
"""
Returns a default, platform specific config.
Expand All @@ -70,7 +51,7 @@ def get_default_config():
"dotfiles/.ssh",
"dotfiles/.pypirc",
],
"config_mapping" : prepare_config_path()
"config_mapping" : get_config_paths()
}


Expand Down Expand Up @@ -123,7 +104,7 @@ def show_config():
elif section == "backup_path":
print_path_red("Backup Path:", contents)
elif section == "config_mapping":
print_red_bold("Configs Path to Dest Mapping: ")
print_red_bold("Configs:")
for path, dest in contents.items():
print(" {} -> {}".format(path, dest))
# Print section header and intent contents. (Dotfiles/folders)
Expand Down

0 comments on commit 57f6075

Please sign in to comment.