Example #1
0
def prompt_project(arguments):
    """prompts the user for a project, if not passed in as a argument"""
    projects = Project.all()

    # Do not prompt -- and auto select the one project if a account only has one project
    if len(projects) == 1:
        return projects[0]

    if arguments['--project-index'] is not None:
        try:
            idx = int(arguments['--project-index']) - 1
            project = projects[idx]
            return project
        except:
            print 'Yikes, that did not work -- try again?'
            exit()

    while True:
        print "Select a Project:"
        for idx, project in enumerate(projects):
            print "[{}] {}".format(idx + 1, project.name)
        s = raw_input('>> ')

        try:
            project = projects[int(s) - 1]
        except:
            print 'Hmmm, that did not work -- try again?'
            continue

        break

    return project
Example #2
0
def prompt_project(arguments):
    """prompts the user for a project, if not passed in as a argument"""
    projects = Project.all()

    # Do not prompt -- and auto select the one project if a account only has one project
    if len(projects) == 1:
        return projects[0]

    if arguments['--project-index'] is not None:
        try:
            idx = int(arguments['--project-index']) - 1
            project = projects[idx]
            return project
        except:
            print 'Yikes, that did not work -- try again?'
            exit()

    while True:
        print "Select a Project:"
        for idx, project in enumerate(projects):
            print "[{}] {}".format(idx+1, project.name)
        s = raw_input('>> ')

        try:
            project = projects[int(s) - 1]
        except:
            print 'Hmmm, that did not work -- try again?'
            continue

        break

    return project
Example #3
0
    def find(cls, story_id, project_index=None):
        project = None
        if project_index is None:
            project = find_project_for_story(story_id)

        else:
            project = Project.all()[project_index]

        if project is not None:
            return project.load_story(story_id)
        else:
            return None
Example #4
0
def find_project_for_story(story_id):
    """If we have multiple projects, will loop through the projects to find the one with the given story.
    returns None if not found
    """

    for project in Project.all():
        story = project.load_story(story_id)
        if story is not None:
            return project

    #Not found
    print "No project found for story: #{}".format(story_id)
    return None
Example #5
0
def get_project_by_index(index):
    return Project.all()[index]