# -*- encoding: utf-8 -*- ############################################################################## # # PyOrgMode, a python module for treating with orgfiles # Copyright (C) 2010 Jonathan BISSON (bissonjonathan on the google thing). # All Rights Reserved # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################## """ The PyOrgMode class is able to read,modify and create orgfiles. The internal representation of the file allows the use of orgfiles easily in your projects. """ import re import string import copy import time class OrgDate: """Functions for date management""" format = 0 TIMED = 1 DATED = 2 WEEKDAYED = 4 ACTIVE = 8 INACTIVE = 16 RANGED = 32 REPEAT = 64 # TODO: Timestamp with repeater interval DICT_RE = {'start': '[[<]', 'end': '[]>]', 'date': '([0-9]{4})-([0-9]{2})-([0-9]{2})(\s+([\w]+))?', 'time': '([0-9]{2}):([0-9]{2})', 'repeat': '[\+\.]{1,2}\d+[dwmy]'} def __init__(self,value=None): """ Initialisation of an OrgDate element. """ if value != None: self.set_value(value) def parse_datetime(self, s): """ Parses an org-mode date time string. Returns (timed, weekdayed, time_struct, repeat). """ search_re = '(?P{date})(\s+(?P