Ejemplo n.º 1
0
    def _parse_task_node(self, task_node):
        '''Recursively parse the node and return a task instance. '''

        planned_start_datetime_attribute_name = 'startdate' if self.tskversion() <= 33 else 'plannedstartdate'
        kwargs = self.__parse_base_composite_attributes(task_node,
                                                        self.__parse_task_nodes)
        kwargs.update(dict(
            plannedStartDateTime=date.parseDateTime(task_node.attrib.get(planned_start_datetime_attribute_name, ''),
                                                    *self.defaultStartTime),
            dueDateTime=parseAndAdjustDateTime(task_node.attrib.get('duedate', ''),
                                               *self.defaultEndTime),
            actualStartDateTime=date.parseDateTime(task_node.attrib.get('actualstartdate', ''),
                                                   *self.defaultStartTime),
            completionDateTime=date.parseDateTime(task_node.attrib.get('completiondate', ''),
                                                  *self.defaultEndTime),
            percentageComplete=self.__parse_int_attribute(task_node,
                                                          'percentageComplete'),
            budget=date.parseTimeDelta(task_node.attrib.get('budget', '')),
            priority=self.__parse_int_attribute(task_node, 'priority'),
            hourlyFee=float(task_node.attrib.get('hourlyFee', '0')),
            fixedFee=float(task_node.attrib.get('fixedFee', '0')),
            reminder=self.__parse_datetime(task_node.attrib.get('reminder', '')),
            reminderBeforeSnooze=self.__parse_datetime(task_node.attrib.get('reminderBeforeSnooze', '')),
            # Ignore prerequisites for now, they'll be resolved later
            prerequisites=[],
            shouldMarkCompletedWhenAllChildrenCompleted=self.__parse_boolean(task_node.attrib.get('shouldMarkCompletedWhenAllChildrenCompleted', '')),
            efforts=self.__parse_effort_nodes(task_node),
            notes=self.__parse_note_nodes(task_node),
            recurrence=self.__parse_recurrence(task_node)))
        self.__prerequisites[kwargs['id']] = [id_ for id_ in task_node.attrib.get('prerequisites', '').split(' ') if id_]
        if self.__tskversion > 20:
            kwargs['attachments'] = self.__parse_attachments(task_node)
        return self.__save_modification_datetime(task.Task(**kwargs))  # pylint: disable=W0142
Ejemplo n.º 2
0
 def _parse_task_node(self, task_node):
     '''Recursively parse the node and return a task instance. '''
         
     planned_start_datetime_attribute_name = 'startdate' if self.tskversion() <= 33 else 'plannedstartdate'
     kwargs = self.__parse_base_composite_attributes(task_node,
                                                     self.__parse_task_nodes)
     kwargs.update(dict(
         plannedStartDateTime=date.parseDateTime(task_node.attrib.get(planned_start_datetime_attribute_name, ''), 
                                                 *self.defaultStartTime),
         dueDateTime=parseAndAdjustDateTime(task_node.attrib.get('duedate', ''), 
                                        *self.defaultEndTime),
         actualStartDateTime=date.parseDateTime(task_node.attrib.get('actualstartdate', ''),
                                                *self.defaultStartTime),
         completionDateTime=date.parseDateTime(task_node.attrib.get('completiondate', ''), 
                                               *self.defaultEndTime),
         percentageComplete=self.__parse_int_attribute(task_node, 
                                                    'percentageComplete'),
         budget=date.parseTimeDelta(task_node.attrib.get('budget', '')),
         priority=self.__parse_int_attribute(task_node, 'priority'),
         hourlyFee=float(task_node.attrib.get('hourlyFee', '0')),
         fixedFee=float(task_node.attrib.get('fixedFee', '0')),
         reminder=self.__parse_datetime(task_node.attrib.get('reminder', '')),
         reminderBeforeSnooze=self.__parse_datetime(task_node.attrib.get('reminderBeforeSnooze', '')),
         # Ignore prerequisites for now, they'll be resolved later
         prerequisites=[],
         shouldMarkCompletedWhenAllChildrenCompleted=self.__parse_boolean(task_node.attrib.get('shouldMarkCompletedWhenAllChildrenCompleted', '')),
         efforts=self.__parse_effort_nodes(task_node),
         notes=self.__parse_note_nodes(task_node),
         recurrence=self.__parse_recurrence(task_node)))
     self.__prerequisites[kwargs['id']] = [id_ for id_ in task_node.attrib.get('prerequisites', '').split(' ') if id_]
     if self.__tskversion > 20:
         kwargs['attachments'] = self.__parse_attachments(task_node)
     return self.__save_modification_datetime(task.Task(**kwargs))  # pylint: disable=W0142
