Permalink
Browse files

Merge branch 'master' of github.com:novoid/Memacs

  • Loading branch information...
2 parents 4b2526e + c2a36f3 commit 4093cf4e5700e92e25cc8f511b99a9215c90477e @novoid committed Jun 25, 2012
Showing with 28 additions and 3 deletions.
  1. +26 −2 memacs/lib/orgproperty.py
  2. +2 −1 memacs/lib/orgwriter.py
View
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Time-stamp: <2012-03-09 14:39:17 armin>
+# Time-stamp: <2012-06-03 11:16:03 armin>
import hashlib
@@ -22,6 +22,7 @@ def __init__(self, data_for_hashing=""):
you can add here data only for hash generation
"""
self.__properties = {}
+ self.__properties_multiline = {}
self.__data_for_hashing = data_for_hashing
self.__id = None
@@ -33,10 +34,20 @@ def add(self, tag, value):
"""
tag = unicode(tag).strip().upper()
value = unicode(value).strip()
+
if tag == "ID":
raise Exception("you should not specify an :ID: property " + \
"it will be generated automatically")
+ value_multiline = value.splitlines()
+
+ if len(value_multiline) > 1:
+ # we do have multiline value
+ multiline_value = [" " + v for v in value_multiline]
+ self.__properties_multiline[tag] = multiline_value
+
+ value = " ".join(value_multiline)
+
self.__properties[tag] = unicode(value)
def set_id(self, value):
@@ -50,7 +61,11 @@ def delete(self, key):
delete a pair out of properties
@param key index
"""
- del self.__properties[key]
+ try:
+ del self.__properties[key]
+ del self.__properties_multiline[key]
+ except Keyerror, e:
+ pass
def __get_property_max_tag_width(self):
width = 10 # :PROPERTIES: has width 10
@@ -120,3 +135,12 @@ def get_value_delete_but_add_for_hashing(self, key):
self.delete(key)
self.add_data_for_hashing(ret)
return ret
+
+ def get_multiline_properties(self):
+ ret = ""
+ for key in self.__properties_multiline.keys():
+ ret += "\n " + key + ":\n"
+ ret += "\n".join(self.__properties_multiline[key])
+ ret += "\n"
+
+ return ret
View
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Time-stamp: <2012-04-16 20:13:03 armin>
+# Time-stamp: <2012-06-03 10:59:09 armin>
import codecs
import sys
@@ -147,6 +147,7 @@ def __write_org_subitem(self,
for n in note.splitlines():
self.writeln(" " + n)
self.writeln(unicode(properties))
+ self.write(properties.get_multiline_properties())
def write_org_subitem(self,
timestamp,

0 comments on commit 4093cf4

Please sign in to comment.