def test_with_file_and_no_overrides(self): config = { "default": { "a": "b", "x": "y", }, "staging": { "x": "k", }, "prod": { "x": "x", }, } with tempfile.NamedTemporaryFile("w") as f: ydump(config, f) expected = {"a": "b", "x": "k"} found = read_env_config_from_file("staging", overrideOptions={}, filePath=f.name) self.assertDictEqual(expected, found) # testing the default case expected = { "a": "b", "x": "y", } found = read_env_config_from_file("newenv", overrideOptions={}, filePath=f.name) self.assertDictEqual(expected, found)
def project_generate_yml(name=None): action = "init" report_async({"command": f"dg project generate"}, status="start") update_existing_yaml = False if os.path.exists("digger.yml"): Bcolors.warn("digger.yml found, please remove before running command") sys.exit(0) if name is None: defaultProjectName = os.path.basename(os.getcwd()) questions = [ { 'type': 'input', 'name': 'project_name', 'message': 'Enter project name', 'default': defaultProjectName, 'validate': ProjectNameValidator }, ] answers = pyprompt(questions) project_name = answers["project_name"] else: project_name = name spinner = Halo(text='Generating project: ' + project_name, spinner='dots') spinner.start() response = api.generate_project(project_name) settings = json.loads(response.content) f = open(digger_yaml(), "w") ydump(settings, f) spinner.stop() print("project generated successfully") report_async({"command": f"dg project generate"}, settings=settings, status="complete")
def dump_yaml(self): f = open("digger.yml", "w") ydump(self.state, f)
def update_digger_yaml(d): global PROJECT f = open(digger_yaml(), "w") ydump(d, f) PROJECT = d