Ejemplo n.º 3
0
 def _parseTaskNode(self, taskNode):
     class DummyPrerequisite(object):
         def __init__(self, id):
             self.id = id
         def __getattr__(self, attr):
             ''' Ignore all method calls. '''
             return lambda *args, **kwargs: None
         
     kwargs = self._parseBaseCompositeAttributes(taskNode, self._parseTaskNodes)
     kwargs.update(dict(
         startDateTime=date.parseDateTime(taskNode.attrib.get('startdate', ''), 
                                          *self.defaultStartTime),
         dueDateTime=date.parseDateTime(taskNode.attrib.get('duedate', ''), 
                                        *self.defaultEndTime),
         completionDateTime=date.parseDateTime(taskNode.attrib.get('completiondate', ''), 
                                               *self.defaultEndTime),
         percentageComplete=int(taskNode.attrib.get('percentageComplete','0')),
         budget=date.parseTimeDelta(taskNode.attrib.get('budget', '')),
         priority=int(taskNode.attrib.get('priority', '0')),
         hourlyFee=float(taskNode.attrib.get('hourlyFee', '0')),
         fixedFee=float(taskNode.attrib.get('fixedFee', '0')),
         reminder=self._parseDateTime(taskNode.attrib.get('reminder', '')),
         # Here we just add the ids, they will be converted to object references later on:
         prerequisites=[DummyPrerequisite(id) for id in taskNode.attrib.get('prerequisites', '').split(' ') if id], 
         shouldMarkCompletedWhenAllChildrenCompleted= \
             self._parseBoolean(taskNode.attrib.get('shouldMarkCompletedWhenAllChildrenCompleted', '')),
         efforts=self._parseEffortNodes(taskNode),
         notes=self._parseNoteNodes(taskNode),
         recurrence=self._parseRecurrence(taskNode)))
     if self.__tskversion > 20:
         kwargs['attachments'] = self._parseAttachmentNodes(taskNode)
     return task.Task(**kwargs) # pylint: disable-msg=W0142
Ejemplo n.º 4
0
 def _parseTaskNode(self, taskNode):
     class DummyPrerequisite(object):
         def __init__(self, id):
             self.id = id
         def __getattr__(self, attr):
             ''' Ignore all method calls. '''
             return lambda *args, **kwargs: None
         
     kwargs = self._parseBaseCompositeAttributes(taskNode, self._parseTaskNodes)
     kwargs.update(dict(
         startDateTime=date.parseDateTime(taskNode.attrib.get('startdate', ''), 
                                          *self.defaultStartTime),
         dueDateTime=date.parseDateTime(taskNode.attrib.get('duedate', ''), 
                                        *self.defaultEndTime),
         completionDateTime=date.parseDateTime(taskNode.attrib.get('completiondate', ''), 
                                               *self.defaultEndTime),
         percentageComplete=int(taskNode.attrib.get('percentageComplete','0')),
         budget=date.parseTimeDelta(taskNode.attrib.get('budget', '')),
         priority=int(taskNode.attrib.get('priority', '0')),
         hourlyFee=float(taskNode.attrib.get('hourlyFee', '0')),
         fixedFee=float(taskNode.attrib.get('fixedFee', '0')),
         reminder=self._parseDateTime(taskNode.attrib.get('reminder', '')),
         # Here we just add the ids, they will be converted to object references later on:
         prerequisites=[DummyPrerequisite(id) for id in taskNode.attrib.get('prerequisites', '').split(' ') if id], 
         shouldMarkCompletedWhenAllChildrenCompleted= \
             self._parseBoolean(taskNode.attrib.get('shouldMarkCompletedWhenAllChildrenCompleted', '')),
         efforts=self._parseEffortNodes(taskNode),
         notes=self._parseNoteNodes(taskNode),
         recurrence=self._parseRecurrence(taskNode)))
     if self.__tskversion > 20:
         kwargs['attachments'] = self._parseAttachmentNodes(taskNode)
     return task.Task(**kwargs) # pylint: disable-msg=W0142
