Esempio n. 1
0
def get(project_name):
    """Get policy."""
    issue_tracker_config = local_config.IssueTrackerConfig()
    project_config = issue_tracker_config.get(project_name)
    if not project_config:
        raise ConfigurationError(
            'Issue tracker for {} does not exist'.format(project_name))

    if not 'policies' in project_config:
        raise ConfigurationError(
            'Policies for {} do not exist'.format(project_name))

    return IssueTrackerPolicy(project_config['policies'])
def get_issue_tracker(project_name=None):
  """Get the issue tracker with the given type and name."""
  issue_tracker_config = local_config.IssueTrackerConfig()
  if not project_name:
    from datastore import data_handler
    project_name = data_handler.get_issue_tracker_name()

  issue_project_config = issue_tracker_config.get(project_name)
  if not issue_project_config:
    raise ValueError('Issue tracker for {} does not exist'.format(project_name))

  constructor = _ISSUE_TRACKER_CONSTRUCTORS.get(issue_project_config['type'])
  if not constructor:
    raise ValueError('Invalid issue tracker type: ' +
                     issue_project_config['type'])

  return constructor(project_name, issue_project_config)