From 0fd0bbe7250930c98f3c79a2851c71eac8b0abe3 Mon Sep 17 00:00:00 2001 From: Ronny Abraham Date: Wed, 10 Oct 2018 13:06:19 +0300 Subject: [PATCH] added edit project configuration files capability --- modules/conf_setup.py | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/modules/conf_setup.py b/modules/conf_setup.py index d402443..2fb8eac 100644 --- a/modules/conf_setup.py +++ b/modules/conf_setup.py @@ -257,3 +257,57 @@ def copy_directories(source_path, dest_path): fpath = os.path.join(source_path, fname) put(fpath, dest_path) + + +@task +def edit(param='help'): + """ + calls up mvim on the yaml project configuration files + """ + + from maintenance import edit as maintenance_edit + from maintenance import _get_configuration_path + + locations = { + 'development': { + 'path': _get_configuration_path("config", "development"), + 'desc': 'development project configuration file', + }, + + 'staging': { + 'path': _get_configuration_path("config", "staging"), + 'desc': 'staging project configuration file', + }, + + 'production': { + 'path': _get_configuration_path("config", "production"), + 'desc': 'production project configuration file', + }, + } + + if param in locations.keys(): + # it is unnecessary to give the host_string to edit + # because the host_string is determined when we call fab + # ie. "fab devel whatever" or "fab stage whatever" + # we want to edit all files on localhost. b/c we only call + # fab FROM localhost + + remote_path = locations[param]['path'] + maintenance_edit(remote_path=remote_path) + else: + # if param == 'help': + + print """ + "fab configuration.edit" automates opening up and editing project + configuration files + + to use this you must pass one of the editable locations in as a + parameter + + currently editable locations are: + """ + + for k_loc in locations.keys(): + print "\t{0: <20} - {1}".format(k_loc, locations[k_loc]['desc']) + + return