Ejemplo n.º 5
0
 def __parseEffortNode(self, effortNode):
     kwargs = {}
     if self.__tskversion >= 21:
         kwargs['status'] = int(effortNode.getAttribute('status'))
     start = effortNode.getAttribute('start')
     stop = effortNode.getAttribute('stop')
     description = self.__parseDescription(effortNode)
     return effort.Effort(None, date.parseDateTime(start), 
         date.parseDateTime(stop), description, **kwargs)
Ejemplo n.º 6
0
 def _parseEffortNode(self, effortNode):
     kwargs = {}
     if self.__tskversion >= 22:
         kwargs['status'] = int(effortNode.attrib['status'])
     if self.__tskversion >= 29:
         kwargs['id'] = effortNode.attrib['id']
     start = effortNode.attrib.get('start', '')
     stop = effortNode.attrib.get('stop', '')
     description = self._parseDescription(effortNode)
     # pylint: disable-msg=W0142
     return effort.Effort(task=None, start=date.parseDateTime(start),
         stop=date.parseDateTime(stop), description=description, **kwargs)
Ejemplo n.º 7
0
 def _parseEffortNode(self, effortNode):
     kwargs = {}
     if self.__tskversion >= 22:
         kwargs['status'] = int(effortNode.attrib['status'])
     if self.__tskversion >= 29:
         kwargs['id'] = effortNode.attrib['id']
     start = effortNode.attrib.get('start', '')
     stop = effortNode.attrib.get('stop', '')
     description = self._parseDescription(effortNode)
     # task=None because it is set when the effort is actually added to the
     # task by the task itself. This way no events are sent for changing the
     # effort owner, which is good.
     # pylint: disable-msg=W0142 
     return effort.Effort(task=None, start=date.parseDateTime(start),
         stop=date.parseDateTime(stop), description=description, **kwargs)
Ejemplo n.º 8
0
 def __parse_effort_node(self, node):
     ''' Parse an effort record from the node. '''
     kwargs = {}
     if self.__tskversion >= 22:
         kwargs['status'] = int(node.attrib.get('status', '1'))
     if self.__tskversion >= 29:
         kwargs['id'] = node.attrib['id']
     start = node.attrib.get('start', '')
     stop = node.attrib.get('stop', '')
     description = self.__parse_description(node)
     # task=None because it is set when the effort is actually added to the
     # task by the task itself. This way no events are sent for changing the
     # effort owner, which is good.
     # pylint: disable=W0142 
     return effort.Effort(task=None, start=date.parseDateTime(start),
         stop=date.parseDateTime(stop), description=description, **kwargs)
Ejemplo n.º 9
0
 def __parse_effort_node(self, node):
     ''' Parse an effort record from the node. '''
     kwargs = {}
     if self.__tskversion >= 22:
         kwargs['status'] = int(node.attrib.get('status', '1'))
     if self.__tskversion >= 29:
         kwargs['id'] = node.attrib['id']
     start = node.attrib.get('start', '')
     stop = node.attrib.get('stop', '')
     description = self.__parse_description(node)
     # task=None because it is set when the effort is actually added to the
     # task by the task itself. This way no events are sent for changing the
     # effort owner, which is good.
     # pylint: disable=W0142 
     return effort.Effort(task=None, start=date.parseDateTime(start),
                          stop=date.parseDateTime(stop), description=description, **kwargs)
Ejemplo n.º 10
0
    def feed(self, data):
        super(InfiniteDateTimeItem, self).feed(data)

        if self.state == 2:
            if self.value is None:
                self.value = DateTime()
            else:
                self.value = parseDateTime(self.value)
Ejemplo n.º 11
0
    def feed(self, data):
        super(InfiniteDateTimeItem, self).feed(data)

        if self.state == 2:
            if self.value is None:
                self.value = DateTime()
            else:
                self.value = parseDateTime(self.value)
