How to use get_default_project method in dbt-osmosis

Best Python code snippet using dbt-osmosis_python

utils.py

Source:utils.py Github

copy

Full Screen

...26 def get_project(self, project):27 if isinstance(project, Project):28 return project29 return self.backend.get_item(Project, {'name': project})30 def get_default_project(self):31 project = self.backend.get_item(Project, {'default': True})32 if project is None:33 return self.backend.get_first_item(Project)34 return project35 def set_project_default(self, project):36 if not isinstance(project, Project):37 project = self.get_project(project)38 if project is None:39 return40 self.backend.bulk_update(Project, {'default': False})41 project.default = True42 self.backend.update_item(project)43 self.backend.commit()44 def delete_project(self, project):45 if not isinstance(project, Project):46 project = self.get_project(project)47 if project is None:48 return49 categories = self.get_project_categories(project)50 for category in categories:51 self.delete_project_category(project, category)52 self.backend.delete_item(project)53 self.backend.commit()54 def schedule_tasks(self, project, duration=60):55 schedule = []56 all_tasks = self.get_all_tasks(project)57 if all_tasks is None:58 return None59 # sort tasks by priority60 all_tasks = sorted(all_tasks, cmp=lambda x,y: cmp(self.get_task_priority(x), self.get_task_priority(y)), reverse=True)61 # split sorted tasks in categories62 categories = {}63 for task in all_tasks:64 if task.category_id not in categories:65 categories[task.category_id] = []66 categories[task.category_id].append(task)67 # interleave categories if more than one68 if len(categories) > 1:69 all_tasks = [y for x in map(None, *categories.values()) for y in x]70 d = 071 for task in [t for t in all_tasks if not t is None]:72 if d + task.duration <= duration:73 schedule.append(task)74 d += task.duration75 return schedule76 # categories77 def create_category(self, category):78 project = self.get_default_project()79 return self.create_project_category(project, category)80 def create_project_category(self, project, category):81 project = self.get_project(project)82 if project is None:83 print('Invalid project')84 return85 if self.backend.item_exists(Category, {'name': category, 'project_id': project.id}):86 print('Category already exists')87 return88 cat = Category(category)89 cat.project = project90 self.backend.add_item(cat)91 self.backend.commit()92 return cat93 def delete_category(self, category):94 project = self.get_default_project()95 return self.delete_project_category(project, category)96 def delete_project_category(self, project, category):97 project = self.get_project(project)98 if not isinstance(category, Category):99 category = self.get_category(project, category)100 tasks = self.get_project_tasks(project, category)101 for task in tasks:102 self.delete_project_task(project, category, task)103 self.backend.delete_item(category)104 self.backend.commit()105 def get_category(self, project, category):106 if isinstance(category, Category):107 return category108 if not isinstance(project, Project):109 project = self.get_project(project)110 if project is None:111 print('Invalid project')112 return None113 return self.backend.get_item(Category, {'name': category, 'project_id': project.id})114 def get_project_categories(self, project):115 if not isinstance(project, Project):116 project = self.get_project(project)117 if project is None:118 print('Invalid project')119 return None120 categories = self.backend.get_items(Category, {'project_id': project.id})121 return categories122 def get_categories(self):123 project = self.get_default_project()124 if project is None:125 print('Invalid project')126 return None127 return self.get_project_categories(project)128 # tasks129 def create_task(self, category, name):130 project = self.get_default_project()131 return self.create_project_task(project, category, name)132 def create_project_task(self, project, category, name):133 if project is None:134 print('Invalid project')135 return None136 cat = self.get_category(project, category)137 if cat is None:138 cat = self.create_project_category(project, category)139 if self.backend.item_exists(Task, {'name': name, 'category_id': cat.id}):140 print('Task already exists')141 return142 task = Task(name)143 task.category_id = cat.id144 self.backend.add_item(task)145 self.backend.commit()146 return task147 def get_tasks(self, category):148 project = self.get_default_project()149 if project is None:150 print('No project')151 return None152 return self.get_project_tasks(project, category)153 def get_project_tasks(self, project, category):154 if not isinstance(project, Project):155 project = self.get_project(project)156 if project is None:157 print('Invalid project')158 return None159 if not isinstance(category, Category):160 category = self.get_category(project, category)161 if category is None:162 print('Invalid category')...

Full Screen

Full Screen

judith.py

Source:judith.py Github

copy

Full Screen

...44 return {'fulfillmentText': msg}45 self.default_project = project_id46 msg = " I have set the default project to " + project_id47 return {'fulfillmentText': msg}48 def get_default_project(self):49 assert os.path.exists(projects_dir)50 default_project = self.default_project51 52 if default_project is not None:53 msg = " The current default project is " + default_project54 else:55 msg = " There is currently no default project set"56 return {'fulfillmentText': msg}57 def get_official_baseline(self):58 project = self.default_project59 assert project is not None 60 def post_to_facebook(self):61 62 63 def act_upon_action(self, action, parameters=None):64 if action == 'set_default_project':65 return self.set_default_project(parameters)66 elif action == 'get_default_project':67 return self.get_default_project()68 elif action == 'post_to_facebook':69 return self.post_to_facebook()70 elif action == 'project_info':71 try:72 assert self.default_project is not None73 return self.get_project_info(parameters)74 except AssertionError:75 msg = "Boss I dont have a default project"76 return {'fulfillmentText': msg} 77 else:78 msg = " I am sorry. I dont understand this " + action79 return {'fulfillmentText': msg}...

Full Screen

Full Screen

crm_lead.py

Source:crm_lead.py Github

copy

Full Screen

...3import logging4_logger = logging.getLogger(__name__)5class CrmLead(models.Model):6 _inherit = 'crm.lead'7 def get_default_project(self):8 if self.team_id and self.team_id.timesheet_project_id:9 return self.team_id.timesheet_project_id10 elif 'default_team_id' in self.env.context:11 team_id = self.env['crm.team'].browse(self.env.context.get('default_team_id', 1))12 return team_id.timesheet_project_id13 return False...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run dbt-osmosis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful