Exemple #1
0
def load_story(story_id, arguments):
    story = None
    if arguments['--project-index'] is not None and arguments['--project-index'].isdigit():
        idx = int(arguments['--project-index']) - 1
        story = Story.find(story_id, project_index=idx)
    else:

        story = Story.find(story_id)
    return story
Exemple #2
0
def load_story(story_id, arguments):
    story = None
    if arguments['--project-index'] is not None and arguments['--project-index'].isdigit():
        idx = int(arguments['--project-index']) - 1
        story = Story.find(story_id, project_index=idx)
    else:

        story = Story.find(story_id)
    return story
Exemple #3
0
    def load_story(self, story_id):
        """Trys to find a story, returns None is not found"""
        story_url = "https://www.pivotaltracker.com/services/v3/projects/{}/stories/{}".format(
            self.project_id, story_id)

        resposne = _perform_pivotal_get(story_url)
        # print resposne.text
        if resposne.status_code == 404:
            # Not Found
            return None
        else:
            #Found, parsing story
            root = ET.fromstring(resposne.text)
            return Story.from_node(root)
Exemple #4
0
    def get_stories(self, filter_string):
        """Given a filter strong, returns an list of stories matching that filter.  If none will return an empty list
        Look at [link](https://www.pivotaltracker.com/help/faq#howcanasearchberefined) for syntax

        """

        story_filter = quote(filter_string, safe='')
        stories_url = "https://www.pivotaltracker.com/services/v3/projects/{}/stories?filter={}".format(
            self.project_id, story_filter)

        response = _perform_pivotal_get(stories_url)
        stories_root = ET.fromstring(response.text)

        return [Story.from_node(story_node) for story_node in stories_root]
Exemple #5
0
    def from_node(cls, node):
        """instantiates a Story object from an elementTree node, build child notes and attachment lists"""

        story = Story()
        story.story_id = _parse_text(node, 'id')
        story.name = _parse_text(node, 'name')
        story.owned_by = _parse_text(node, 'owned_by')
        story.story_type = _parse_text(node, 'story_type')
        story.state = _parse_text(node, 'current_state')
        story.description = _parse_text(node, 'description')
        story.estimate = _parse_int(node, 'estimate')
        story.labels = _parse_text(node, 'labels')
        story.url = _parse_text(node, 'url')
        story.project_id = _parse_text(node, 'project_id')

        note_nodes = node.find('notes')
        if note_nodes is not None:
            for note_node in note_nodes:
                note_id = _parse_text(note_node, 'id')
                text = _parse_text(note_node, 'text')
                author = _parse_text(note_node, 'author')
                story.notes.append(Note(note_id, text, author))

        attachment_nodes = node.find('attachments')
        if attachment_nodes is not None:
            for attachment_node in attachment_nodes:
                attachment_id = _parse_text(attachment_node, 'id')
                description = _parse_text(attachment_node, 'text')
                url = _parse_text(attachment_node, 'url')
                story.attachments.append(
                    Attachment(attachment_id, description, url))

        task_nodes = node.find('tasks')
        if task_nodes is not None:
            for task_node in task_nodes:
                task_id = _parse_text(task_node, 'id')
                description = _parse_text(task_node, 'description')
                complete = _parse_boolean(task_node, 'complete')
                story.tasks.append(Task(task_id, description, complete))

        return story