def get_project_path_and_type(module_name): try: projects = ProjectsDAO.get_projects() return projects[module_name]["path"], projects[module_name]["type"] except KeyError: msg = "Path not found for project [%s]" % module_name raise Exception(msg)
def validate_modules_exists(commands): projects = ProjectsDAO.get_projects() wrong_modules_names = filter(lambda command: command.target_module not in projects.keys(), commands) if len(wrong_modules_names): msg = "Unknown modules keys=%s" % str(map(lambda cmd: cmd.target_module, wrong_modules_names)) raise Exception(msg)
def test_add(self): ProjectsDAO.save_projects(self.create_projects_obj(), db_path=test_db) ProjectsDAO.add_project("append", "/home/append", "mvn_project", db_path=test_db) read = ProjectsDAO.get_projects(db_path=test_db) self.assertEquals(read["project1"], {"path": "/home/tests/project1", "type": "mvn_project"}) self.assertEquals(read["project2"], {"path": "/home/tests/project2", "type": "mvn_project"}) self.assertEquals(read["project3"], {"path": "/home/tests/project3", "type": "mvn_project"}) self.assertEquals(read["append"], {"path": "/home/append", "type": "mvn_project"})
def get_actions(self): actions = [] last_used_mods = [] if 'ordered_args' not in dir(self.parsed): self.arg_parser.parse_args(['-h']) return for (action_key, modules) in self.parsed.ordered_args: arguments = map(lambda arg: arg[1:], filter(lambda arg: arg[0] == '@', modules)) action_modules = filter(lambda mod: mod[0] != '@', modules) if len(action_modules) == 0: if len(last_used_mods) == 0: raise Exception("None module pressed") action_modules = last_used_mods else: if "all" in action_modules: action_modules = [x[0] for x in ProjectsDAO.get_projects().items() if x[1]['type'] == 'mvn_project'] last_used_mods = action_modules for module in action_modules: actions.append(Action(target_module=module, action=action_key, arguments=arguments)) return actions