Skip to content

Commit

Permalink
:ID: is now generated automatically see FAQs_and_Best_Practices.org
Browse files Browse the repository at this point in the history
* lot of files needed a modification
* calendar got *apendmode*
* some cleanup

Signed-off-by: Armin Wieser <armin.wieser@gmail.com>
  • Loading branch information
awieser committed Dec 27, 2011
1 parent 10530bc commit 5a62211
Show file tree
Hide file tree
Showing 16 changed files with 920 additions and 1,135 deletions.
15 changes: 14 additions & 1 deletion FAQs_and_Best_Practices.org
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Time-stamp: <2011-10-18 10:56:50 vk>
## Time-stamp: <2011-12-27 21:59:44 armin>
## This file is best viewed with GNU Emacs Org-mode: http://orgmode.org/

* Best Practices
Expand Down Expand Up @@ -202,6 +202,19 @@ being executed.
If you have one question, please contact «Karl dot Voit
at IST dot TUGraz dot at» and he is happy to answer it.

** how works the *appendmode* of memacs? / How is the :ID: Property generated?
All properties (:PROPERTIES: drawer) are stored in a dict
: i.e.: :CREATED: <date>
: key = "CREATED , value = <date>

generation:
: id-hash = sha1(<all values> + <all keys>)

Before writing an entry to the org-file, the id is generated.

If Memacs module is in appendmode, it looks for those :ID: properties
and stores them in a list. On writing(append) it first checks against that list.

** Emacs always complains what to do with changed org files
Solution is to add this to your emacs config file (.emacs):
: (global-auto-revert-mode t)
50 changes: 4 additions & 46 deletions calendars/memacs_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

import sys
import os
import codecs
from urllib2 import urlopen, HTTPError, URLError
import logging
import time
from datetime import timedelta
# needed to import common.*
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from common.memacs import Memacs
Expand Down Expand Up @@ -62,46 +59,6 @@ def _parser_parse_args(self):
and not os.path.exists(self._args.calendar_file):
self._parser.error("calendar path not exists")

def __read_file(self, file):
"""
reads a file
@param file: path to file
@return: returns data
"""
try:
file = codecs.open(self._args.calendar_file, 'rb')
data = file.read()
file.close()
return data
except IOError:
logging.error("Error at opening file: %s" %
self._args.calendar_file)
sys.exit(1)

def __read_url(self, url):
"""
reads from a url
@param url: url to read
@returns: returns data
"""
try:
req = urlopen(self._args.calendar_url, None, 10)
return req.read()
except HTTPError:
logging.error("Error at opening url: %s" %
self._args.calendar_url)
sys.exit(1)
except URLError:
logging.error("Error at opening url: %s" %
self._args.calendar_url)
sys.exit(1)
except ValueError:
logging.error("Error - no valid url: %s" %
self._args.calendar_url)
sys.exit(1)

def __handle_vcalendar(self, component):
"""
handles a VCALENDAR Component
Expand Down Expand Up @@ -203,8 +160,8 @@ def __handle_vevent(self, component):
if description != None:
org_properties.add("DESCRIPTION", description)

self._writer.write_org_subitem(summary,
note=orgdate,
org_properties.add("created", orgdate)
self._writer.append_org_subitem(output=summary,
properties=org_properties)

def _main(self):
Expand All @@ -230,5 +187,6 @@ def _main(self):
prog_version_date=PROG_VERSION_DATE,
prog_description=PROG_DESCRIPTION,
prog_short_description=PROG_SHORT_DESCRIPTION,
prog_tag=PROG_TAG)
prog_tag=PROG_TAG,
append=True)
memacs.handle_main()
Loading

0 comments on commit 5a62211

Please sign in to comment.