def add_label_view(self): name = get_input('Name this view: ') jira_connection_name = pick_value( 'Which JIRA Connection does this belong to? ', list(self._jira_connections.keys())) jira_connection = self._jira_connections[jira_connection_name] new_view = JiraView(name, jira_connection) self.jira_views[name] = new_view jira_filter = JiraFilter('labels', jira_connection) while True: label = get_input('Add which label? ([q] to quit)') if label == 'q': break if label.isspace() or label == '': continue print('Adding label: [{}]'.format(label)) jira_filter.include(label) res_jf = JiraFilter('Resolution', jira_connection) res_jf.include('unresolved') new_view.add_raw_filter(jira_filter) new_view.add_raw_filter(res_jf) self._save_config() new_view.display_view(self) print('Creating new view with label(s): {}'.format(','.join( jira_filter._includes)))
def from_file(cls, jira_manager: 'JiraManager', config_file_name: str, team_manager: 'TeamManager') -> 'JiraView': """ Throws ConfigError on error """ config_file = JiraView._build_config(config_file_name) if not os.path.isfile(config_file): raise ConfigError( 'Failed to find jira view config file: {}'.format(config_file)) config_parser = configparser.RawConfigParser() config_parser.read(config_file) name = config_parser.get('JiraView', 'name') jira_connection = jira_manager.get_jira_connection( config_parser.get('JiraView', 'jira_connection')) new_jira_view = JiraView(name, jira_connection) # Due to init order dep, we init teams empty here then fill them out separately from team_manager if config_parser.has_option('JiraView', 'Teams'): for t in config_parser.get('JiraView', 'Teams').split(','): new_jira_view._teams[t] = team_manager.get_team_by_name(t) sections = config_parser.sections() for section_name in sections: if section_name == 'JiraView': continue new_jira_filter = JiraFilter.from_file(jira_manager, section_name, config_parser) new_jira_view.add_raw_filter(new_jira_filter) return new_jira_view
def add_single_filter(self, name, value, filter_type, and_or): # type: (str, str, str, str) -> None """ :param name: field name :param value: value to match against :param filter_type: 'i' to include, else exclude :param and_or: 'AND' or 'OR' """ if name not in self._jira_filters: self._jira_filters[name] = JiraFilter(name, self.jira_connection, and_or) # don't add logic to confirm validity or overlap, just add it filter = self._jira_filters[name] filter.name = name if filter_type == 'i': filter.include(value) else: filter.exclude(value)
def add_single_filter(self, field: str, value: str, filter_type: str, and_or: str) -> None: """ :param field: field name :param value: value to match against :param filter_type: 'i' to include, else exclude :param and_or: 'AND' or 'OR' """ assert and_or == 'AND' or and_or == 'OR', 'Expected AND or OR to add_single_filter. Got: {}'.format( and_or) if field not in self._jira_filters: self._jira_filters[field] = JiraFilter(field, self.jira_connection, and_or) # Overwrite fields if it already exists. jira_filter = self._jira_filters[field] jira_filter.field = field if filter_type == 'i': jira_filter.include(value) else: jira_filter.exclude(value)