def __get_datetime(self, mydate): """ @return string: Datetime - in Org Format """ mydate_tupel = OrgFormat.datetupelutctimestamp(mydate) return OrgFormat.date(mydate_tupel)
def __get_datetime(self, mydate): """ @return string: Datetime - in Org Format """ mydate_tupel = OrgFormat.datetupelutctimestamp(mydate) return OrgFormat.date(mydate_tupel)
def __get_datetime_range(self, dtstart, dtend): """ @return string: Datetime - Range in Org Format """ begin_tupel = OrgFormat.datetupelutctimestamp(dtstart) end_tupel = OrgFormat.datetupelutctimestamp(dtend) # handle "all-day" - events if begin_tupel.tm_sec == 0 and \ begin_tupel.tm_min == 0 and \ begin_tupel.tm_hour == 0 and \ end_tupel.tm_sec == 0 and \ end_tupel.tm_min == 0 and \ end_tupel.tm_hour == 0: # we have to subtract 1 day to get the correct dates end_tupel = time.localtime(time.mktime(end_tupel) - 24 * 60 * 60) return OrgFormat.utcrange(begin_tupel, end_tupel)
def __get_datetime_range(self, dtstart, dtend): """ @return string: Datetime - Range in Org Format """ begin_tupel = OrgFormat.datetupelutctimestamp(dtstart) end_tupel = OrgFormat.datetupelutctimestamp(dtend) # handle "all-day" - events if begin_tupel.tm_sec == 0 and \ begin_tupel.tm_min == 0 and \ begin_tupel.tm_hour == 0 and \ end_tupel.tm_sec == 0 and \ end_tupel.tm_min == 0 and \ end_tupel.tm_hour == 0: # we have to subtract 1 day to get the correct dates end_tupel = time.localtime(time.mktime(end_tupel) - 24 * 60 * 60) return OrgFormat.utcrange(begin_tupel, end_tupel)
def __write(self): """ write attributes to writer (make an org_sub_item) """ logging.debug("msg:%s", self.__msg) self.__msg = self.__msg.splitlines() subject = "" notes = "" # idea: look for the first -nonempty- message if len(self.__msg) > 0: start_notes = 0 for i in range(len(self.__msg)): if self.__msg[i].strip() != "": subject = self.__msg[i].strip() start_notes = i + 1 break if len(self.__msg) > start_notes: for n in self.__msg[start_notes:]: if n != "": notes += n + "\n" output = "%s (r%d): %s" % (self.__author, self.__rev, subject) properties = OrgProperties(data_for_hashing=self.__author + subject) timestamp = OrgFormat.datetime( OrgFormat.datetupelutctimestamp(self.__date)) properties.add("REVISION", self.__rev) if self.__grepauthor == None or \ (self.__author.strip() == self.__grepauthor.strip()): self._writer.write_org_subitem(output=output, timestamp=timestamp, note=notes, properties=properties)
def __write(self): """ write attributes to writer (make an org_sub_item) """ logging.debug("msg:%s", self.__msg) self.__msg = self.__msg.splitlines() subject = "" notes = "" # idea: look for the first -nonempty- message if len(self.__msg) > 0: start_notes = 0 for i in range(len(self.__msg)): if self.__msg[i].strip() != "": subject = self.__msg[i].strip() start_notes = i + 1 break if len(self.__msg) > start_notes: for n in self.__msg[start_notes:]: if n != "": notes += n + "\n" output = "%s (r%d): %s" % (self.__author, self.__rev, subject) properties = OrgProperties(data_for_hashing=self.__author + subject) timestamp = OrgFormat.datetime( OrgFormat.datetupelutctimestamp(self.__date)) properties.add("REVISION", self.__rev) if self.__grepauthor == None or \ (self.__author.strip() == self.__grepauthor.strip()): self._writer.write_org_subitem(output=output, timestamp=timestamp, note=notes, properties=properties)
def __write(self): """ write attributes to writer (make an org_sub_item) """ logging.debug("msg:%s", self.__msg) #getting tags if self.__attrtags: tags = self.__attrtags if self.__split: tags = tags.split(self.__split) else: tags = tags.split(' ') tags = tags[1:] elif self.__taging: tags = self.__taging if self.__split: tags = tags.split(self.__split) else: tags = tags.split(' ') else: tags = [] for item in tags: if item == '': tags.remove(item) #getting output if not self.__attroutput: output = "%s: %s" % (self.__author, self.__msg) else: output = self.__attroutput part = output.split(" ") output = "" for item in part: if re.search("http[s]?://", item) != None: unformatted_link = item short_link = OrgFormat.link(unformatted_link, "link") output = output + " " + short_link + ": " + item else: output = output + " " + item output = output[1:] #getting properties if not self.__attrproperties: properties = OrgProperties(data_for_hashing=self.__author \ + self.__msg + self.__date) else: properties = OrgProperties(data_for_hashing=self.__attrproperties) #getting notes if self.__attrnote: notes = self.__attrnote elif self.__notes: notes = self.__notes else: notes = "" if notes: parts = notes.split(" ") notes = "" for item in parts: if re.search("http[s]?://", item) != None: unformatted_link = item short_link = OrgFormat.link(unformatted_link, "link") notes = notes + " " + short_link + ": " + item else: notes = notes + " " + item notes = notes[1:] #prepare for most time formats + getting timestamp if self.__attrtime: self.__date = self.attrtime try: if (self.__time == 'YYYYMMDD' or self.__time == 'YYYY' or self.__time == 'YYYYMMDDTHHMMSSZ' or self.__time == 'YYYYMMDDTHHMMSST'): timestamp = OrgFormat.datetime( OrgFormat.datetupelutctimestamp( self.__date)) elif (self.__time == ('YYYY-MM-DD')): timestamp = OrgFormat.datetime( OrgFormat.datetupeliso8601( self.__date)) elif (self.__time == 'YYYY-MM-DDTHH.MM.SS' or self.__time == 'YYYY-MM-DDTHH.MM'): timestamp = OrgFormat.datetime( OrgFormat.datetimetupeliso8601( self.__date)) elif (self.__time == 'timetuple'): time_tupel = time.localtime(time.mktime( parsedate(self.__date))) timestamp = OrgFormat.datetime(time_tupel) except: logging.debug("Write functione @timestamp timestamp=%s", self.__date) logging.error("A timestamp problem occured") sys.exit(2) self._writer.write_org_subitem(output=output, timestamp=timestamp, note=notes, tags=tags, properties=properties)