Exemplo n.º 1
0
    def write_org_subitem(self,
                          timestamp,
                          output,
                          note="",
                          properties=OrgProperties(),
                          tags=None):
        """
        Writes an org item line.

        i.e:** <timestamp> <output> :<tags>:\n
               :PROPERTIES:
               <properties>
               :ID: -generated id-
               :END:

        if an argument -a or --append is given,
        then a desicion regarding the :ID: is made if the item has to be
        written to file

        @param timestamp: str/unicode
        @param output: st tar/unicode
        @param note: str/unicode
        @param tags: list of tags
        @param properties: OrgProperties object
        """
        assert (timestamp.__class__ == str or timestamp.__class__ == unicode)
        assert tags.__class__ == list or tags == None
        assert properties.__class__ == OrgProperties
        assert (output.__class__ == str or output.__class__ == unicode)
        assert (note.__class__ == str or note.__class__ == unicode)

        # count the entries we have written, if above our limit do not write
        if self.__number_entries and \
            self.__entries_count == self.__number_entries:
            return
        else:
            self.__entries_count += 1

        if tags == None:
            tags = []

        if self.__autotag_dict != {}:
            self.__get_autotags(tags, output)

        ## fix time-stamps (if user wants to)
        if self.__timestamp_delta:
            timestamp = OrgFormat.apply_timedelta_to_Orgmode_timestamp(timestamp, int(self.__timestamp_delta))

        if self.__append:
            self.__append_org_subitem(timestamp,
                                      output,
                                      note,
                                      properties,
                                      tags)
        else:
            self.__write_org_subitem(timestamp,
                                     output,
                                     note,
                                     properties,
                                     tags)
Exemplo n.º 2
0
    def write_org_subitem(self,
                          timestamp,
                          output,
                          note="",
                          properties=OrgProperties(),
                          tags=None):
        """
        Writes an org item line.

        i.e:** <timestamp> <output> :<tags>:\n
               :PROPERTIES:
               <properties>
               :ID: -generated id-
               :END:

        if an argument -a or --append is given,
        then a desicion regarding the :ID: is made if the item has to be
        written to file

        @param timestamp: str/unicode
        @param output: st tar/unicode
        @param note: str/unicode
        @param tags: list of tags
        @param properties: OrgProperties object
        """
        assert (timestamp.__class__ == str or timestamp.__class__ == unicode)
        assert tags.__class__ == list or tags == None
        assert properties.__class__ == OrgProperties
        assert (output.__class__ == str or output.__class__ == unicode)
        assert (note.__class__ == str or note.__class__ == unicode)

        # count the entries we have written, if above our limit do not write
        if self.__number_entries and \
            self.__entries_count == self.__number_entries:
            return
        else:
            self.__entries_count += 1

        if tags == None:
            tags = []

        if self.__autotag_dict != {}:
            self.__get_autotags(tags, output)

        ## fix time-stamps (if user wants to)
        if self.__timestamp_delta:
            timestamp = OrgFormat.apply_timedelta_to_Orgmode_timestamp(
                timestamp, float(self.__timestamp_delta))

        ## a bit of a hack to get inactive time-stamps:
        ## FIXXME: use OrgFormat method to generate inactive time-stamps in the first place and remove asserts
        if self.__inactive_timestamps:
            assert (
                timestamp[0] == '<'
            )  ## at least try to find cases where this replace method fails
            assert (
                timestamp[-1] == '>'
            )  ## at least try to find cases where this replace method fails
            timestamp = '[' + timestamp[1:-1] + ']'

        if self.__append:
            self.__append_org_subitem(timestamp, output, note, properties,
                                      tags)
        else:
            self.__write_org_subitem(timestamp, output, note, properties, tags)
Exemplo n.º 3
0
    def write_org_subitem(self,
                          timestamp,
                          output,
                          note="",
                          properties=OrgProperties(),
                          tags=None):
        """
        Writes an org item line.

        i.e:** <timestamp> <output> :<tags>:\n
               :PROPERTIES:
               <properties>
               :ID: -generated id-
               :END:

        if an argument -a or --append is given,
        then a desicion regarding the :ID: is made if the item has to be
        written to file

        @param timestamp: str/unicode
        @param output: st tar/unicode
        @param note: str/unicode
        @param tags: list of tags
        @param properties: OrgProperties object
        """
        assert (timestamp.__class__ == str or timestamp.__class__ == unicode)
        assert tags.__class__ == list or tags == None
        assert properties.__class__ == OrgProperties
        assert (output.__class__ == str or output.__class__ == unicode)
        assert (note.__class__ == str or note.__class__ == unicode)

        # count the entries we have written, if above our limit do not write
        if self.__number_entries and \
            self.__entries_count == self.__number_entries:
            return
        else:
            self.__entries_count += 1

        if tags == None:
            tags = []

        if self.__autotag_dict != {}:
            self.__get_autotags(tags, output)

        ## fix time-stamps (if user wants to)
        if self.__timestamp_delta:
            timestamp = OrgFormat.apply_timedelta_to_Orgmode_timestamp(timestamp, int(self.__timestamp_delta))

        ## a bit of a hack to get inactive time-stamps:
        ## FIXXME: use OrgFormat method to generate inactive time-stamps in the first place and remove asserts
        if self.__inactive_timestamps:
            assert(timestamp[0] == '<')  ## at least try to find cases where this replace method fails
            assert(timestamp[-1] == '>')  ## at least try to find cases where this replace method fails
            timestamp = '[' + timestamp[1:-1] + ']'

        if self.__append:
            self.__append_org_subitem(timestamp,
                                      output,
                                      note,
                                      properties,
                                      tags)
        else:
            self.__write_org_subitem(timestamp,
                                     output,
                                     note,
                                     properties,
                                     tags)