コード例 #1
0
ファイル: parser.py プロジェクト: prust/basecampreporting
def parse_basecamp_xml(xml_object):
    if hasattr(xml_object, 'getchildren'):
        nodes = xml_object.getchildren()
    else:
        nodes = ET.fromstring(xml_object).getchildren()

    parsed = parse_tree(nodes)
    return parsed
コード例 #2
0
 def people(self):
     '''Dictionary of people on the project, keyed by id'''
     if self.cache['people']: return self.cache['people']
     people_xml = self.bc.people_within_project(self.id)
     for person_node in ET.fromstring(people_xml).findall('person'):
         p = Person(person_node)
         self.cache['people'][p.id] = p
     return self.cache['people']
コード例 #3
0
def parse_basecamp_xml(xml_object):
    if hasattr(xml_object, 'getchildren'):
        nodes = xml_object.getchildren()
    else:
        nodes = ET.fromstring(xml_object).getchildren()
        
    parsed = parse_tree(nodes)
    return parsed
コード例 #4
0
 def messages(self):
     if self.cache['messages']: return self.cache['messages']
     message_xml = self.bc.message_archive(self.id)
     messages = []
     for post in ET.fromstring(message_xml).findall("post"):
         messages.append(Message(post))
     self.cache['messages'] = messages
     return self.cache['messages']
コード例 #5
0
 def people(self):
     '''Dictionary of people on the project, keyed by id'''
     if self.cache['people']: return self.cache['people']
     people_xml = self.bc.people_within_project(self.id)
     for person_node in ET.fromstring(people_xml).findall('person'):
         p = Person(person_node)
         self.cache['people'][p.id] = p
     return self.cache['people']
コード例 #6
0
 def messages(self):
     if self.cache['messages']: return self.cache['messages']
     message_xml = self.bc.message_archive(self.id)
     messages = []
     for post in ET.fromstring(message_xml).findall("post"):
         messages.append(Message(post))
     self.cache['messages'] = messages
     return self.cache['messages']
コード例 #7
0
 def todo_lists(self):
     if self.cache['todo_lists']: return self.cache['todo_lists']
     todo_lists_xml = self.bc.todo_lists(self.id)
     todo_lists = {}
     for node in ET.fromstring(todo_lists_xml).findall("todo-list"):
         the_list = ToDoList(node)
         todo_lists[the_list.name] = the_list
     self.cache['todo_lists'] = todo_lists
     return self.cache['todo_lists']
コード例 #8
0
 def todo_lists(self):
     if self.cache['todo_lists']: return self.cache['todo_lists']
     todo_lists_xml = self.bc.todo_lists(self.id)
     todo_lists = {}
     for node in ET.fromstring(todo_lists_xml).findall("todo-list"):
         the_list = ToDoList(node)
         todo_lists[the_list.name] = the_list
     self.cache['todo_lists'] = todo_lists
     return self.cache['todo_lists']
コード例 #9
0
    def milestones(self):
        '''Array of all milestones'''
        if self.cache['milestones']: return self.cache['milestones']
        milestone_xml = self.bc.list_milestones(self.id)
        milestones = []
        for node in ET.fromstring(milestone_xml).findall("milestone"):
            milestones.append(Milestone(node))

        milestones.sort()
        milestones.reverse()
        self.cache['milestones'] = milestones
        return self.cache['milestones']
コード例 #10
0
 def comments(self):
     '''Looks through the last 3 messages and returns those comments.'''
     if self.cache['comments']: return self.cache['comments']
     comments = []
     for message in self.messages[0:3]:
         comment_xml = self.bc.comments(message.id)
         for comment_node in ET.fromstring(comment_xml).findall("comment"):
             comments.append(Comment(comment_node))
     comments.sort()
     comments.reverse()
     self.cache['comments'] = comments
     return self.cache['comments']
コード例 #11
0
    def milestones(self):
        '''Array of all milestones'''
        if self.cache['milestones']: return self.cache['milestones']
        milestone_xml = self.bc.list_milestones(self.id)
        milestones = []
        for node in ET.fromstring(milestone_xml).findall("milestone"):
            milestones.append(Milestone(node))

        milestones.sort()
        milestones.reverse()
        self.cache['milestones'] = milestones
        return self.cache['milestones']
コード例 #12
0
 def comments(self):
     '''Looks through the last 3 messages and returns those comments.'''
     if self.cache['comments']: return self.cache['comments']
     comments = []
     for message in self.messages[0:3]:
         comment_xml = self.bc.comments(message.id)
         for comment_node in ET.fromstring(comment_xml).findall("comment"):
             comments.append(Comment(comment_node))
     comments.sort()
     comments.reverse()
     self.cache['comments'] = comments
     return self.cache['comments']
コード例 #13
0
 def time_entries(self, start_date=None, end_date=None):
     '''Array of all time entries'''
     if self.cache['time_entries']: return self.cache['time_entries']
     if not start_date:
         start_date = datetime.date(1900, 1, 1)
     if not end_date:
         end_date = datetime.date.today()
     time_entry_xml = self.bc.list_time_entries(self.id, start_date, end_date)
     time_entries = []
     for entry in ET.fromstring(time_entry_xml).findall("time-entry"):
         time_entries.append(TimeEntry(entry))
     self.cache['time_entries'] = time_entries
     return self.cache['time_entries']
コード例 #14
0
 def time_entries(self, start_date=None, end_date=None):
     '''Array of all time entries'''
     if self.cache['time_entries']: return self.cache['time_entries']
     if not start_date:
         start_date = datetime.date(1900, 1, 1)
     if not end_date:
         end_date = datetime.date.today()
     time_entry_xml = self.bc.list_time_entries(self.id, start_date,
                                                end_date)
     time_entries = []
     for entry in ET.fromstring(time_entry_xml).findall("time-entry"):
         time_entries.append(TimeEntry(entry))
     self.cache['time_entries'] = time_entries
     return self.cache['time_entries']
コード例 #15
0
 def _get_project_info(self):
     project_xml = self.bc._request("/projects/%s.xml" % self.id)
     node = ET.fromstring(project_xml)
     self._name = node.findtext("name")
     self._status = node.findtext("status")
     self._last_changed_on = node.findtext("last-changed-on")
コード例 #16
0
 def _get_project_info(self):
     project_xml = self.bc._request("/projects/%s.xml" % self.id)
     node = ET.fromstring(project_xml)
     self._name = node.findtext("name")
     self._status = node.findtext("status")
     self._last_changed_on = node.findtext("last-changed-on")