[tracker/rss-enclosures] performance enhancements for the datagenerator



commit b8d017142e4ae59089e562625704bf12abb82f2f
Author: Akos PASZTORY <ext-akos pasztory nokia com>
Date:   Fri Apr 23 16:07:16 2010 +0300

    performance enhancements for the datagenerator

 utils/data-generators/cc/gen_data.py               |   16 ++--
 utils/data-generators/cc/generate                  |   40 ++++----
 utils/data-generators/cc/mfo.py                    |   22 ++---
 utils/data-generators/cc/mto.py                    |   31 ++----
 utils/data-generators/cc/ncal.py                   |   51 +++------
 utils/data-generators/cc/nco.py                    |   45 +++-----
 utils/data-generators/cc/nfo.py                    |   57 +++-------
 utils/data-generators/cc/nmm.py                    |   76 ++++----------
 utils/data-generators/cc/nmo.py                    |  115 +++++---------------
 .../cc/template/mfo_FeedChannel.tmpl               |   10 +-
 .../cc/template/mfo_FeedMessage.tmpl               |   14 ++--
 .../cc/template/mto_TransferElement.tmpl           |   12 +-
 .../cc/template/mto_UploadTransfer.tmpl            |   12 +-
 utils/data-generators/cc/template/ncal_Alarm.tmpl  |   12 +-
 .../data-generators/cc/template/ncal_Calendar.tmpl |    2 +-
 utils/data-generators/cc/template/ncal_Event.tmpl  |   22 ++--
 utils/data-generators/cc/template/ncal_Todo.tmpl   |   18 ++--
 .../cc/template/nco_EmailAddress.tmpl              |    4 +-
 .../cc/template/nco_PersonContact.tmpl             |   16 ++--
 .../cc/template/nco_PhoneNumber.tmpl               |    4 +-
 .../cc/template/nco_PostalAddress.tmpl             |   12 +-
 .../cc/template/nfo_PlainTextDocument.tmpl         |   24 ++--
 .../cc/template/nfo_SoftwareApplication.tmpl       |   20 ++--
 .../cc/template/nfo_SoftwareCategory.tmpl          |    4 +-
 .../cc/template/nfo_WebHistory.tmpl                |   14 ++--
 utils/data-generators/cc/template/nmm_Artist.tmpl  |    4 +-
 .../cc/template/nmm_MusicAlbum.tmpl                |    6 +-
 .../cc/template/nmm_MusicPiece.tmpl                |   44 ++++----
 utils/data-generators/cc/template/nmm_Photo.tmpl   |   24 ++--
 utils/data-generators/cc/template/nmm_Video.tmpl   |   22 ++--
 utils/data-generators/cc/template/nmo_Call.tmpl    |   22 ++--
 .../cc/template/nmo_CommunicationChannel.tmpl      |   12 +-
 utils/data-generators/cc/template/nmo_Email.tmpl   |   28 +++---
 .../data-generators/cc/template/nmo_IMMessage.tmpl |   28 +++---
 .../cc/template/nmo_MailAccount.tmpl               |    8 +-
 .../cc/template/nmo_MailFolder.tmpl                |    6 +-
 .../cc/template/nmo_SMSMessage.tmpl                |   30 +++---
 .../cc/template/tracker_Volume.tmpl                |    2 +-
 utils/data-generators/cc/tools.py                  |   16 ++--
 utils/data-generators/cc/tracker.py                |    9 +-
 40 files changed, 372 insertions(+), 542 deletions(-)
---
diff --git a/utils/data-generators/cc/gen_data.py b/utils/data-generators/cc/gen_data.py
index 3640a96..b361f53 100755
--- a/utils/data-generators/cc/gen_data.py
+++ b/utils/data-generators/cc/gen_data.py
@@ -94,23 +94,23 @@ def create_city_state_zip(zip_code=None):
 def create_sentence(min=4, max=15):
     sentence = []
     sentence.append(string.capitalize(random.choice(latin_words)))
-    for word in range(1, random.randint(min, max-1)):
+    for word in xrange(1, random.randint(min, max-1)):
         sentence.append(random.choice(latin_words))
-    return " ".join(sentence) + "."
+    return ' '.join(sentence) + '.'
 
 def create_paragraphs(num=1, min_sentences=4, max_sentences=7):
     paragraphs = []
-    for para in range(0, num):
-        for sentence in range(1, random.randint(min_sentences, max_sentences)):
+    for para in xrange(0, num):
+        for sentence in xrange(1, random.randint(min_sentences, max_sentences)):
             paragraphs.append(create_sentence()+" ")
         paragraphs.append("\n\n")
     return "".join(paragraphs)
 
 def create_text(min_sentences=4, max_sentences=10):
     text = []