Ejemplo n.º 12
0
def parseAndAdjustDateTime(string, *timeDefaults):
    dateTime = date.parseDateTime(string, *timeDefaults)
    if dateTime != date.DateTime() and dateTime is not None and \
        dateTime.time() == date.Time(23, 59, 0, 0):
        dateTime = date.DateTime(year=dateTime.year,
                                 month=dateTime.month,
                                 day=dateTime.day,
                                 hour=23, minute=59, second=59, microsecond=999999)
    return dateTime
Ejemplo n.º 13
0
def parseAndAdjustDateTime(string, *timeDefaults):
    dateTime = date.parseDateTime(string, *timeDefaults)
    if dateTime != date.DateTime() and dateTime is not None and \
        dateTime.time() == date.Time(23, 59, 0, 0):
        dateTime = date.DateTime(year=dateTime.year,
                                 month=dateTime.month,
                                 day=dateTime.day,
                                 hour=23, minute=59, second=59, microsecond=999999)
    return dateTime
Ejemplo n.º 14
0
    def _parse_task_node(self, task_node):
        """Recursively parse the node and return a task instance. """

        planned_start_datetime_attribute_name = "startdate" if self.tskversion() <= 33 else "plannedstartdate"
        kwargs = self.__parse_base_composite_attributes(task_node, self.__parse_task_nodes)
        kwargs.update(
            dict(
                plannedStartDateTime=date.parseDateTime(
                    task_node.attrib.get(planned_start_datetime_attribute_name, ""), *self.defaultStartTime
                ),
                dueDateTime=parseAndAdjustDateTime(task_node.attrib.get("duedate", ""), *self.defaultEndTime),
                actualStartDateTime=date.parseDateTime(
                    task_node.attrib.get("actualstartdate", ""), *self.defaultStartTime
                ),
                completionDateTime=date.parseDateTime(task_node.attrib.get("completiondate", ""), *self.defaultEndTime),
                percentageComplete=self.__parse_int_attribute(task_node, "percentageComplete"),
                budget=date.parseTimeDelta(task_node.attrib.get("budget", "")),
                priority=self.__parse_int_attribute(task_node, "priority"),
                hourlyFee=float(task_node.attrib.get("hourlyFee", "0")),
                fixedFee=float(task_node.attrib.get("fixedFee", "0")),
                reminder=self.__parse_datetime(task_node.attrib.get("reminder", "")),
                reminderBeforeSnooze=self.__parse_datetime(task_node.attrib.get("reminderBeforeSnooze", "")),
                # Ignore prerequisites for now, they'll be resolved later
                prerequisites=[],
                shouldMarkCompletedWhenAllChildrenCompleted=self.__parse_boolean(
                    task_node.attrib.get("shouldMarkCompletedWhenAllChildrenCompleted", "")
                ),
                efforts=self.__parse_effort_nodes(task_node),
                notes=self.__parse_note_nodes(task_node),
                recurrence=self.__parse_recurrence(task_node),
            )
        )
        self.__prerequisites[kwargs["id"]] = [
            id_ for id_ in task_node.attrib.get("prerequisites", "").split(" ") if id_
        ]
        if self.__tskversion > 20:
            kwargs["attachments"] = self.__parse_attachments(task_node)
        return self.__save_modification_datetime(task.Task(**kwargs))  # pylint: disable=W0142
Ejemplo n.º 15
0
    def feed(self, data):
        super(DateTimeItem, self).feed(data)

        if self.state == 2:
            if self.value is not None:
                self.value = parseDateTime(self.value)
Ejemplo n.º 16
0
    def feed(self, data):
        super(DateTimeItem, self).feed(data)

        if self.state == 2:
            if self.value is not None:
                self.value = parseDateTime(self.value)
Ejemplo n.º 17
0
 def __parseEffortNode(self, effortNode):
     start = effortNode.getAttribute('start')
     stop = effortNode.getAttribute('stop')
     description = self.__parseDescription(effortNode)
     return effort.Effort(None, date.parseDateTime(start), 
         date.parseDateTime(stop), description)