def _setup_paths(project_settings): # first merge in variables from project_settings - but ignore __doc__ etc user_settings = [x for x in vars(project_settings).keys() if not x.startswith('__')] for setting in user_settings: env[setting] = vars(project_settings)[setting] # allow for project_settings having set up some of these differently h.set_dict_if_not_set(env, 'verbose', False) h.set_dict_if_not_set(env, 'use_sudo', True) h.set_dict_if_not_set(env, 'cvs_rsh', 'CVS_RSH="ssh"') h.set_dict_if_not_set(env, 'default_branch', {'production': 'master', 'staging': 'master'}) h.set_dict_if_not_set(env, 'project_root', os.path.join(env.server_home, env.project_name)) h.set_dict_if_not_set(env, 'vcs_root', os.path.join(env.project_root, 'dev')) h.set_dict_if_not_set(env, 'prev_root', os.path.join(env.project_root, 'previous')) h.set_dict_if_not_set(env, 'dump_dir', os.path.join(env.project_root, 'dbdumps')) h.set_dict_if_not_set(env, 'deploy_root', os.path.join(env.vcs_root, 'deploy')) h.set_dict_if_not_set(env, 'settings', '%(project_name)s.settings' % env) if env.project_type == "django": h.set_dict_if_not_set(env, 'django_relative_dir', env.project_name) h.set_dict_if_not_set(env, 'django_root', os.path.join(env.vcs_root, env.django_relative_dir)) if env.use_virtualenv: h.set_dict_if_not_set(env, 'virtualenv_root', os.path.join(env.django_root, '.ve')) h.set_dict_if_not_set(env, 'local_tasks_bin', os.path.join('/', 'usr', 'bin', 'python') + ' ' + os.path.join(os.path.dirname(__file__), 'tasks.py')) # valid environments - used for require statements in fablib env.valid_envs = env.host_list.keys()
def test_item_added_if_not_present(self): testdict = {'a': 'b'} helper.set_dict_if_not_set(testdict, 'b', 'c') self.assertEqual('c', testdict['b'])