-    for sentence in range(1, random.randint(min_sentences, max_sentences)):
-        text.append(create_sentence()+" ")
-    return "".join(text)
+    for sentence in xrange(1, random.randint(min_sentences, max_sentences)):
+        text.append(create_sentence())
+    return ' '.join(text)
 
 def create_date(numeric=True, past=False, max_years_future=10, max_years_past=10):
     """
@@ -151,7 +151,7 @@ def create_company_name(biz_type=None):
                      random.choice(last_names))
         name.append('LLP')
     else:
-        for i in range(1,random.randint(2,4)):
+        for i in xrange(1,random.randint(2,4)):
             rand_name = random.choice(company_names)
             if rand_name not in name:
                 name.append(rand_name)
diff --git a/utils/data-generators/cc/generate b/utils/data-generators/cc/generate
index 6292f39..8b02617 100755
--- a/utils/data-generators/cc/generate
+++ b/utils/data-generators/cc/generate
@@ -70,7 +70,7 @@ print "Loaded", templates_count, "templates"
 
 print "Generating Contacts",
 count_contacts = config.getint('counts','contacts')
-for contact in range(1, count_contacts+1):
+for contact in xrange(1, count_contacts+1):
   if (contact % 10 == 0):
     sys.stdout.write('.')
     sys.stdout.flush()
@@ -84,30 +84,30 @@ print "Generate Emails",
 count_accounts = config.getint('counts','accounts')
 count_folders = config.getint('counts','folders')
 count_emails = config.getint('counts','emails')
-for account in range(1, count_accounts+1):
+for account in xrange(1, count_accounts+1):
   sys.stdout.write('.')
   sys.stdout.flush()
   nmo.generateMailAccount( account*count_folders*count_emails )
-  for folder in range(1, count_folders+1):
+  for folder in xrange(1, count_folders+1):
     nmo.generateMailFolder( account*count_folders*count_emails+folder*count_emails )
-    for email in range(1, count_emails+1):
+    for email in xrange(1, count_emails+1):
       nmo.generateEmail( account*count_folders*count_emails+folder*count_emails+email )
 print "Done"
 
 print "Generate IM messages",
 count_comchans = config.getint('counts','comchans')
 count_ims = config.getint('counts','ims')
-for comchannel in range(1, count_comchans+1):
+for comchannel in xrange(1, count_comchans+1):
   sys.stdout.write('.')
   sys.stdout.flush()
   nmo.generateCommunicationChannel( comchannel )
-  for im in range(1, count_ims+1):
+  for im in xrange(1, count_ims+1):
     nmo.generateIMMessage( comchannel*count_ims+im )
 print "Done"
 
 print "Generate SMS messages",
 count_sms = config.getint('counts','sms')
-for sms in range(1, count_sms+1):
+for sms in xrange(1, count_sms+1):
   if (sms % 10 == 0):
     sys.stdout.write('.')
     sys.stdout.flush()
@@ -116,7 +116,7 @@ print "Done"
 
 print "Generate calls",
 count_calls = config.getint('counts','calls')
-for call in range(1, count_calls+1):
+for call in xrange(1, count_calls+1):
   if (call % 10 == 0):
     sys.stdout.write('.')
     sys.stdout.flush()
@@ -127,7 +127,7 @@ print "* Starting with file system based content"
 
 print "Generate volumes",
 count_volumes = config.getint('counts','volumes')
-for volume in range(1, count_volumes+1):
+for volume in xrange(1, count_volumes+1):
   sys.stdout.write('.')
   sys.stdout.flush()
   tracker.generateVolume( volume )
@@ -137,19 +137,19 @@ print "Generating Music",
 count_artists = config.getint('counts','artists')
 count_albums = config.getint('counts','albums')
 count_songs = config.getint('counts','songs')
-for artist in range(1, count_artists+1):
+for artist in xrange(1, count_artists+1):
   sys.stdout.write('.')
   sys.stdout.flush()
   nmm.generateArtist( artist*count_albums*count_songs )
-  for album in range(1, count_albums+1):
+  for album in xrange(1, count_albums+1):
     nmm.generateAlbum( artist*count_albums*count_songs+album )
-    for song in range(1, count_songs+1):
+    for song in xrange(1, count_songs+1):
       nmm.generateMusicPiece( artist*count_albums*count_songs+album*count_songs+song )
 print "Done"
 
 print "Generate Photos",
 count_images = config.getint('counts','images')
-for photo in range(1, count_images+1):
+for photo in xrange(1, count_images+1):
   if (photo % 10 == 0):
     sys.stdout.write('.')
     sys.stdout.flush()
@@ -158,7 +158,7 @@ print "Done"
 
 print "Generate Videos",
 count_videos = config.getint('counts','videos')
-for video in range(1, count_videos+1):
+for video in xrange(1, count_videos+1):
   if (video % 10 == 0):
     sys.stdout.write('.')
     sys.stdout.flush()
@@ -167,7 +167,7 @@ print "Done"
 
 print "Generate plain text documents",
 count_docs = config.getint('counts','docs')
-for doc in range(1, count_docs+1):
+for doc in xrange(1, count_docs+1):
   if (doc % 10 == 0):
     sys.stdout.write('.')
     sys.stdout.flush()
@@ -177,28 +177,28 @@ print "Done"
 print "Generate feeds",
 count_fchans = config.getint('counts','fchans')
 count_fms = config.getint('counts','fms')
-for fchan in range(1, count_fchans+1):
+for fchan in xrange(1, count_fchans+1):
   sys.stdout.write('.')
   sys.stdout.flush()
   mfo.generateFeedChannel( fchan*count_fms )
-  for fm in range(1, count_fms+1):
+  for fm in xrange(1, count_fms+1):
     mfo.generateFeedMessage( fchan*count_fms+fm )
 print "Done"
 
 print "Generate software",
 count_softcats = config.getint('counts','softcats')
 count_softapps = config.getint('counts','softapps')
-for softcat in range(1, count_softcats+1):
+for softcat in xrange(1, count_softcats+1):
   sys.stdout.write('.')
   sys.stdout.flush()
   nfo.generateSoftwareCategory( softcat*count_softapps )
-  for softapp in range(1, count_softapps+1):
+  for softapp in xrange(1, count_softapps+1):
     nfo.generateSoftwareApplication( softcat*count_softapps+softapp )
 print "Done"
 
 print "Generate something for the rest",
 count_others = config.getint('counts','others')
-for index in range(1,count_others+1):
+for index in xrange(1,count_others+1):
   if (index % 10 == 0):
     sys.stdout.write('.')
     sys.stdout.flush()
diff --git a/utils/data-generators/cc/mfo.py b/utils/data-generators/cc/mfo.py
index 6b8c91c..d4a9636 100644
--- a/utils/data-generators/cc/mfo.py
+++ b/utils/data-generators/cc/mfo.py
@@ -4,24 +4,23 @@ import tools
 
 ####################################################################################
 def generateFeedChannel(index):
+  me = 'mfo#FeedChannel'
   feed_channel_uri         = 'http://feed%d.feed.com/feed%d.rss' % (index % 1000, index)
   feed_channel_title       = 'Feed %d' % index
   feed_channel_description = 'Description %d' % (index % 1000)
 
   # save the last uri
-  tools.addUri( 'mfo#FeedChannel', feed_channel_uri )
+  tools.addUri( me, feed_channel_uri )
 
   # subsitute into template
-  channel = tools.getTemplate( 'mfo#FeedChannel' )
-  channel = channel.replace( '${feed_channel_uri}', feed_channel_uri )
-  channel = channel.replace( '${feed_channel_title}', feed_channel_title )
-  channel = channel.replace( '${feed_channel_description}', feed_channel_description )
+  channel = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'mfo#FeedChannel', channel )
+  tools.addResult( me, channel % locals())
 
 ####################################################################################
 def generateFeedMessage(index):
+  me = 'mfo#FeedMessage'
   feed_message_uri         = 'http://feed%d.feed.com/message%d.html' % (index % 1000, index)
   feed_message_title       = 'Message %d' % index
   feed_message_description = 'Description %d' % (index % 1000)
@@ -29,15 +28,10 @@ def generateFeedMessage(index):
   feed_message_channel     = tools.getLastUri( 'mfo#FeedChannel' )
 
   # save the last uri
-  tools.addUri( 'mfo#FeedMessage', feed_message_uri )
+  tools.addUri( me, feed_message_uri )
 
   # subsitute into template
-  message = tools.getTemplate( 'mfo#FeedMessage' )
-  message = message.replace( '${feed_message_uri}', feed_message_uri )
-  message = message.replace( '${feed_message_title}', feed_message_title )
-  message = message.replace( '${feed_message_description}', feed_message_description )
-  message = message.replace( '${feed_message_comment}', feed_message_comment )
-  message = message.replace( '${feed_message_channel}', feed_message_channel )
+  message = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'mfo#FeedMessage', message )
+  tools.addResult( me, message % locals() )
diff --git a/utils/data-generators/cc/mto.py b/utils/data-generators/cc/mto.py
index 9b29ec6..5e97ebc 100644
--- a/utils/data-generators/cc/mto.py
+++ b/utils/data-generators/cc/mto.py
@@ -4,30 +4,26 @@ import tools
 
 ####################################################################################
 def generateTransferElement(index):
+  me = 'mto#TransferElement'
   transfer_uri         = 'http://www.sopranolive.org/contexts/tracker/generated_unique_id/%d' % (index % 1000)
-  transfer_source      = tools.getRandomUri( 'nmm#Photo' ) 
+  transfer_source      = tools.getRandomUri( 'nmm#Photo' )
   transfer_destination = 'http://www.uploadsite%d.com/item%d' % (index % 100, index )
   transfer_started     = tools.getDateNowString()
   transfer_completed   = tools.getDateNowString()
   transfer_state       = 'http://www.tracker-project.org/temp/mto#state-done'
 
   # save the last uri
-  tools.addUri( 'mto#TransferElement', transfer_uri )
+  tools.addUri( me, transfer_uri )
 
   # subsitute into template
-  data = tools.getTemplate( 'mto#TransferElement' )
-  data = data.replace( '${transfer_uri}', transfer_uri )
-  data = data.replace( '${transfer_source}', transfer_source )
-  data = data.replace( '${transfer_destination}', transfer_destination )
-  data = data.replace( '${transfer_started}', transfer_started )
-  data = data.replace( '${transfer_completed}', transfer_completed )
-  data = data.replace( '${transfer_state}', transfer_state )
+  data = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'mto#TransferElement', data )
+  tools.addResult( me, data % locals() )
 
 ####################################################################################
 def generateUploadTransfer(index):
+  me = 'mto#UploadTransfer'
   upload_uri     = 'mtransfer://%d' % index
   upload_state   = 'http://www.tracker-project.org/temp/mto#state-done'
   upload_method  = 'http://www.tracker-project.org/temp/mto#transfer-method-web'
@@ -36,20 +32,13 @@ def generateUploadTransfer(index):
 
   # add some random transfers
   upload_transfers = ''
-  for index in range (1, 2 + (index % 10)):
+  for index in xrange (1, 2 + (index % 10)):
     upload_transfers += 'mto:transferList <%s> ;\n' % tools.getRandomUri( 'mto#TransferElement' )
 
   # save the last uri
-  tools.addUri( 'mto#UploadTransfer', upload_uri )
+  tools.addUri( me, upload_uri )
 
   # subsitute into template
-  data = tools.getTemplate( 'mto#UploadTransfer' )
-  data = data.replace( '${upload_uri}', upload_uri )
-  data = data.replace( '${upload_state}', upload_state )
-  data = data.replace( '${upload_method}', upload_method )
-  data = data.replace( '${upload_created}', upload_created )
-  data = data.replace( '${upload_account}', upload_account )
-  data = data.replace( '${upload_transfers}', upload_transfers )
-
+  data = tools.getTemplate( me )
   # save the result
-  tools.addResult( 'mto#UploadTransfer', data )
+  tools.addResult( me, data % locals() )
diff --git a/utils/data-generators/cc/ncal.py b/utils/data-generators/cc/ncal.py
index 7f80b64..d3e50e8 100644
--- a/utils/data-generators/cc/ncal.py
+++ b/utils/data-generators/cc/ncal.py
@@ -4,6 +4,7 @@ import tools
 
 ####################################################################################
 def generateAlarm(index):
+  me = 'ncal#Alarm'
   alarm_uri          = 'urn:x-ical:alarm%d' % index
   alarm_repeat       = '%d' % ( 3600 *  ((index % 10) + 1) )
   alarm_duration     = '%d' % ( 1 + (index % 10) )
@@ -12,37 +13,32 @@ def generateAlarm(index):
   alarm_description  = 'Description %d' % index
 
   # save the last uri
-  tools.addUri( 'ncal#Alarm', alarm_uri )
+  tools.addUri( me, alarm_uri )
 
   # subsitute into template
-  alarm = tools.getTemplate( 'ncal#Alarm' )
-  alarm = alarm.replace( '${alarm_uri}', alarm_uri )
-  alarm = alarm.replace( '${alarm_repeat}', alarm_repeat )
-  alarm = alarm.replace( '${alarm_duration}', alarm_duration )
-  alarm = alarm.replace( '${alarm_trigger_date}', alarm_trigger_date )
-  alarm = alarm.replace( '${alarm_subject}', alarm_subject )
-  alarm = alarm.replace( '${alarm_description}', alarm_description )
+  alarm = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'ncal#Alarm', alarm )
+  tools.addResult( me, alarm % locals() )
 
 ####################################################################################
 def generateCalendar(index):
+  me = 'ncal#Calendar'
   calendar_uri = 'urn:x-ical:calendar%d' % index
 
   # save the last uri
-  tools.addUri( 'ncal#Calendar', calendar_uri )
+  tools.addUri( me, calendar_uri )
 
   # subsitute into template
-  calendar = tools.getTemplate( 'ncal#Calendar' )
-  calendar = calendar.replace( '${calendar_uri}', calendar_uri )
+  calendar = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'ncal#Calendar', calendar )
+  tools.addResult( me, calendar % locals() )
 
 
 ####################################################################################
 def generateEvent(index):
+  me = 'ncal#Event'
   event_uri      = 'urn:x-ical:%d' % index
   event_uid      = '%d' % index
   event_start    = '%d-%02d-%02dT09:00:00Z' % (2010 + (index % 5), (index % 12) + 1, (index % 25) + 1)
@@ -54,25 +50,17 @@ def generateEvent(index):
   calendar_uri   = tools.getRandomUri( 'ncal#Calendar' )
 
   # save the last uri
-  tools.addUri( 'ncal#Event', event_uri )
+  tools.addUri( me, event_uri )
 
   # subsitute into template
-  event = tools.getTemplate( 'ncal#Event' )
-  event = event.replace( '${event_uri}', event_uri )
-  event = event.replace( '${event_uid}', event_uid )
-  event = event.replace( '${event_start}', event_start )
-  event = event.replace( '${event_end}', event_end )
-  event = event.replace( '${event_summary}', event_summary )
-  event = event.replace( '${event_created}', event_created )
-  event = event.replace( '${event_modified}', event_modified )
-  event = event.replace( '${alarm_uri}', alarm_uri )
-  event = event.replace( '${calendar_uri}', calendar_uri )
+  event = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'ncal#Event', event )
+  tools.addResult( me, event % locals() )
 
 ####################################################################################
 def generateTodo(index):
+  me = 'ncal#Todo'
   todo_uri      = 'urn:todo::%d' % index
   todo_uid      = '%d' % index
   todo_summary  = 'Todo %d' % index
@@ -82,17 +70,10 @@ def generateTodo(index):
   calendar_uri  = tools.getRandomUri( 'ncal#Calendar' )
 
   # save the last uri
-  tools.addUri( 'ncal#Todo', todo_uri )
+  tools.addUri( me, todo_uri )
 
   # subsitute into template
-  todo = tools.getTemplate( 'ncal#Todo' )
-  todo = todo.replace( '${todo_uri}', todo_uri )
-  todo = todo.replace( '${todo_uid}', todo_uid )
-  todo = todo.replace( '${todo_summary}', todo_summary )
-  todo = todo.replace( '${todo_created}', todo_created )
-  todo = todo.replace( '${todo_modified}', todo_modified )
-  todo = todo.replace( '${alarm_uri}', alarm_uri )
-  todo = todo.replace( '${calendar_uri}', calendar_uri )
+  todo = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'ncal#Todo', todo )
+  tools.addResult( me, todo % locals() )
diff --git a/utils/data-generators/cc/nco.py b/utils/data-generators/cc/nco.py
index 89d1eb2..f67b5b9 100644
--- a/utils/data-generators/cc/nco.py
+++ b/utils/data-generators/cc/nco.py
@@ -4,39 +4,38 @@ import tools
 
 ####################################################################################
 def generateEmailAddress(index):
+  me = 'nco#EmailAddress'
   email_address = 'given%d family%d domain%d com' % (index % 1000,index % 1000,index % 1000)
   email_address_uri = 'mailto:' + email_address
 
   # save the uri
-  tools.addUri( 'nco#EmailAddress', email_address_uri )
+  tools.addUri( me, email_address_uri )
 
   # substitute into template
-  email = tools.getTemplate( 'nco#EmailAddress' )
-  email = email.replace( '${email_address}', email_address )
-  email = email.replace( '${email_address_uri}', email_address_uri )
+  email = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nco#EmailAddress', email )
+  tools.addResult( me, email % locals() )
 
 ####################################################################################
 def generatePhoneNumber(index):
+  me = 'nco#PhoneNumber'
   phonenumber = '+%d-555-%08d' %(index, index)
   phonenumber_uri = 'tel:' + phonenumber
 
   # save the last uri
-  tools.addUri( 'nco#PhoneNumber', phonenumber_uri )
+  tools.addUri( me, phonenumber_uri )
 
   # subsitute into template
-  pn = tools.getTemplate( 'nco#PhoneNumber' )
-  pn = pn.replace( '${phonenumber_uri}', phonenumber_uri )
-  pn = pn.replace( '${phonenumber}', phonenumber )
+  pn = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nco#PhoneNumber', pn )
+  tools.addResult( me, pn % locals() )
 
 
 ####################################################################################
 def generatePostalAddress(index):
+  me = 'nco#PostalAddress'
   postal_address_uri         = 'urn:pa:%d' % index
   postal_address_country     = 'Country %d' % (index % 1000)
   postal_address_region      = 'Region %d' % (index % 1000)
@@ -45,22 +44,17 @@ def generatePostalAddress(index):
   postal_address_street      = 'Demo Street %d' % (index % 100)
 
   # save the last uri
-  tools.addUri( 'nco#PostalAddress', postal_address_uri )
+  tools.addUri( me, postal_address_uri )
 
   # subsitute into template
-  pa = tools.getTemplate( 'nco#PostalAddress' )
-  pa = pa.replace( '${postal_address_uri}', postal_address_uri )
-  pa = pa.replace( '${postal_address_country}', postal_address_country )
-  pa = pa.replace( '${postal_address_region}', postal_address_region )
-  pa = pa.replace( '${postal_address_postal_code}', postal_address_postal_code )
-  pa = pa.replace( '${postal_address_city}', postal_address_city )
-  pa = pa.replace( '${postal_address_street}', postal_address_street )
+  pa = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nco#PostalAddress', pa )
+  tools.addResult( me, pa % locals() )
 
 ####################################################################################
 def generatePersonContact(index):
+  me = 'nco#PersonContact'
   contact_uri         = 'urn:uid:%d' % index
   contact_name_given  = 'Given%d' % (index % 1000)
   contact_name_family = 'Family%d' % (index % 1000)
@@ -70,17 +64,10 @@ def generatePersonContact(index):
   postal_address_uri  = '<%s>' % tools.getLastUri( 'nco#PostalAddress' )
 
   # save the uri
-  tools.addUri( 'nco#PersonContact', contact_uri )
+  tools.addUri( me, contact_uri )
 
   # subsitute into template
-  pc = tools.getTemplate( 'nco#PersonContact' )
-  pc = pc.replace( '${contact_uri}', contact_uri )
-  pc = pc.replace( '${contact_name_given}', contact_name_given )
-  pc = pc.replace( '${contact_name_family}', contact_name_family )
-  pc = pc.replace( '${contact_birth_date}', contact_birth_date )
-  pc = pc.replace( '${email_address_uri}', email_address_uri )
-  pc = pc.replace( '${phonenumber_uri}', phonenumber_uri )
-  pc = pc.replace( '${postal_address_uri}', postal_address_uri )
+  pc = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nco#PersonContact', pc )
+  tools.addResult( me, pc % locals() )
diff --git a/utils/data-generators/cc/nfo.py b/utils/data-generators/cc/nfo.py
index fa13aa8..1d9bb81 100644
--- a/utils/data-generators/cc/nfo.py
+++ b/utils/data-generators/cc/nfo.py
@@ -5,6 +5,7 @@ import gen_data as gen
 
 ####################################################################################
 def generatePlainTextDocument(index):
+  me = 'nfo#PlainTextDocument'
   plaintext_document_datasource    = tools.getRandomUri( 'tracker#Volume' )
   plaintext_document_filename      = 'Plain_text_document_%d.txt' % (index % 1000)
   plaintext_document_container     = 'file://documents/'
@@ -18,43 +19,32 @@ def generatePlainTextDocument(index):
   plaintext_document_size          = '%d' % (1 + (index % 1000000))
 
   # save the last uri
-  tools.addUri( 'nfo#PlainTextDocument', plaintext_document_uri )
+  tools.addUri( me, plaintext_document_uri )
 
   # subsitute into template
-  doc = tools.getTemplate( 'nfo#PlainTextDocument' )
-  doc = doc.replace( '${plaintext_document_uri}', plaintext_document_uri )
-  doc = doc.replace( '${plaintext_document_url}', plaintext_document_url )
-  doc = doc.replace( '${plaintext_document_datasource}', plaintext_document_datasource )
-  doc = doc.replace( '${plaintext_document_filename}', plaintext_document_filename )
-  doc = doc.replace( '${plaintext_document_container}', plaintext_document_container )
-  doc = doc.replace( '${plaintext_document_mime}', plaintext_document_mime )
-  doc = doc.replace( '${plaintext_document_content}', plaintext_document_content )
-  doc = doc.replace( '${plaintext_document_stored_as}', plaintext_document_stored_as )
-  doc = doc.replace( '${plaintext_document_last_accessed}', plaintext_document_last_accessed )
-  doc = doc.replace( '${plaintext_document_last_modified}', plaintext_document_last_modified )
-  doc = doc.replace( '${plaintext_document_size}', plaintext_document_size )
+  doc = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nfo#PlainTextDocument', doc )
+  tools.addResult( me, doc % locals() )
 
 ####################################################################################
 def generateSoftwareCategory(index):
+  me = 'nfo#SoftwareCategory'
   application_category_uri   = 'urn:software-category:%d' % index
   application_category_title = 'Category %d' % (index % 1000)
 
   # save the last uri
-  tools.addUri( 'nfo#SoftwareCategory', application_category_uri )
+  tools.addUri( me, application_category_uri )
 
   # subsitute into template
-  category = tools.getTemplate( 'nfo#SoftwareCategory' )
-  category = category.replace( '${application_category_uri}', application_category_uri )
-  category = category.replace( '${application_category_title}', application_category_title )
+  category = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nfo#SoftwareCategory', category )
+  tools.addResult( me, category % locals() )
 
 ####################################################################################
 def generateSoftwareApplication(index):
+  me = 'nfo#SoftwareApplication'
   application_cmdline       = 'app%d' % index
   application_filename      = application_cmdline + '.desktop'
   application_uri           = 'file://applications/' + application_filename
@@ -66,26 +56,18 @@ def generateSoftwareApplication(index):
   application_icon          = 'urn:theme-icon:Icon-%d' % index
 
   # save the last uri
-  tools.addUri( 'nfo#SoftwareApplication', application_uri )
+  tools.addUri( me, application_uri )
 
   # subsitute into template
-  app = tools.getTemplate( 'nfo#SoftwareApplication' )
-  app = app.replace( '${application_cmdline}', application_cmdline )
-  app = app.replace( '${application_filename}', application_filename )
-  app = app.replace( '${application_uri}', application_uri )
-  app = app.replace( '${application_title}', application_title )
-  app = app.replace( '${application_part_of}', application_part_of )
-  app = app.replace( '${application_url}', application_url )
-  app = app.replace( '${application_datasource}', application_datasource )
-  app = app.replace( '${application_last_modified}', application_last_modified )
-  app = app.replace( '${application_icon}', application_icon )
+  app = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nfo#SoftwareApplication', app )
+  tools.addResult( me, app % locals() )
 
 
 ####################################################################################
 def generateWebHistory(index):
+  me = 'nfo#WebHistory'
   webhistory_uri       = 'urn:webhistory:%d' % index
   webhistory_title     = 'Web history %d' % (index % 1000)
   webhistory_date      = tools.getDateNowString()
@@ -95,18 +77,11 @@ def generateWebHistory(index):
   webhistory_url       = 'http://www.%d.com/' % index
 
   # save the last uri
-  tools.addUri( 'nfo#WebHistory', webhistory_uri )
+  tools.addUri( me, webhistory_uri )
 
   # subsitute into template
-  data = tools.getTemplate( 'nfo#WebHistory' )
-  data = data.replace( '${webhistory_uri}', webhistory_uri )
-  data = data.replace( '${webhistory_title}', webhistory_title )
-  data = data.replace( '${webhistory_date}', webhistory_date )
-  data = data.replace( '${webhistory_created}', webhistory_created )
-  data = data.replace( '${webhistory_modified}', webhistory_modified )
-  data = data.replace( '${webhistory_counter}', webhistory_counter )
-  data = data.replace( '${webhistory_url}', webhistory_url )
+  data = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nfo#WebHistory', data )
+  tools.addResult( me, data % locals() )
 
diff --git a/utils/data-generators/cc/nmm.py b/utils/data-generators/cc/nmm.py
index a99b052..f517115 100644
--- a/utils/data-generators/cc/nmm.py
+++ b/utils/data-generators/cc/nmm.py
@@ -4,6 +4,7 @@ import tools
 
 ####################################################################################
 def generatePhoto(index):
+  me = 'nmm#Photo'
   photo_uri          = 'urn:photo:%d' % index
   photo_filename     = 'photo%d.jpg' % index
   photo_url          = 'file:///path/' + photo_filename
@@ -18,25 +19,17 @@ def generatePhoto(index):
   photo_date         = '%d-%02d-%02dT01:01:01Z' % (2000 + (index % 10), (index % 12) + 1, (index % 25) + 1)
 
   # save the last uri
-  tools.addUri( 'nmm#Photo', photo_uri )
+  tools.addUri( me, photo_uri )
 
   # subsitute into template
-  photo = tools.getTemplate( 'nmm#Photo' )
-  photo = photo.replace( '${photo_uri}', photo_uri )
-  photo = photo.replace( '${photo_filename}', photo_filename )
-  photo = photo.replace( '${photo_url}', photo_url )
-  photo = photo.replace( '${photo_size}',  photo_size)
-  photo = photo.replace( '${photo_camera}', photo_camera )
-  photo = photo.replace( '${photo_exposure}', photo_exposure )
-  photo = photo.replace( '${photo_fnumber}', photo_fnumber )
-  photo = photo.replace( '${photo_focal_length}', photo_focal_length )
-  photo = photo.replace( '${photo_date}', photo_date )
+  photo = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmm#Photo', photo )
+  tools.addResult( me, photo % locals() )
 
 ####################################################################################
 def generateVideo(index):
+  me = 'nmm#Video'
   video_uri          = 'urn:video:%d' % index
   video_filename     = 'video%d.jpg' % index
   video_url          = 'file:///path/' + video_filename
@@ -47,56 +40,47 @@ def generateVideo(index):
   video_tag          = 'TEST%d' % index
 
   # save the last uri
-  tools.addUri( 'nmm#Video', video_uri )
+  tools.addUri( me, video_uri )
 
   # subsitute into template
-  video = tools.getTemplate( 'nmm#Video' )
-  video = video.replace( '${video_uri}', video_uri )
-  video = video.replace( '${video_filename}', video_filename )
-  video = video.replace( '${video_url}', video_url )
-  video = video.replace( '${video_size}',  video_size)
-  video = video.replace( '${video_date}', video_date )
-  video = video.replace( '${video_samplerate}', video_samplerate )
-  video = video.replace( '${video_duration}', video_duration )
-  video = video.replace( '${video_tag}', video_tag )
+  video = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmm#Video', video )
+  tools.addResult( me, video % locals() )
 
 ####################################################################################
 def generateArtist(index):
+  me = 'nmm#Artist'
   artist_uri  = 'urn:artist:%d' % index
   artist_name = 'Artist %d' % (index % 1000)
 
   # save the last uri
-  tools.addUri( 'nmm#Artist', artist_uri )
+  tools.addUri( me, artist_uri )
 
   # subsitute into template
-  artist = tools.getTemplate( 'nmm#Artist' )
-  artist = artist.replace( '${artist_uri}', artist_uri )
-  artist = artist.replace( '${artist_name}', artist_name )
+  artist = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmm#Artist', artist )
+  tools.addResult( me, artist % locals() )
 
 ####################################################################################
 def generateAlbum(index):
+  me = 'nmm#MusicAlbum'
   album_uri  = 'urn:album:%d' % index
   album_name = 'Album %d' % (index % 1000)
 
   # save the last uri
-  tools.addUri( 'nmm#MusicAlbum', album_uri )
+  tools.addUri( me, album_uri )
 
   # subsitute into template
-  album = tools.getTemplate( 'nmm#MusicAlbum' )
-  album = album.replace( '${album_uri}', album_uri )
-  album = album.replace( '${album_name}', album_name )
+  album = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmm#MusicAlbum', album )
+  tools.addResult( me, album % locals() )
 
 ####################################################################################
 def generateMusicPiece(index):
+  me = 'nmm#MusicPiece'
   music_piece_uri           = 'urn:music:%d' % index
   music_piece_title         = 'Song %d' % (index % 1000)
   music_piece_size          = str(index)
@@ -118,30 +102,10 @@ def generateMusicPiece(index):
   music_piece_track         = '%d' % (1 + (index % 100))
 
   # save the last uri
-  tools.addUri( 'nmm#MusicPiece', music_piece_uri )
+  tools.addUri( me, music_piece_uri )
 
   # subsitute into template
-  mp = tools.getTemplate( 'nmm#MusicPiece' )
-  mp = mp.replace( '${music_piece_uri}', music_piece_uri )
-  mp = mp.replace( '${music_piece_title}', music_piece_title )
-  mp = mp.replace( '${music_piece_size}', music_piece_size )
-  mp = mp.replace( '${music_piece_container}', music_piece_container )
-  mp = mp.replace( '${music_piece_filename}', music_piece_filename )
-  mp = mp.replace( '${music_piece_url}', music_piece_url )
-  mp = mp.replace( '${music_piece_mime}', music_piece_mime )
-  mp = mp.replace( '${music_piece_date}', music_piece_date )
-  mp = mp.replace( '${music_piece_date}', music_piece_date )
-  mp = mp.replace( '${music_piece_last_accessed}', music_piece_last_accessed )
-  mp = mp.replace( '${music_piece_last_modified}', music_piece_last_modified )
-  mp = mp.replace( '${music_piece_codec}', music_piece_codec )
-  mp = mp.replace( '${music_piece_bitrate}', music_piece_bitrate )
-  mp = mp.replace( '${music_piece_genre}', music_piece_genre )
-  mp = mp.replace( '${music_piece_channels}', music_piece_channels )
-  mp = mp.replace( '${music_piece_sample_rate}', music_piece_sample_rate )
-  mp = mp.replace( '${music_piece_album}', music_piece_album )
-  mp = mp.replace( '${music_piece_artist}', music_piece_artist )
-  mp = mp.replace( '${music_piece_length}', music_piece_length )
-  mp = mp.replace( '${music_piece_track}', music_piece_track )
+  mp = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmm#MusicPiece', mp )
+  tools.addResult( me, mp % locals() )
diff --git a/utils/data-generators/cc/nmo.py b/utils/data-generators/cc/nmo.py
index 8792eb3..dec1e5a 100644
--- a/utils/data-generators/cc/nmo.py
+++ b/utils/data-generators/cc/nmo.py
@@ -5,45 +5,41 @@ import gen_data as gen
 
 ####################################################################################
 def generateMailAccount(index):
+  me = 'nmo#MailAccount'
   account_uri              = 'qmf://groove.nokia.com/accounts#%d' % index
   account_from_address_uri = '<from:%d>' % index
   account_name             = 'Account %d' % (index % 1000)
   account_signature        = 'Signature %d' % (index % 1000)
 
   # save the last uri
-  tools.addUri( 'nmo#MailAccount', account_uri )
+  tools.addUri( me, account_uri )
 
   # subsitute into template
-  account = tools.getTemplate( 'nmo#MailAccount' )
-  account = account.replace( '${account_uri}', account_uri )
-  account = account.replace( '${account_from_address_uri}', account_from_address_uri )
-  account = account.replace( '${account_name}', account_name )
-  account = account.replace( '${account_signature}', account_signature )
+  account = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmo#MailAccount', account )
+  tools.addResult( me, account % locals() )
 
 
 ####################################################################################
 def generateMailFolder(index):
+  me = 'nmo#MailFolder'
   mailfolder_uri     = 'qmf://groove.nokia.com/folder#%d' % index
   mailfolder_account = '<%s>' % tools.getRandomUri( 'nmo#MailAccount' )
   mailfolder_name    = 'Folder %d' % (index % 1000)
 
   # save the last uri
-  tools.addUri( 'nmo#MailFolder', mailfolder_uri )
+  tools.addUri( me, mailfolder_uri )
 
   # subsitute into template
-  folder = tools.getTemplate( 'nmo#MailFolder' )
-  folder = folder.replace( '${mailfolder_uri}', mailfolder_uri )
-  folder = folder.replace( '${mailfolder_account}', mailfolder_account )
-  folder = folder.replace( '${mailfolder_name}', mailfolder_name )
+  folder = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmo#MailFolder', folder )
+  tools.addResult( me, folder % locals() )
 
 ####################################################################################
 def generateEmail(index):
+  me = 'nmo#Email'
   email_uri       = 'qmf://groove.nokia.com/email%d' % index
   email_mime      = 'multipart/mixed'
   email_stored_as = 'urn:uuid:XX:%d' % index
@@ -59,29 +55,17 @@ def generateEmail(index):
   email_content   = gen.create_text(2,30)
 
   # save the last uri
-  tools.addUri( 'nmo#Email', email_uri )
+  tools.addUri( me, email_uri )
 
   # subsitute into template
-  email = tools.getTemplate( 'nmo#Email' )
-  email = email.replace( '${email_uri}', email_uri )
-  email = email.replace( '${email_mime}', email_mime )
-  email = email.replace( '${email_stored_as}', email_stored_as )
-  email = email.replace( '${email_account}', email_account )
-  email = email.replace( '${email_folder}', email_folder )
-  email = email.replace( '${email_size}', email_size )
-  email = email.replace( '${email_recipient}', email_recipient )
-  email = email.replace( '${email_id}', email_id )
-  email = email.replace( '${email_subject}', email_subject )
-  email = email.replace( '${email_received}', email_received )
-  email = email.replace( '${email_sender}', email_sender )
-  email = email.replace( '${email_sent}', email_sent )
-  email = email.replace( '${email_content}', email_content )
+  email = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmo#Email', email )
+  tools.addResult( me, email % locals() )
 
 ####################################################################################
 def generateCommunicationChannel(index):
+  me = 'nmo#CommunicationChannel'
   channel_uri          = 'urn:channel:%d' % index
   channel_subject      = '/org/freedesktop/Telepathy/Account/gabble/jabber/dut_40localhost0'
   channel_date         = tools.getDateNowString()
@@ -90,22 +74,17 @@ def generateCommunicationChannel(index):
   channel_participiant = tools.getRandomUri( 'nco#PersonContact' )
 
   # save the last uri
-  tools.addUri( 'nmo#CommunicationChannel', channel_uri )
+  tools.addUri( me, channel_uri )
 
   # subsitute into template
-  channel = tools.getTemplate( 'nmo#CommunicationChannel' )
-  channel = channel.replace( '${channel_uri}', channel_uri )
-  channel = channel.replace( '${channel_subject}', channel_subject )
-  channel = channel.replace( '${channel_date}', channel_date )
-  channel = channel.replace( '${channel_modified}', channel_modified )
-  channel = channel.replace( '${channel_last_message}', channel_last_message )
-  channel = channel.replace( '${channel_participiant}', channel_participiant )
+  channel = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmo#CommunicationChannel', channel )
+  tools.addResult( me, channel % locals() )
 
 ####################################################################################
 def generateIMMessage(index):
+  me = 'nmo#IMMessage'
   immessage_uri         = 'urn:immessage:%d' % index
   immessage_content     = 'Lorem IM Ipsum %d' % index
   immessage_date        = tools.getDateNowString()
@@ -122,30 +101,17 @@ def generateIMMessage(index):
   immessage_content     = gen.create_text( 1, 2 )
 
   # save the last uri
-  tools.addUri( 'nmo#IMMessage', immessage_uri )
+  tools.addUri( me, immessage_uri )
 
   # subsitute into template
-  imm = tools.getTemplate( 'nmo#IMMessage' )
-  imm = imm.replace( '${immessage_uri}', immessage_uri )
-  imm = imm.replace( '${immessage_content}', immessage_content )
-  imm = imm.replace( '${immessage_date}', immessage_date )
-  imm = imm.replace( '${immessage_modified}', immessage_modified )
-  imm = imm.replace( '${immessage_from}', immessage_from )
-  imm = imm.replace( '${immessage_to}', immessage_to )
-  imm = imm.replace( '${immessage_draft}', immessage_draft )
-  imm = imm.replace( '${immessage_read}', immessage_read )
-  imm = imm.replace( '${immessage_sent}', immessage_sent )
-  imm = imm.replace( '${immessage_message_id}', immessage_message_id )
-  imm = imm.replace( '${immessage_received}', immessage_received )
-  imm = imm.replace( '${immessage_sent_date}', immessage_sent_date )
-  imm = imm.replace( '${immessage_channel_uri}', immessage_channel_uri )
-  imm = imm.replace( '${immessage_content}', immessage_content )
+  imm = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmo#IMMessage', imm )
+  tools.addResult( me, imm % locals() )
 
 ####################################################################################
 def generateSMSMessage(index):
+  me = 'nmo#SMSMessage'
   smsmessage_uri         = 'urn:sms:%d' % index
   smsmessage_id          = '%d' % index
   smsmessage_content     = 'Lorem SMS Ipsum %d' % index
@@ -163,31 +129,17 @@ def generateSMSMessage(index):
   smsmessage_content     = gen.create_text( 1, 5 )
 
   # save the last uri
-  tools.addUri( 'nmo#SMSMessage', smsmessage_uri )
+  tools.addUri( me, smsmessage_uri )
 
   # subsitute into template
-  sms = tools.getTemplate( 'nmo#SMSMessage' )
-  sms = sms.replace( '${smsmessage_uri}', smsmessage_uri )
-  sms = sms.replace( '${smsmessage_id}', smsmessage_id )
-  sms = sms.replace( '${smsmessage_content}', smsmessage_content )
-  sms = sms.replace( '${smsmessage_date}', smsmessage_date )
-  sms = sms.replace( '${smsmessage_modified}', smsmessage_modified )
-  sms = sms.replace( '${smsmessage_from}', smsmessage_from )
-  sms = sms.replace( '${smsmessage_to}', smsmessage_to )
-  sms = sms.replace( '${smsmessage_draft}', smsmessage_draft )
-  sms = sms.replace( '${smsmessage_read}', smsmessage_read )
-  sms = sms.replace( '${smsmessage_sent}', smsmessage_sent )
-  sms = sms.replace( '${smsmessage_message_id}', smsmessage_message_id )
-  sms = sms.replace( '${smsmessage_received}', smsmessage_received )
-  sms = sms.replace( '${smsmessage_sent_date}', smsmessage_sent_date )
-  sms = sms.replace( '${smsmessage_channel_uri}', smsmessage_channel_uri )
-  sms = sms.replace( '${smsmessage_content}', smsmessage_content )
+  sms = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmo#SMSMessage', sms )
+  tools.addResult( me, sms % locals() )
 
 ####################################################################################
 def generateCall(index):
+  me = 'nmo#Call'
   call_uri         = 'urn:call:%d' % index
   call_subject     = 'Subject %d' % index
   call_date        = tools.getDateNowString()
@@ -201,21 +153,10 @@ def generateCall(index):
   call_duration    = '%d' % ( 10 + (index % 3600) )
 
   # save the last uri
-  tools.addUri( 'nmo#Call', call_uri )
+  tools.addUri( me, call_uri )
 
   # subsitute into template
-  call = tools.getTemplate( 'nmo#Call' )
-  call = call.replace( '${call_uri}', call_uri )
-  call = call.replace( '${call_subject}', call_subject )
-  call = call.replace( '${call_date}', call_date )
-  call = call.replace( '${call_modified}', call_modified )
-  call = call.replace( '${call_from}', call_from )
-  call = call.replace( '${call_to}', call_to )
-  call = call.replace( '${call_read}', call_read )
-  call = call.replace( '${call_sent}', call_sent )
-  call = call.replace( '${call_received}', call_received )
-  call = call.replace( '${call_sent_date}', call_sent_date )
-  call = call.replace( '${call_duration}', call_duration )
+  call = tools.getTemplate( me )
 
   # save the result
-  tools.addResult( 'nmo#Call', call )
+  tools.addResult( me, call % locals() )
diff --git a/utils/data-generators/cc/template/mfo_FeedChannel.tmpl b/utils/data-generators/cc/template/mfo_FeedChannel.tmpl
index cc414e7..07772f6 100644
--- a/utils/data-generators/cc/template/mfo_FeedChannel.tmpl
+++ b/utils/data-generators/cc/template/mfo_FeedChannel.tmpl
@@ -1,7 +1,7 @@
-<${feed_channel_uri}> a mfo:FeedChannel ;
-  nie:title       "${feed_channel_title}" ;
-  nie:relatedTo   <${feed_channel_uri}> ;
-  nie:description "${feed_channel_description}" ;
-  nie:links       <${feed_channel_uri}> ;
+<%(feed_channel_uri)s> a mfo:FeedChannel ;
+  nie:title       "%(feed_channel_title)s" ;
+  nie:relatedTo   <%(feed_channel_uri)s> ;
+  nie:description "%(feed_channel_description)s" ;
+  nie:links       <%(feed_channel_uri)s> ;
   mfo:image       "" ;
   mfo:type        <http://www.tracker-project.org/temp/mfo#rssatom> .
diff --git a/utils/data-generators/cc/template/mfo_FeedMessage.tmpl b/utils/data-generators/cc/template/mfo_FeedMessage.tmpl
index 070697f..c278318 100644
--- a/utils/data-generators/cc/template/mfo_FeedMessage.tmpl
+++ b/utils/data-generators/cc/template/mfo_FeedMessage.tmpl
@@ -1,7 +1,7 @@
-<${feed_message_uri}> a mfo:FeedMessage ;
-  nie:title                "${feed_message_title}" ;
-  nie:relatedTo            <${feed_message_uri}> ;
-  nie:description          "${feed_message_description}" ;
-  nie:links                <${feed_message_uri}> ;
-  nie:comment              "${feed_message_comment}" ;
-  nmo:communicationChannel <${feed_message_channel}> .
+<%(feed_message_uri)s> a mfo:FeedMessage ;
+  nie:title                "%(feed_message_title)s" ;
+  nie:relatedTo            <%(feed_message_uri)s> ;
+  nie:description          "%(feed_message_description)s" ;
+  nie:links                <%(feed_message_uri)s> ;
+  nie:comment              "%(feed_message_comment)s" ;
+  nmo:communicationChannel <%(feed_message_channel)s> .
diff --git a/utils/data-generators/cc/template/mto_TransferElement.tmpl b/utils/data-generators/cc/template/mto_TransferElement.tmpl
index 6095def..7cf56c0 100644
--- a/utils/data-generators/cc/template/mto_TransferElement.tmpl
+++ b/utils/data-generators/cc/template/mto_TransferElement.tmpl
@@ -1,6 +1,6 @@
-<${transfer_uri}> a mto:TransferElement ;
-  mto:source        <${transfer_source}> ;
-  mto:destination   <${transfer_destination}> ;
-  mto:startedTime   "${transfer_started}" ;
-  mto:completedTime "${transfer_completed}" ;
-  mto:state         <${transfer_state}> .
+<%(transfer_uri)s> a mto:TransferElement ;
+  mto:source        <%(transfer_source)s> ;
+  mto:destination   <%(transfer_destination)s> ;
+  mto:startedTime   "%(transfer_started)s" ;
+  mto:completedTime "%(transfer_completed)s" ;
+  mto:state         <%(transfer_state)s> .
diff --git a/utils/data-generators/cc/template/mto_UploadTransfer.tmpl b/utils/data-generators/cc/template/mto_UploadTransfer.tmpl
index 5f90139..c137b12 100644
--- a/utils/data-generators/cc/template/mto_UploadTransfer.tmpl
+++ b/utils/data-generators/cc/template/mto_UploadTransfer.tmpl
@@ -1,6 +1,6 @@
-<${upload_uri}> a mto:UploadTransfer ;
-  mto:transferState  <${upload_state}> ;
-  mto:method         <${upload_method}> ;
-  mto:created        "${upload_created}" ;
-${upload_transfers}  
-  mto:account        "${upload_account}" .
+<%(upload_uri)s> a mto:UploadTransfer ;
+  mto:transferState  <%(upload_state)s> ;
+  mto:method         <%(upload_method)s> ;
+  mto:created        "%(upload_created)s" ;
+%(upload_transfers)s
+  mto:account        "%(upload_account)s" .
diff --git a/utils/data-generators/cc/template/ncal_Alarm.tmpl b/utils/data-generators/cc/template/ncal_Alarm.tmpl
index 473a233..80827ec 100644
--- a/utils/data-generators/cc/template/ncal_Alarm.tmpl
+++ b/utils/data-generators/cc/template/ncal_Alarm.tmpl
@@ -1,7 +1,7 @@
-<${alarm_uri}> a ncal:Alarm; 
+<%(alarm_uri)s> a ncal:Alarm; 
     ncal:action      ncal:emailAction; 
-    ncal:repeat      "${alarm_repeat}"; 
-    ncal:duration    "${alarm_duration}"; 
-    ncal:trigger [ a ncal:Trigger; ncal:triggerDateTime "${alarm_trigger_date}" ]; 
-    ncal:summary     "${alarm_subject}"; 
-    ncal:description "${alarm_description}" . 
+    ncal:repeat      "%(alarm_repeat)s"; 
+    ncal:duration    "%(alarm_duration)s"; 
+    ncal:trigger [ a ncal:Trigger; ncal:triggerDateTime "%(alarm_trigger_date)s" ]; 
+    ncal:summary     "%(alarm_subject)s"; 
+    ncal:description "%(alarm_description)s" . 
diff --git a/utils/data-generators/cc/template/ncal_Calendar.tmpl b/utils/data-generators/cc/template/ncal_Calendar.tmpl
index 3ba2d83..5e04d2b 100644
--- a/utils/data-generators/cc/template/ncal_Calendar.tmpl
+++ b/utils/data-generators/cc/template/ncal_Calendar.tmpl
@@ -1 +1 @@
-<${calendar_uri}> a ncal:Calendar .
+<%(calendar_uri)s> a ncal:Calendar .
diff --git a/utils/data-generators/cc/template/ncal_Event.tmpl b/utils/data-generators/cc/template/ncal_Event.tmpl
index a15c1b7..ea37768 100644
--- a/utils/data-generators/cc/template/ncal_Event.tmpl
+++ b/utils/data-generators/cc/template/ncal_Event.tmpl
@@ -1,20 +1,20 @@
-<${event_uri}> a ncal:Event, nie:DataObject;
-  ncal:uid      "${event_uid}";
+<%(event_uri)s> a ncal:Event, nie:DataObject;
+  ncal:uid      "%(event_uid)s";
   ncal:dtstart [ a ncal:NcalDateTime;
-    ncal:dateTime "${event_start}";
+    ncal:dateTime "%(event_start)s";
     ncal:ncalTimezone <urn:x-ical:timezone:Europe/Helsinki> ]; 
   ncal:dtend [ a ncal:NcalDateTime;
-    ncal:dateTime "${event_end}";
+    ncal:dateTime "%(event_end)s";
     ncal:ncalTimezone <urn:x-ical:timezone:Europe/Helsinki> ]; 
   ncal:transp        ncal:opaqueTransparency; 
-  ncal:summary       "${event_summary}"; 
+  ncal:summary       "%(event_summary)s"; 
   ncal:class         ncal:publicClassification; 
   ncal:eventStatus   ncal:; 
   ncal:priority      0; 
-  ncal:dtstamp       "${event_created}"; 
-  ncal:created       "${event_created}";
-  ncal:lastModified  "${event_modified}";
+  ncal:dtstamp       "%(event_created)s"; 
+  ncal:created       "%(event_created)s";
+  ncal:lastModified  "%(event_modified)s";
   ncal:sequence       0; 
-  ncal:url            <${event_uri}>;
-  ncal:hasAlarm       <${alarm_uri}> ; 
-  nie:isLogicalPartOf <${calendar_uri}> .
+  ncal:url            <%(event_uri)s>;
+  ncal:hasAlarm       <%(alarm_uri)s> ; 
+  nie:isLogicalPartOf <%(calendar_uri)s> .
diff --git a/utils/data-generators/cc/template/ncal_Todo.tmpl b/utils/data-generators/cc/template/ncal_Todo.tmpl
index 0294ce7..8d3b6f1 100644
--- a/utils/data-generators/cc/template/ncal_Todo.tmpl
+++ b/utils/data-generators/cc/template/ncal_Todo.tmpl
@@ -1,14 +1,14 @@
-<${todo_uri}> a ncal:Todo, nie:DataObject;
-  ncal:uid           "${todo_uid}";
+<%(todo_uri)s> a ncal:Todo, nie:DataObject;
+  ncal:uid           "%(todo_uid)s";
   ncal:percentComplete 0;
-  ncal:summary       "${todo_summary}";
+  ncal:summary       "%(todo_summary)s";
   ncal:class         ncal:publicClassification;
   ncal:todoStatus    ncal:;
   ncal:priority      0;
-  ncal:dtstamp       "${todo_created}";
-  ncal:created       "${todo_created}";
-  ncal:lastModified  "${todo_modified}";
+  ncal:dtstamp       "%(todo_created)s";
+  ncal:created       "%(todo_created)s";
+  ncal:lastModified  "%(todo_modified)s";
   ncal:sequence       0;
-  ncal:url            <${todo_uri}>;
-  ncal:hasAlarm       <${alarm_uri}> ;
-  nie:isLogicalPartOf <${calendar_uri}> .
+  ncal:url            <%(todo_uri)s>;
+  ncal:hasAlarm       <%(alarm_uri)s> ;
+  nie:isLogicalPartOf <%(calendar_uri)s> .
diff --git a/utils/data-generators/cc/template/nco_EmailAddress.tmpl b/utils/data-generators/cc/template/nco_EmailAddress.tmpl
index 2218ff0..52b5947 100644
--- a/utils/data-generators/cc/template/nco_EmailAddress.tmpl
+++ b/utils/data-generators/cc/template/nco_EmailAddress.tmpl
@@ -1,2 +1,2 @@
-<${email_address_uri}> a nco:EmailAddress;
-    nco:emailAddress "${email_address}".     
+<%(email_address_uri)s> a nco:EmailAddress;
+    nco:emailAddress "%(email_address)s".     
diff --git a/utils/data-generators/cc/template/nco_PersonContact.tmpl b/utils/data-generators/cc/template/nco_PersonContact.tmpl
index 6d04122..d29563b 100644
--- a/utils/data-generators/cc/template/nco_PersonContact.tmpl
+++ b/utils/data-generators/cc/template/nco_PersonContact.tmpl
@@ -1,8 +1,8 @@
-<${contact_uri}> a nco:PersonContact;
-    nco:fullname         "${contact_name_given} ${contact_name_family}";
-    nco:nameGiven        "${contact_name_given}";
-    nco:nameFamily       "${contact_name_family}";
-    nco:birthDate        "${contact_birth_date}";
-    nco:hasEmailAddress   ${email_address_uri};
-    nco:hasPhoneNumber    ${phonenumber_uri};
-    nco:hasPostalAddress  ${postal_address_uri} .
+<%(contact_uri)s> a nco:PersonContact;
+    nco:fullname         "%(contact_name_given)s %(contact_name_family)s";
+    nco:nameGiven        "%(contact_name_given)s";
+    nco:nameFamily       "%(contact_name_family)s";
+    nco:birthDate        "%(contact_birth_date)s";
+    nco:hasEmailAddress   %(email_address_uri)s;
+    nco:hasPhoneNumber    %(phonenumber_uri)s;
+    nco:hasPostalAddress  %(postal_address_uri)s .
diff --git a/utils/data-generators/cc/template/nco_PhoneNumber.tmpl b/utils/data-generators/cc/template/nco_PhoneNumber.tmpl
index 1989927..6ee20a3 100644
--- a/utils/data-generators/cc/template/nco_PhoneNumber.tmpl
+++ b/utils/data-generators/cc/template/nco_PhoneNumber.tmpl
@@ -1,2 +1,2 @@
-<${phonenumber_uri}> a nco:CellPhoneNumber;
-    nco:phoneNumber "${phonenumber}".
+<%(phonenumber_uri)s> a nco:CellPhoneNumber;
+    nco:phoneNumber "%(phonenumber)s".
diff --git a/utils/data-generators/cc/template/nco_PostalAddress.tmpl b/utils/data-generators/cc/template/nco_PostalAddress.tmpl
index 6f5cf76..e6e87f9 100644
--- a/utils/data-generators/cc/template/nco_PostalAddress.tmpl
+++ b/utils/data-generators/cc/template/nco_PostalAddress.tmpl
@@ -1,6 +1,6 @@
-<${postal_address_uri}> a nco:PostalAddress;
-    nco:country "${postal_address_country}" ;         
-    nco:region "${postal_address_region}" ;          
-    nco:postalcode "${postal_address_postal_code}" ;   
-    nco:locality "${postal_address_city}" ;  
-    nco:streetAddress "${postal_address_street}" .
+<%(postal_address_uri)s> a nco:PostalAddress;
+    nco:country "%(postal_address_country)s" ;         
+    nco:region "%(postal_address_region)s" ;          
+    nco:postalcode "%(postal_address_postal_code)s" ;   
+    nco:locality "%(postal_address_city)s" ;  
+    nco:streetAddress "%(postal_address_street)s" .
diff --git a/utils/data-generators/cc/template/nfo_PlainTextDocument.tmpl b/utils/data-generators/cc/template/nfo_PlainTextDocument.tmpl
index 47e2a1f..49e46c0 100644
--- a/utils/data-generators/cc/template/nfo_PlainTextDocument.tmpl
+++ b/utils/data-generators/cc/template/nfo_PlainTextDocument.tmpl
@@ -1,12 +1,12 @@
-<${plaintext_document_uri}> a nfo:PlainTextDocument, nfo:FileDataObject;
-    nie:byteSize           "${plaintext_document_size}" ;
-    nie:dataSource         <${plaintext_document_datasource}> ;
-    nie:url                "${plaintext_document_url}" ;
-    nfo:belongsToContainer <${plaintext_document_container}> ;
-    nie:mimeType           "${plaintext_document_mime}" ;
-    nie:plainTextContent   "${plaintext_document_content}" ;
-    nie:isStoredAs         <${plaintext_document_stored_as}> ;
-    nfo:fileLastAccessed   "${plaintext_document_last_accessed}" ;
-    nfo:fileLastModified   "${plaintext_document_last_modified}" ;
-    nfo:fileSize           "${plaintext_document_size}" ;
-    nfo:fileName           "${plaintext_document_filename}" .
+<%(plaintext_document_uri)s> a nfo:PlainTextDocument, nfo:FileDataObject;
+    nie:byteSize           "%(plaintext_document_size)s" ;
+    nie:dataSource         <%(plaintext_document_datasource)s> ;
+    nie:url                "%(plaintext_document_url)s" ;
+    nfo:belongsToContainer <%(plaintext_document_container)s> ;
+    nie:mimeType           "%(plaintext_document_mime)s" ;
+    nie:plainTextContent   "%(plaintext_document_content)s" ;
+    nie:isStoredAs         <%(plaintext_document_stored_as)s> ;
+    nfo:fileLastAccessed   "%(plaintext_document_last_accessed)s" ;
+    nfo:fileLastModified   "%(plaintext_document_last_modified)s" ;
+    nfo:fileSize           "%(plaintext_document_size)s" ;
+    nfo:fileName           "%(plaintext_document_filename)s" .
diff --git a/utils/data-generators/cc/template/nfo_SoftwareApplication.tmpl b/utils/data-generators/cc/template/nfo_SoftwareApplication.tmpl
index eeaaf8e..24142d4 100644
--- a/utils/data-generators/cc/template/nfo_SoftwareApplication.tmpl
+++ b/utils/data-generators/cc/template/nfo_SoftwareApplication.tmpl
@@ -1,10 +1,10 @@
-<${application_uri}> a nfo:SoftwareApplication, nfo:FileDataObject;
-    nie:title            "${application_title}";
-    nie:url              "${application_url}";
-    nie:dataSource       <${application_datasource}>;
-    nie:isStoredAs       <${application_url}>;
-    nie:isLogicalPartOf  <${application_part_of}>;
-    nfo:fileName         "${application_filename}";
-    nfo:fileLastModified "${application_last_modified}";
-    nfo:softwareIcon     <${application_icon}>;
-    nfo:softwareCmdLine  "${application_cmdline}" .
+<%(application_uri)s> a nfo:SoftwareApplication, nfo:FileDataObject;
+    nie:title            "%(application_title)s";
+    nie:url              "%(application_url)s";
+    nie:dataSource       <%(application_datasource)s>;
+    nie:isStoredAs       <%(application_url)s>;
+    nie:isLogicalPartOf  <%(application_part_of)s>;
+    nfo:fileName         "%(application_filename)s";
+    nfo:fileLastModified "%(application_last_modified)s";
+    nfo:softwareIcon     <%(application_icon)s>;
+    nfo:softwareCmdLine  "%(application_cmdline)s" .
diff --git a/utils/data-generators/cc/template/nfo_SoftwareCategory.tmpl b/utils/data-generators/cc/template/nfo_SoftwareCategory.tmpl
index acb21ba..f276cff 100644
--- a/utils/data-generators/cc/template/nfo_SoftwareCategory.tmpl
+++ b/utils/data-generators/cc/template/nfo_SoftwareCategory.tmpl
@@ -1,3 +1,3 @@
-<${application_category_uri}> a nfo:SoftwareCategory;
-  nie:title "${application_category_title}" .
+<%(application_category_uri)s> a nfo:SoftwareCategory;
+  nie:title "%(application_category_title)s" .
   
\ No newline at end of file
diff --git a/utils/data-generators/cc/template/nfo_WebHistory.tmpl b/utils/data-generators/cc/template/nfo_WebHistory.tmpl
index cfd5d0b..0a1b5c9 100644
--- a/utils/data-generators/cc/template/nfo_WebHistory.tmpl
+++ b/utils/data-generators/cc/template/nfo_WebHistory.tmpl
@@ -1,7 +1,7 @@
-<${webhistory_uri}> a nfo:WebHistory ;
-  nie:title                   "${webhistory_title}" ;
-  nie:informationElementDate  "${webhistory_date}" ;
-  nie:contentCreated          "${webhistory_created}" ;
-  nie:contentLastModified     "${webhistory_modified}" ;
-  nie:usageCounter            "${webhistory_counter}" ;
-  nfo:uri                     "${webhistory_url}" .
+<%(webhistory_uri)s> a nfo:WebHistory ;
+  nie:title                   "%(webhistory_title)s" ;
+  nie:informationElementDate  "%(webhistory_date)s" ;
+  nie:contentCreated          "%(webhistory_created)s" ;
+  nie:contentLastModified     "%(webhistory_modified)s" ;
+  nie:usageCounter            "%(webhistory_counter)s" ;
+  nfo:uri                     "%(webhistory_url)s" .
diff --git a/utils/data-generators/cc/template/nmm_Artist.tmpl b/utils/data-generators/cc/template/nmm_Artist.tmpl
index ca4fb88..ac9e94a 100644
--- a/utils/data-generators/cc/template/nmm_Artist.tmpl
+++ b/utils/data-generators/cc/template/nmm_Artist.tmpl
@@ -1,2 +1,2 @@
-<${artist_uri}> a nmm:Artist ;
-    nmm:artistName "${artist_name}" .
+<%(artist_uri)s> a nmm:Artist ;
+    nmm:artistName "%(artist_name)s" .
diff --git a/utils/data-generators/cc/template/nmm_MusicAlbum.tmpl b/utils/data-generators/cc/template/nmm_MusicAlbum.tmpl
index b139876..826929e 100644
--- a/utils/data-generators/cc/template/nmm_MusicAlbum.tmpl
+++ b/utils/data-generators/cc/template/nmm_MusicAlbum.tmpl
@@ -1,3 +1,3 @@
-<${album_uri}> a nmm:MusicAlbum ;
-    nie:title        "${album_name}" ;
-    nmm:albumTitle   "${album_name}" .
+<%(album_uri)s> a nmm:MusicAlbum ;
+    nie:title        "%(album_name)s" ;
+    nmm:albumTitle   "%(album_name)s" .
diff --git a/utils/data-generators/cc/template/nmm_MusicPiece.tmpl b/utils/data-generators/cc/template/nmm_MusicPiece.tmpl
index aadf7cf..bacde95 100644
--- a/utils/data-generators/cc/template/nmm_MusicPiece.tmpl
+++ b/utils/data-generators/cc/template/nmm_MusicPiece.tmpl
@@ -1,22 +1,22 @@
-<${music_piece_uri}> a nmm:MusicPiece, nfo:FileDataObject, nfo:Audio;
-    nie:byteSize               "${music_piece_size}" ;
-    nie:url                    "${music_piece_url}" ;
-    nfo:belongsToContainer     <${music_piece_container}> ;
-    nie:title                  "${music_piece_title}" ;
-    nie:mimeType               "${music_piece_mime}" ;
-    nie:informationElementDate "${music_piece_date}" ;
-    nie:isLogicalPartOf        <${music_piece_album}> ;
-    nco:contributor            <${music_piece_artist}> ;
-    nfo:fileLastAccessed       "${music_piece_last_accessed}" ;
-    nfo:fileSize               "${music_piece_size}" ;
-    nfo:fileName               "${music_piece_filename}" ;
-    nfo:fileLastModified       "${music_piece_last_modified}" ;
-    nfo:codec                  "${music_piece_codec}" ;
-    nfo:averageBitrate         "${music_piece_bitrate}" ;
-    nfo:genre                  "${music_piece_genre}" ;
-    nfo:channels               "${music_piece_channels}" ;
-    nfo:sampleRate             "${music_piece_sample_rate}" ;
-    nmm:musicAlbum             <${music_piece_album}> ;
-    nmm:performer              <${music_piece_artist}> ;
-    nmm:length                 "${music_piece_length}" ;
-    nmm:trackNumber            "${music_piece_track}" .
+<%(music_piece_uri)s> a nmm:MusicPiece, nfo:FileDataObject, nfo:Audio;
+    nie:byteSize               "%(music_piece_size)s" ;
+    nie:url                    "%(music_piece_url)s" ;
+    nfo:belongsToContainer     <%(music_piece_container)s> ;
+    nie:title                  "%(music_piece_title)s" ;
+    nie:mimeType               "%(music_piece_mime)s" ;
+    nie:informationElementDate "%(music_piece_date)s" ;
+    nie:isLogicalPartOf        <%(music_piece_album)s> ;
+    nco:contributor            <%(music_piece_artist)s> ;
+    nfo:fileLastAccessed       "%(music_piece_last_accessed)s" ;
+    nfo:fileSize               "%(music_piece_size)s" ;
+    nfo:fileName               "%(music_piece_filename)s" ;
+    nfo:fileLastModified       "%(music_piece_last_modified)s" ;
+    nfo:codec                  "%(music_piece_codec)s" ;
+    nfo:averageBitrate         "%(music_piece_bitrate)s" ;
+    nfo:genre                  "%(music_piece_genre)s" ;
+    nfo:channels               "%(music_piece_channels)s" ;
+    nfo:sampleRate             "%(music_piece_sample_rate)s" ;
+    nmm:musicAlbum             <%(music_piece_album)s> ;
+    nmm:performer              <%(music_piece_artist)s> ;
+    nmm:length                 "%(music_piece_length)s" ;
+    nmm:trackNumber            "%(music_piece_track)s" .
diff --git a/utils/data-generators/cc/template/nmm_Photo.tmpl b/utils/data-generators/cc/template/nmm_Photo.tmpl
index d2cadf6..6188db6 100644
--- a/utils/data-generators/cc/template/nmm_Photo.tmpl
+++ b/utils/data-generators/cc/template/nmm_Photo.tmpl
@@ -1,18 +1,18 @@
-<${photo_uri}> a nie:DataObject, nfo:FileDataObject, nfo:Media, nfo:Visual, nfo:Image, nmm:Photo ;
-    nie:url              "${photo_url}";
-    nie:byteSize         "${photo_size}";
-    nie:contentCreated   "${photo_date}";
+<%(photo_uri)s> a nie:DataObject, nfo:FileDataObject, nfo:Media, nfo:Visual, nfo:Image, nmm:Photo ;
+    nie:url              "%(photo_url)s";
+    nie:byteSize         "%(photo_size)s";
+    nie:contentCreated   "%(photo_date)s";
     nie:mimeType         "image/jpeg";
     nfo:width            "100";
     nfo:height           "100";
-    nfo:fileLastModified "${photo_date}";
-    nfo:fileLastAccessed "${photo_date}";
-    nfo:fileSize         "${photo_size}";
-    nfo:fileName         "${photo_filename}" ;
-    nmm:camera           "${photo_camera}";
-    nmm:exposureTime     "${photo_exposure}";
-    nmm:fnumber          "${photo_fnumber}";
-    nmm:focalLength      "${photo_focal_length}";
+    nfo:fileLastModified "%(photo_date)s";
+    nfo:fileLastAccessed "%(photo_date)s";
+    nfo:fileSize         "%(photo_size)s";
+    nfo:fileName         "%(photo_filename)s" ;
+    nmm:camera           "%(photo_camera)s";
+    nmm:exposureTime     "%(photo_exposure)s";
+    nmm:fnumber          "%(photo_fnumber)s";
+    nmm:focalLength      "%(photo_focal_length)s";
     nmm:flash            <http://www.tracker-project.org/temp/nmm#flash-off> ;
     nmm:meteringMode     <http://www.tracker-project.org/temp/nmm#meteringMode-pattern> ;
     nmm:whiteBalance     <http://www.tracker-project.org/temp/nmm#whiteBalance-auto> .
diff --git a/utils/data-generators/cc/template/nmm_Video.tmpl b/utils/data-generators/cc/template/nmm_Video.tmpl
index c327109..50c7f14 100644
--- a/utils/data-generators/cc/template/nmm_Video.tmpl
+++ b/utils/data-generators/cc/template/nmm_Video.tmpl
@@ -1,14 +1,14 @@
-<${video_uri}> a nie:DataObject, nfo:FileDataObject, nfo:Media, nfo:Visual, nfo:Video, nmm:Video ;
-    nie:url              "${video_url}";
-    nie:byteSize         "${video_size}";
-    nie:contentCreated   "${video_date}";
+<%(video_uri)s> a nie:DataObject, nfo:FileDataObject, nfo:Media, nfo:Visual, nfo:Video, nmm:Video ;
+    nie:url              "%(video_url)s";
+    nie:byteSize         "%(video_size)s";
+    nie:contentCreated   "%(video_date)s";
     nie:mimeType         "video/x-msvideo";
     nfo:width            "100";
     nfo:height           "100";
-    nfo:fileLastModified "${video_date}";
-    nfo:fileLastAccessed "${video_date}";
-    nfo:fileSize         "${video_size}";
-    nfo:fileName         "${video_filename}" ;
-    nfo:sampleRate       "${video_samplerate}" ;
-    nfo:duration         "${video_duration}" ;
-    nao:hasTag           [a nao:Tag ; nao:prefLabel "${video_tag}"] .
+    nfo:fileLastModified "%(video_date)s";
+    nfo:fileLastAccessed "%(video_date)s";
+    nfo:fileSize         "%(video_size)s";
+    nfo:fileName         "%(video_filename)s" ;
+    nfo:sampleRate       "%(video_samplerate)s" ;
+    nfo:duration         "%(video_duration)s" ;
+    nao:hasTag           [a nao:Tag ; nao:prefLabel "%(video_tag)s"] .
diff --git a/utils/data-generators/cc/template/nmo_Call.tmpl b/utils/data-generators/cc/template/nmo_Call.tmpl
index 38697a0..2949c90 100644
--- a/utils/data-generators/cc/template/nmo_Call.tmpl
+++ b/utils/data-generators/cc/template/nmo_Call.tmpl
@@ -1,11 +1,11 @@
-<${call_uri}> a nmo:Call;
-  nie:subject                "${call_subject}";
-  nie:informationElementDate "${call_date}";
-  nie:contentLastModified    "${call_modified}";
-  nmo:from                   <${call_from}>  ;
-  nmo:to                     <${call_to}>  ;
-  nmo:isRead                 "${call_read}" ;
-  nmo:isSent                 "${call_sent}" ;
-  nmo:receivedDate           "${call_received}" ;
-  nmo:sentDate               "${call_sent_date}" ;
-  nmo:duration               "${call_duration}" .
+<%(call_uri)s> a nmo:Call;
+  nie:subject                "%(call_subject)s";
+  nie:informationElementDate "%(call_date)s";
+  nie:contentLastModified    "%(call_modified)s";
+  nmo:from                   <%(call_from)s>  ;
+  nmo:to                     <%(call_to)s>  ;
+  nmo:isRead                 "%(call_read)s" ;
+  nmo:isSent                 "%(call_sent)s" ;
+  nmo:receivedDate           "%(call_received)s" ;
+  nmo:sentDate               "%(call_sent_date)s" ;
+  nmo:duration               "%(call_duration)s" .
diff --git a/utils/data-generators/cc/template/nmo_CommunicationChannel.tmpl b/utils/data-generators/cc/template/nmo_CommunicationChannel.tmpl
index 21a4273..c810285 100644
--- a/utils/data-generators/cc/template/nmo_CommunicationChannel.tmpl
+++ b/utils/data-generators/cc/template/nmo_CommunicationChannel.tmpl
@@ -1,6 +1,6 @@
-<${channel_uri}> a nmo:CommunicationChannel;
-  nie:subject                "${channel_subject}";
-  nie:informationElementDate "${channel_date}";
-  nie:contentLastModified    "${channel_modified}";
-  nmo:lastMessageDate        "${channel_last_message}";
-  nmo:hasParticipant         <${channel_participiant}> .
+<%(channel_uri)s> a nmo:CommunicationChannel;
+  nie:subject                "%(channel_subject)s";
+  nie:informationElementDate "%(channel_date)s";
+  nie:contentLastModified    "%(channel_modified)s";
+  nmo:lastMessageDate        "%(channel_last_message)s";
+  nmo:hasParticipant         <%(channel_participiant)s> .
diff --git a/utils/data-generators/cc/template/nmo_Email.tmpl b/utils/data-generators/cc/template/nmo_Email.tmpl
index 4e24833..3900f84 100644
--- a/utils/data-generators/cc/template/nmo_Email.tmpl
+++ b/utils/data-generators/cc/template/nmo_Email.tmpl
@@ -1,14 +1,14 @@
-<${email_uri}> a nmo:Email ;
-    nie:mimeType         "${email_mime}" ;
-    nie:relatedTo        <${email_account}> ;
-    nie:isStoredAs       <${email_stored_as}> ;
-    nie:isLogicalPartOf  <${email_folder}> ;
-    nie:contentSize      "${email_size}" ;
-    nie:plainTextContent "${email_content}" ;
-    nmo:recipient        <${email_recipient}> ;
-    nmo:messageId        "${email_id}" ;
-    nmo:messageSubject   "${email_subject}" ;
-    nmo:receivedDate     "${email_received}" ;
-    nmo:sender           <${email_sender}> ;
-    nmo:from             <${email_sender}> ;
-    nmo:sentDate         "${email_sent}" .
+<%(email_uri)s> a nmo:Email ;
+    nie:mimeType         "%(email_mime)s" ;
+    nie:relatedTo        <%(email_account)s> ;
+    nie:isStoredAs       <%(email_stored_as)s> ;
+    nie:isLogicalPartOf  <%(email_folder)s> ;
+    nie:contentSize      "%(email_size)s" ;
+    nie:plainTextContent "%(email_content)s" ;
+    nmo:recipient        <%(email_recipient)s> ;
+    nmo:messageId        "%(email_id)s" ;
+    nmo:messageSubject   "%(email_subject)s" ;
+    nmo:receivedDate     "%(email_received)s" ;
+    nmo:sender           <%(email_sender)s> ;
+    nmo:from             <%(email_sender)s> ;
+    nmo:sentDate         "%(email_sent)s" .
diff --git a/utils/data-generators/cc/template/nmo_IMMessage.tmpl b/utils/data-generators/cc/template/nmo_IMMessage.tmpl
index 847fa03..6954626 100644
--- a/utils/data-generators/cc/template/nmo_IMMessage.tmpl
+++ b/utils/data-generators/cc/template/nmo_IMMessage.tmpl
@@ -1,14 +1,14 @@
-<${immessage_uri}> a nmo:IMMessage;
-  nie:plainTextContent       "${immessage_content}" ;
-  nie:informationElementDate "${immessage_date}" ;
-  nie:contentLastModified    "${immessage_modified}" ;
-  nie:plainTextContent       "${immessage_content}" ;
-  nmo:from                   <${immessage_from}> ;
-  nmo:to                     <${immessage_to}> ;
-  nmo:isDraft                "${immessage_draft}" ;
-  nmo:isRead                 "${immessage_read}" ;
-  nmo:isSent                 "${immessage_sent}" ;
-  nmo:messageId              "${immessage_message_id}" ;
-  nmo:receivedDate           "${immessage_received}" ;
-  nmo:sentDate               "${immessage_sent_date}" ;
-  nmo:communicationChannel   <${immessage_channel_uri}> .
+<%(immessage_uri)s> a nmo:IMMessage;
+  nie:plainTextContent       "%(immessage_content)s" ;
+  nie:informationElementDate "%(immessage_date)s" ;
+  nie:contentLastModified    "%(immessage_modified)s" ;
+  nie:plainTextContent       "%(immessage_content)s" ;
+  nmo:from                   <%(immessage_from)s> ;
+  nmo:to                     <%(immessage_to)s> ;
+  nmo:isDraft                "%(immessage_draft)s" ;
+  nmo:isRead                 "%(immessage_read)s" ;
+  nmo:isSent                 "%(immessage_sent)s" ;
+  nmo:messageId              "%(immessage_message_id)s" ;
+  nmo:receivedDate           "%(immessage_received)s" ;
+  nmo:sentDate               "%(immessage_sent_date)s" ;
+  nmo:communicationChannel   <%(immessage_channel_uri)s> .
diff --git a/utils/data-generators/cc/template/nmo_MailAccount.tmpl b/utils/data-generators/cc/template/nmo_MailAccount.tmpl
index 77abc90..a13b8be 100644
--- a/utils/data-generators/cc/template/nmo_MailAccount.tmpl
+++ b/utils/data-generators/cc/template/nmo_MailAccount.tmpl
@@ -1,4 +1,4 @@
-<${account_uri}> a nmo:MailAccount ;
-    nmo:accountName "${account_name}" ;
-    nmo:fromAddress ${account_from_address_uri} ;
-    nmo:signature   "${account_signature}" .
+<%(account_uri)s> a nmo:MailAccount ;
+    nmo:accountName "%(account_name)s" ;
+    nmo:fromAddress %(account_from_address_uri)s ;
+    nmo:signature   "%(account_signature)s" .
diff --git a/utils/data-generators/cc/template/nmo_MailFolder.tmpl b/utils/data-generators/cc/template/nmo_MailFolder.tmpl
index 17a6da7..efcec31 100644
--- a/utils/data-generators/cc/template/nmo_MailFolder.tmpl
+++ b/utils/data-generators/cc/template/nmo_MailFolder.tmpl
@@ -1,3 +1,3 @@
-<${mailfolder_uri}> a nmo:MailFolder ;
-    nie:relatedTo  ${mailfolder_account} ;
-    nmo:folderName "${mailfolder_name}" .
+<%(mailfolder_uri)s> a nmo:MailFolder ;
+    nie:relatedTo  %(mailfolder_account)s ;
+    nmo:folderName "%(mailfolder_name)s" .
diff --git a/utils/data-generators/cc/template/nmo_SMSMessage.tmpl b/utils/data-generators/cc/template/nmo_SMSMessage.tmpl
index be79833..088b698 100644
--- a/utils/data-generators/cc/template/nmo_SMSMessage.tmpl
+++ b/utils/data-generators/cc/template/nmo_SMSMessage.tmpl
@@ -1,15 +1,15 @@
-<${smsmessage_uri}> a nmo:SMSMessage;
-  nmo:smsId                  "${smsmessage_id}" ;
-  nie:plainTextContent       "${smsmessage_content}";
-  nie:informationElementDate "${smsmessage_date}";
-  nie:contentLastModified    "${smsmessage_modified}";
-  nie:plainTextContent       "${smsmessage_content}" ;
-  nmo:from                   <${smsmessage_from}>  ;
-  nmo:to                     <${smsmessage_to}>  ;
-  nmo:isDraft                "${smsmessage_draft}" ;
-  nmo:isRead                 "${smsmessage_read}" ;
-  nmo:isSent                 "${smsmessage_sent}" ;
-  nmo:messageId              "${smsmessage_message_id}" ;
-  nmo:receivedDate           "${smsmessage_received}" ;
-  nmo:sentDate               "${smsmessage_sent_date}" ;
-  nmo:communicationChannel   <${smsmessage_channel_uri}> .
+<%(smsmessage_uri)s> a nmo:SMSMessage;
+  nmo:smsId                  "%(smsmessage_id)s" ;
+  nie:plainTextContent       "%(smsmessage_content)s";
+  nie:informationElementDate "%(smsmessage_date)s";
+  nie:contentLastModified    "%(smsmessage_modified)s";
+  nie:plainTextContent       "%(smsmessage_content)s" ;
+  nmo:from                   <%(smsmessage_from)s>  ;
+  nmo:to                     <%(smsmessage_to)s>  ;
+  nmo:isDraft                "%(smsmessage_draft)s" ;
+  nmo:isRead                 "%(smsmessage_read)s" ;
+  nmo:isSent                 "%(smsmessage_sent)s" ;
+  nmo:messageId              "%(smsmessage_message_id)s" ;
+  nmo:receivedDate           "%(smsmessage_received)s" ;
+  nmo:sentDate               "%(smsmessage_sent_date)s" ;
+  nmo:communicationChannel   <%(smsmessage_channel_uri)s> .
diff --git a/utils/data-generators/cc/template/tracker_Volume.tmpl b/utils/data-generators/cc/template/tracker_Volume.tmpl
index c8c52bf..4ae8bee 100644
--- a/utils/data-generators/cc/template/tracker_Volume.tmpl
+++ b/utils/data-generators/cc/template/tracker_Volume.tmpl
@@ -1 +1 @@
-<${datasource_uri}> a tracker:Volume .
+<%(datasource_uri)s> a tracker:Volume .
diff --git a/utils/data-generators/cc/tools.py b/utils/data-generators/cc/tools.py
index c086a60..8ae0623 100644
--- a/utils/data-generators/cc/tools.py
+++ b/utils/data-generators/cc/tools.py
@@ -11,6 +11,7 @@ output_filenames = {}
 templates = {}
 last_uris = {}
 result = {}
+now = datetime.datetime.today().strftime('%Y-%m-%dT%H:%M:%SZ')
 
 ####################################################################################
 def addType(name, order):
@@ -20,11 +21,11 @@ def addType(name, order):
   template_filenames[name] = template
   output_filenames[name] = output
   templates[name] = ''
-  result[name] = ''
+  result[name] = []
   last_uris[name] = []
 
 def addResult(type, data):
-  result[type] += data + '\n'
+  result[type].append(data)
 
 def addUri(type, uri):
   last_uris[type].append( uri )
@@ -33,11 +34,12 @@ def getLastUri(type):
   return last_uris[type][-1]
 
 def getRandomUri(type):
-  return last_uris[type][ int(random.random() * len(last_uris[type]) ) ]
+  return random.choice(last_uris[type])
+  #return last_uris[type][ int(random.random() * len(last_uris[type]) ) ]
 
 def loadTemplates ():
   for ontology, filename in template_filenames.items():
-    content = string.join( open(filename).readlines() )
+    content = ''.join( open(filename).readlines() )
     templates[ontology] = content
 
   return len(templates)
@@ -50,9 +52,9 @@ def saveResult ():
     print 'Saving', output_filenames[ontology], '...'
     output = open( output_filenames[ontology], 'w')
     output.write( ontology_prefixes.ontology_prefixes )
-    output.write( content )
+    for it in content:
+      output.write( it )
     output.close()
 
 def getDateNowString():
-  return datetime.datetime.today().strftime('%Y-%m-%dT%H:%M:%SZ')
-
+  return now
diff --git a/utils/data-generators/cc/tracker.py b/utils/data-generators/cc/tracker.py
index 985b557..eab3854 100644
--- a/utils/data-generators/cc/tracker.py
+++ b/utils/data-generators/cc/tracker.py
@@ -4,15 +4,12 @@ import tools
 
 ####################################################################################
 def generateVolume(index):
+  me = 'tracker#Volume'
   datasource_uri  = 'urn:nepomuk:datasource:%d' % index
 
   # save the last uri
-  tools.addUri( 'tracker#Volume', datasource_uri )
+  tools.addUri( me, datasource_uri )
 
   # subsitute into template
   volume = tools.getTemplate( 'tracker#Volume' )
-  volume = volume.replace( '${datasource_uri}', datasource_uri )
-
-  # save the result
-  tools.addResult( 'tracker#Volume', volume )
- 
\ No newline at end of file
+  tools.addResult(me, volume % locals())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]