[tracker/rss-enclosures] increasing coherency by putting the template near the functions that fill them
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] increasing coherency by putting the template near the functions that fill them
- Date: Mon, 3 May 2010 00:44:45 +0000 (UTC)
commit 3b70a89d2c487d05975e782b9d2cc589dfcec6db
Author: Akos PASZTORY <ext-akos pasztory nokia com>
Date: Mon Apr 26 10:08:34 2010 +0300
increasing coherency by putting the template near the functions that fill them
utils/data-generators/cc/generate | 4 -
utils/data-generators/cc/mfo.py | 36 +++--
utils/data-generators/cc/mto.py | 39 +++--
utils/data-generators/cc/ncal.py | 90 +++++++----
utils/data-generators/cc/nco.py | 63 ++++----
utils/data-generators/cc/nfo.py | 78 +++++----
utils/data-generators/cc/nmm.py | 115 +++++++++-----
utils/data-generators/cc/nmo.py | 171 ++++++++++++--------
.../cc/template/mfo_FeedChannel.tmpl | 7 -
.../cc/template/mfo_FeedMessage.tmpl | 7 -
.../cc/template/mto_TransferElement.tmpl | 6 -
.../cc/template/mto_UploadTransfer.tmpl | 6 -
utils/data-generators/cc/template/ncal_Alarm.tmpl | 7 -
.../data-generators/cc/template/ncal_Calendar.tmpl | 1 -
utils/data-generators/cc/template/ncal_Event.tmpl | 20 ---
utils/data-generators/cc/template/ncal_Todo.tmpl | 14 --
.../cc/template/nco_EmailAddress.tmpl | 2 -
.../cc/template/nco_PersonContact.tmpl | 8 -
.../cc/template/nco_PhoneNumber.tmpl | 2 -
.../cc/template/nco_PostalAddress.tmpl | 6 -
.../cc/template/nfo_PlainTextDocument.tmpl | 12 --
.../cc/template/nfo_SoftwareApplication.tmpl | 10 --
.../cc/template/nfo_SoftwareCategory.tmpl | 3 -
.../cc/template/nfo_WebHistory.tmpl | 7 -
utils/data-generators/cc/template/nmm_Artist.tmpl | 2 -
.../cc/template/nmm_MusicAlbum.tmpl | 3 -
.../cc/template/nmm_MusicPiece.tmpl | 22 ---
utils/data-generators/cc/template/nmm_Photo.tmpl | 18 --
utils/data-generators/cc/template/nmm_Video.tmpl | 14 --
utils/data-generators/cc/template/nmo_Call.tmpl | 11 --
.../cc/template/nmo_CommunicationChannel.tmpl | 6 -
utils/data-generators/cc/template/nmo_Email.tmpl | 14 --
.../data-generators/cc/template/nmo_IMMessage.tmpl | 14 --
.../cc/template/nmo_MailAccount.tmpl | 4 -
.../cc/template/nmo_MailFolder.tmpl | 3 -
.../cc/template/nmo_SMSMessage.tmpl | 15 --
.../cc/template/tracker_Volume.tmpl | 1 -
utils/data-generators/cc/tools.py | 27 +---
utils/data-generators/cc/tracker.py | 10 +-
39 files changed, 353 insertions(+), 525 deletions(-)
---
diff --git a/utils/data-generators/cc/generate b/utils/data-generators/cc/generate
index 8b02617..de87599 100755
--- a/utils/data-generators/cc/generate
+++ b/utils/data-generators/cc/generate
@@ -64,10 +64,6 @@ tools.addType( 'mfo#FeedMessage', 81 )
tools.addType( 'mto#TransferElement', 90 )
tools.addType( 'mto#UploadTransfer', 91 )
-# first load all templates
-templates_count = tools.loadTemplates()
-print "Loaded", templates_count, "templates"
-
print "Generating Contacts",
count_contacts = config.getint('counts','contacts')
for contact in xrange(1, count_contacts+1):
diff --git a/utils/data-generators/cc/mfo.py b/utils/data-generators/cc/mfo.py
index d4a9636..a26ed76 100644
--- a/utils/data-generators/cc/mfo.py
+++ b/utils/data-generators/cc/mfo.py
@@ -3,22 +3,33 @@
import tools
####################################################################################
+mfo_FeedChannel = '''
+<%(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> .
+'''
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( me, feed_channel_uri )
-
- # subsitute into template
- channel = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, channel % locals())
+ tools.addItem( me, feed_channel_uri, mfo_FeedChannel % locals() );
####################################################################################
+mfo_FeedMessage = '''
+<%(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> .
+'''
def generateFeedMessage(index):
me = 'mfo#FeedMessage'
feed_message_uri = 'http://feed%d.feed.com/message%d.html' % (index % 1000, index)
@@ -27,11 +38,4 @@ def generateFeedMessage(index):
feed_message_comment = 'Comment %d' % index
feed_message_channel = tools.getLastUri( 'mfo#FeedChannel' )
- # save the last uri
- tools.addUri( me, feed_message_uri )
-
- # subsitute into template
- message = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, message % locals() )
+ tools.addItem( me, feed_message_uri, mfo_FeedMessage % locals() )
diff --git a/utils/data-generators/cc/mto.py b/utils/data-generators/cc/mto.py
index 5e97ebc..c6a8a67 100644
--- a/utils/data-generators/cc/mto.py
+++ b/utils/data-generators/cc/mto.py
@@ -3,31 +3,40 @@
import tools
####################################################################################
+mto_TransferElement = '''
+<%(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> .
+'''
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_destination = 'http://www.uploadsite%d.com/item%d' % (index % 100, index )
- transfer_started = tools.getDateNowString()
- transfer_completed = tools.getDateNowString()
+ transfer_started = tools.now
+ transfer_completed = tools.now
transfer_state = 'http://www.tracker-project.org/temp/mto#state-done'
- # save the last uri
- tools.addUri( me, transfer_uri )
-
- # subsitute into template
- data = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, data % locals() )
+ tools.addItem( me, transfer_uri, mto_TransferElement % locals() )
####################################################################################
+mto_UploadTransfer = '''
+<%(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" .
+'''
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'
- upload_created = tools.getDateNowString()
+ upload_created = tools.now
upload_account = ('picasa', 'flickr', 'facebook', 'youtube')[ index % 4 ]
# add some random transfers
@@ -35,10 +44,4 @@ def generateUploadTransfer(index):
for index in xrange (1, 2 + (index % 10)):
upload_transfers += 'mto:transferList <%s> ;\n' % tools.getRandomUri( 'mto#TransferElement' )
- # save the last uri
- tools.addUri( me, upload_uri )
-
- # subsitute into template
- data = tools.getTemplate( me )
- # save the result
- tools.addResult( me, data % locals() )
+ tools.addItem( me, upload_uri, mto_UploadTransfer % locals() )
diff --git a/utils/data-generators/cc/ncal.py b/utils/data-generators/cc/ncal.py
index d3e50e8..05cba08 100644
--- a/utils/data-generators/cc/ncal.py
+++ b/utils/data-generators/cc/ncal.py
@@ -3,6 +3,15 @@
import tools
####################################################################################
+ncal_Alarm = '''
+<%(alarm_uri)s> a ncal:Alarm;
+ ncal:action ncal:emailAction;
+ 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" .
+'''
def generateAlarm(index):
me = 'ncal#Alarm'
alarm_uri = 'urn:x-ical:alarm%d' % index
@@ -12,31 +21,42 @@ def generateAlarm(index):
alarm_subject = 'Subject %d' % index
alarm_description = 'Description %d' % index
- # save the last uri
- tools.addUri( me, alarm_uri )
-
- # subsitute into template
- alarm = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, alarm % locals() )
+ tools.addItem( me, alarm_uri, ncal_Alarm % locals() )
####################################################################################
+ncal_Calendar = '''
+<%(calendar_uri)s> a ncal:Calendar .
+'''
def generateCalendar(index):
me = 'ncal#Calendar'
calendar_uri = 'urn:x-ical:calendar%d' % index
# save the last uri
- tools.addUri( me, calendar_uri )
-
- # subsitute into template
- calendar = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, calendar % locals() )
-
+ tools.addItem( me, calendar_uri, ncal_Calendar % locals() )
####################################################################################
+ncal_Event = '''
+<%(event_uri)s> a ncal:Event, nie:DataObject;
+ ncal:uid "%(event_uid)s";
+ ncal:dtstart [ a ncal:NcalDateTime;
+ ncal:dateTime "%(event_start)s";
+ ncal:ncalTimezone <urn:x-ical:timezone:Europe/Helsinki> ];
+ ncal:dtend [ a ncal:NcalDateTime;
+ ncal:dateTime "%(event_end)s";
+ ncal:ncalTimezone <urn:x-ical:timezone:Europe/Helsinki> ];
+ ncal:transp ncal:opaqueTransparency;
+ ncal:summary "%(event_summary)s";
+ ncal:class ncal:publicClassification;
+ ncal:eventStatus ncal:;
+ ncal:priority 0;
+ ncal:dtstamp "%(event_created)s";
+ ncal:created "%(event_created)s";
+ ncal:lastModified "%(event_modified)s";
+ ncal:sequence 0;
+ ncal:url <%(event_uri)s>;
+ ncal:hasAlarm <%(alarm_uri)s> ;
+ nie:isLogicalPartOf <%(calendar_uri)s> .
+'''
def generateEvent(index):
me = 'ncal#Event'
event_uri = 'urn:x-ical:%d' % index
@@ -44,36 +64,38 @@ def generateEvent(index):
event_start = '%d-%02d-%02dT09:00:00Z' % (2010 + (index % 5), (index % 12) + 1, (index % 25) + 1)
event_end = '%d-%02d-%02dT17:00:00Z' % (2010 + (index % 5), (index % 12) + 1, (index % 25) + 1)
event_summary = 'Event %d' % index
- event_created = tools.getDateNowString()
+ event_created = tools.now
event_modified = event_created
alarm_uri = tools.getLastUri( 'ncal#Alarm' )
calendar_uri = tools.getRandomUri( 'ncal#Calendar' )
- # save the last uri
- tools.addUri( me, event_uri )
-
- # subsitute into template
- event = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, event % locals() )
+ tools.addItem( me, event_uri, ncal_Event % locals() )
####################################################################################
+ncal_Todo = '''
+<%(todo_uri)s> a ncal:Todo, nie:DataObject;
+ ncal:uid "%(todo_uid)s";
+ ncal:percentComplete 0;
+ ncal:summary "%(todo_summary)s";
+ ncal:class ncal:publicClassification;
+ ncal:todoStatus ncal:;
+ ncal:priority 0;
+ ncal:dtstamp "%(todo_created)s";
+ ncal:created "%(todo_created)s";
+ ncal:lastModified "%(todo_modified)s";
+ ncal:sequence 0;
+ ncal:url <%(todo_uri)s>;
+ ncal:hasAlarm <%(alarm_uri)s> ;
+ nie:isLogicalPartOf <%(calendar_uri)s> .
+'''
def generateTodo(index):
me = 'ncal#Todo'
todo_uri = 'urn:todo::%d' % index
todo_uid = '%d' % index
todo_summary = 'Todo %d' % index
- todo_created = tools.getDateNowString()
+ todo_created = tools.now
todo_modified = todo_created
alarm_uri = tools.getRandomUri( 'ncal#Alarm' )
calendar_uri = tools.getRandomUri( 'ncal#Calendar' )
- # save the last uri
- tools.addUri( me, todo_uri )
-
- # subsitute into template
- todo = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, todo % locals() )
+ tools.addItem( me, todo_uri, ncal_Todo % locals() )
diff --git a/utils/data-generators/cc/nco.py b/utils/data-generators/cc/nco.py
index f67b5b9..6e2cd29 100644
--- a/utils/data-generators/cc/nco.py
+++ b/utils/data-generators/cc/nco.py
@@ -3,37 +3,38 @@
import tools
####################################################################################
+nco_EmailAddress = '''
+<%(email_address_uri)s> a nco:EmailAddress;
+ nco:emailAddress "%(email_address)s".
+'''
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( me, email_address_uri )
-
- # substitute into template
- email = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, email % locals() )
+ tools.addItem( me, email_address_uri, nco_EmailAddress % locals() )
####################################################################################
+nco_PhoneNumber = '''
+<%(phonenumber_uri)s> a nco:CellPhoneNumber;
+ nco:phoneNumber "%(phonenumber)s".
+'''
def generatePhoneNumber(index):
me = 'nco#PhoneNumber'
phonenumber = '+%d-555-%08d' %(index, index)
phonenumber_uri = 'tel:' + phonenumber
- # save the last uri
- tools.addUri( me, phonenumber_uri )
-
- # subsitute into template
- pn = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, pn % locals() )
-
+ tools.addItem( me, phonenumber_uri, nco_PhoneNumber % locals() )
####################################################################################
+nco_PostalAddress = '''
+<%(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" .
+'''
def generatePostalAddress(index):
me = 'nco#PostalAddress'
postal_address_uri = 'urn:pa:%d' % index
@@ -43,16 +44,19 @@ def generatePostalAddress(index):
postal_address_city = 'City %d' % (index % 1000)
postal_address_street = 'Demo Street %d' % (index % 100)
- # save the last uri
- tools.addUri( me, postal_address_uri )
-
- # subsitute into template
- pa = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, pa % locals() )
+ tools.addItem( me, postal_address_uri, nco_PostalAddress % locals() )
####################################################################################
+nco_PersonContact = '''
+<%(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 .
+'''
def generatePersonContact(index):
me = 'nco#PersonContact'
contact_uri = 'urn:uid:%d' % index
@@ -63,11 +67,4 @@ def generatePersonContact(index):
phonenumber_uri = '<%s>' % tools.getLastUri( 'nco#PhoneNumber' )
postal_address_uri = '<%s>' % tools.getLastUri( 'nco#PostalAddress' )
- # save the uri
- tools.addUri( me, contact_uri )
-
- # subsitute into template
- pc = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, pc % locals() )
+ tools.addItem( me, contact_uri, nco_PersonContact % locals() )
diff --git a/utils/data-generators/cc/nfo.py b/utils/data-generators/cc/nfo.py
index 1d9bb81..e353dce 100644
--- a/utils/data-generators/cc/nfo.py
+++ b/utils/data-generators/cc/nfo.py
@@ -4,6 +4,20 @@ import tools
import gen_data as gen
####################################################################################
+nfo_PlainTextDocument = '''
+<%(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" .
+'''
def generatePlainTextDocument(index):
me = 'nfo#PlainTextDocument'
plaintext_document_datasource = tools.getRandomUri( 'tracker#Volume' )
@@ -18,31 +32,33 @@ def generatePlainTextDocument(index):
plaintext_document_last_modified ='%d-%02d-%02dT01:01:01Z' % (2000 + (index % 10), (index % 12) + 1, (index % 25) + 1)
plaintext_document_size = '%d' % (1 + (index % 1000000))
- # save the last uri
- tools.addUri( me, plaintext_document_uri )
-
- # subsitute into template
- doc = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, doc % locals() )
+ tools.addItem( me, plaintext_document_uri, nfo_PlainTextDocument % locals() )
####################################################################################
+nfo_SoftwareCategory = '''
+<%(application_category_uri)s> a nfo:SoftwareCategory;
+ nie:title "%(application_category_title)s" .
+'''
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( me, application_category_uri )
-
- # subsitute into template
- category = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, category % locals() )
+ tools.addItem( me, application_category_uri, nfo_SoftwareCategory % locals() )
####################################################################################
+nfo_SoftwareApplication = '''
+<%(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" .
+'''
def generateSoftwareApplication(index):
me = 'nfo#SoftwareApplication'
application_cmdline = 'app%d' % index
@@ -55,33 +71,27 @@ def generateSoftwareApplication(index):
application_last_modified = '%d-%02d-%02dT01:01:01Z' % (2000 + (index % 10), (index % 12) + 1, (index % 25) + 1)
application_icon = 'urn:theme-icon:Icon-%d' % index
- # save the last uri
- tools.addUri( me, application_uri )
-
- # subsitute into template
- app = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, app % locals() )
-
+ tools.addItem( me, application_uri, nfo_SoftwareApplication % locals() )
####################################################################################
+nfo_WebHistory = '''
+<%(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" .
+'''
def generateWebHistory(index):
me = 'nfo#WebHistory'
webhistory_uri = 'urn:webhistory:%d' % index
webhistory_title = 'Web history %d' % (index % 1000)
- webhistory_date = tools.getDateNowString()
+ webhistory_date = tools.now
webhistory_created = webhistory_date
webhistory_modified = webhistory_date
webhistory_counter = '%d' % (index % 10)
webhistory_url = 'http://www.%d.com/' % index
- # save the last uri
- tools.addUri( me, webhistory_uri )
-
- # subsitute into template
- data = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, data % locals() )
+ tools.addItem( me, webhistory_uri, nfo_WebHistory % locals() )
diff --git a/utils/data-generators/cc/nmm.py b/utils/data-generators/cc/nmm.py
index f517115..31202be 100644
--- a/utils/data-generators/cc/nmm.py
+++ b/utils/data-generators/cc/nmm.py
@@ -1,8 +1,27 @@
# -*- coding: utf-8 -*-
import tools
-
####################################################################################
+nmm_Photo = '''
+<%(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)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> .
+'''
def generatePhoto(index):
me = 'nmm#Photo'
photo_uri = 'urn:photo:%d' % index
@@ -18,16 +37,25 @@ def generatePhoto(index):
photo_focal_length = '%d.0' % (1 + (index % 500))
photo_date = '%d-%02d-%02dT01:01:01Z' % (2000 + (index % 10), (index % 12) + 1, (index % 25) + 1)
- # save the last uri
- tools.addUri( me, photo_uri )
-
- # subsitute into template
- photo = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, photo % locals() )
+ tools.addItem( me, photo_uri, nmm_Photo % locals() )
####################################################################################
+nmm_Video = '''
+<%(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)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"] .
+'''
def generateVideo(index):
me = 'nmm#Video'
video_uri = 'urn:video:%d' % index
@@ -39,46 +67,58 @@ def generateVideo(index):
video_duration = str(index)
video_tag = 'TEST%d' % index
- # save the last uri
- tools.addUri( me, video_uri )
-
- # subsitute into template
- video = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, video % locals() )
+ tools.addItem( me, video_uri, nmm_Video % locals() )
####################################################################################
+nmm_Artist = '''
+<%(artist_uri)s> a nmm:Artist ;
+ nmm:artistName "%(artist_name)s" .
+'''
def generateArtist(index):
me = 'nmm#Artist'
artist_uri = 'urn:artist:%d' % index
artist_name = 'Artist %d' % (index % 1000)
- # save the last uri
- tools.addUri( me, artist_uri )
-
- # subsitute into template
- artist = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, artist % locals() )
+ tools.addItem( me, artist_uri, nmm_Artist % locals() )
####################################################################################
+nmm_MusicAlbum = '''
+<%(album_uri)s> a nmm:MusicAlbum ;
+ nie:title "%(album_name)s" ;
+ nmm:albumTitle "%(album_name)s" .
+'''
def generateAlbum(index):
me = 'nmm#MusicAlbum'
album_uri = 'urn:album:%d' % index
album_name = 'Album %d' % (index % 1000)
- # save the last uri
- tools.addUri( me, album_uri )
-
- # subsitute into template
- album = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, album % locals() )
+ tools.addItem( me, album_uri, nmm_MusicAlbum % locals() )
####################################################################################
+nmm_MusicPiece = '''
+<%(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" .
+'''
def generateMusicPiece(index):
me = 'nmm#MusicPiece'
music_piece_uri = 'urn:music:%d' % index
@@ -101,11 +141,4 @@ def generateMusicPiece(index):
music_piece_length = '%d' % (1 + (index % 1000))
music_piece_track = '%d' % (1 + (index % 100))
- # save the last uri
- tools.addUri( me, music_piece_uri )
-
- # subsitute into template
- mp = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, mp % locals() )
+ tools.addItem( me, music_piece_uri, nmm_MusicPiece % locals() )
diff --git a/utils/data-generators/cc/nmo.py b/utils/data-generators/cc/nmo.py
index dec1e5a..8f3dbb1 100644
--- a/utils/data-generators/cc/nmo.py
+++ b/utils/data-generators/cc/nmo.py
@@ -4,6 +4,12 @@ import tools
import gen_data as gen
####################################################################################
+nmo_MailAccount = '''
+<%(account_uri)s> a nmo:MailAccount ;
+ nmo:accountName "%(account_name)s" ;
+ nmo:fromAddress %(account_from_address_uri)s ;
+ nmo:signature "%(account_signature)s" .
+'''
def generateMailAccount(index):
me = 'nmo#MailAccount'
account_uri = 'qmf://groove.nokia.com/accounts#%d' % index
@@ -11,33 +17,39 @@ def generateMailAccount(index):
account_name = 'Account %d' % (index % 1000)
account_signature = 'Signature %d' % (index % 1000)
- # save the last uri
- tools.addUri( me, account_uri )
-
- # subsitute into template
- account = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, account % locals() )
-
+ tools.addItem( me, account_uri, nmo_MailAccount % locals() )
####################################################################################
+nmo_MailFolder = '''
+<%(mailfolder_uri)s> a nmo:MailFolder ;
+ nie:relatedTo %(mailfolder_account)s ;
+ nmo:folderName "%(mailfolder_name)s" .
+'''
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( me, mailfolder_uri )
-
- # subsitute into template
- folder = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, folder % locals() )
+ tools.addItem( me, mailfolder_uri, nmo_MailFolder % locals() )
####################################################################################
+nmo_Email = '''
+<%(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" .
+'''
def generateEmail(index):
me = 'nmo#Email'
email_uri = 'qmf://groove.nokia.com/email%d' % index
@@ -54,109 +66,128 @@ def generateEmail(index):
email_sent = '%d-%02d-%02dT01:01:02Z' % (2000 + (index % 10), (index % 12) + 1, (index % 25) + 1)
email_content = gen.create_text(2,30)
- # save the last uri
- tools.addUri( me, email_uri )
-
- # subsitute into template
- email = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, email % locals() )
+ tools.addItem( me, email_uri, nmo_Email % locals() )
####################################################################################
+nmo_CommunicationChannel = '''
+<%(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> .
+'''
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()
+ channel_date = tools.now
channel_modified = channel_date
channel_last_message = channel_date
channel_participiant = tools.getRandomUri( 'nco#PersonContact' )
- # save the last uri
- tools.addUri( me, channel_uri )
-
- # subsitute into template
- channel = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, channel % locals() )
+ tools.addItem( me, channel_uri, nmo_CommunicationChannel % locals() )
####################################################################################
+nmo_IMMessage = '''
+<%(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> .
+'''
def generateIMMessage(index):
me = 'nmo#IMMessage'
immessage_uri = 'urn:immessage:%d' % index
immessage_content = 'Lorem IM Ipsum %d' % index
- immessage_date = tools.getDateNowString()
- immessage_modified = tools.getDateNowString()
+ immessage_date = tools.now
+ immessage_modified = tools.now
immessage_from = tools.getRandomUri( 'nco#PersonContact' )
immessage_to = tools.getRandomUri( 'nco#PersonContact' )
immessage_draft = ('false', 'true')[index % 2]
immessage_read = ('false', 'true')[index % 2]
immessage_sent = 'true'
immessage_message_id = '%d' % index
- immessage_received = tools.getDateNowString()
- immessage_sent_date = tools.getDateNowString()
+ immessage_received = tools.now
+ immessage_sent_date = tools.now
immessage_channel_uri = tools.getRandomUri( 'nmo#CommunicationChannel' )
immessage_content = gen.create_text( 1, 2 )
- # save the last uri
- tools.addUri( me, immessage_uri )
-
- # subsitute into template
- imm = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, imm % locals() )
+ tools.addItem( me, immessage_uri, nmo_IMMessage % locals() )
####################################################################################
+nmo_SMSMessage = '''
+<%(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> .
+'''
def generateSMSMessage(index):
me = 'nmo#SMSMessage'
smsmessage_uri = 'urn:sms:%d' % index
smsmessage_id = '%d' % index
smsmessage_content = 'Lorem SMS Ipsum %d' % index
- smsmessage_date = tools.getDateNowString()
- smsmessage_modified = tools.getDateNowString()
+ smsmessage_date = tools.now
+ smsmessage_modified = tools.now
smsmessage_from = tools.getRandomUri( 'nco#PersonContact' )
smsmessage_to = tools.getRandomUri( 'nco#PersonContact' )
smsmessage_draft = ('false', 'true')[index % 2]
smsmessage_read = ('false', 'true')[index % 2]
smsmessage_sent = 'true'
smsmessage_message_id = '%d' % index
- smsmessage_received = tools.getDateNowString()
- smsmessage_sent_date = tools.getDateNowString()
+ smsmessage_received = tools.now
+ smsmessage_sent_date = tools.now
smsmessage_channel_uri = tools.getRandomUri( 'nmo#CommunicationChannel' )
smsmessage_content = gen.create_text( 1, 5 )
- # save the last uri
- tools.addUri( me, smsmessage_uri )
-
- # subsitute into template
- sms = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, sms % locals() )
+ tools.addItem( me, smsmessage_uri, nmo_SMSMessage % locals() )
####################################################################################
+nmo_Call = '''
+<%(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" .
+'''
def generateCall(index):
me = 'nmo#Call'
call_uri = 'urn:call:%d' % index
call_subject = 'Subject %d' % index
- call_date = tools.getDateNowString()
- call_modified = tools.getDateNowString()
+ call_date = tools.now
+ call_modified = tools.now
call_from = tools.getRandomUri( 'nco#PersonContact' )
call_to = tools.getRandomUri( 'nco#PersonContact' )
call_read = 'true'
call_sent = 'true'
- call_received = tools.getDateNowString()
- call_sent_date = tools.getDateNowString()
+ call_received = tools.now
+ call_sent_date = tools.now
call_duration = '%d' % ( 10 + (index % 3600) )
- # save the last uri
- tools.addUri( me, call_uri )
-
- # subsitute into template
- call = tools.getTemplate( me )
-
- # save the result
- tools.addResult( me, call % locals() )
+ tools.addItem( me, call_uri, nmo_Call % locals() )
diff --git a/utils/data-generators/cc/tools.py b/utils/data-generators/cc/tools.py
index 8ae0623..049f813 100644
--- a/utils/data-generators/cc/tools.py
+++ b/utils/data-generators/cc/tools.py
@@ -6,46 +6,28 @@ import datetime
import ontology_prefixes
-template_filenames = {}
output_filenames = {}
-templates = {}
last_uris = {}
result = {}
now = datetime.datetime.today().strftime('%Y-%m-%dT%H:%M:%SZ')
####################################################################################
def addType(name, order):
- template = 'template/' + name.replace( '#', '_') + '.tmpl'
output = 'ttl/%03d-' % order + name.replace( '#', '_') + '.ttl'
- template_filenames[name] = template
output_filenames[name] = output
- templates[name] = ''
result[name] = []
last_uris[name] = []
-def addResult(type, data):
- result[type].append(data)
-
-def addUri(type, uri):
- last_uris[type].append( uri )
+def addItem(itemtype, uri, content):
+ last_uris[itemtype].append( uri )
+ result[itemtype].append( content )
def getLastUri(type):
return last_uris[type][-1]
def getRandomUri(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 = ''.join( open(filename).readlines() )
- templates[ontology] = content
-
- return len(templates)
-
-def getTemplate(type):
- return templates[type]
def saveResult ():
for ontology, content in result.items():
@@ -55,6 +37,3 @@ def saveResult ():
for it in content:
output.write( it )
output.close()
-
-def getDateNowString():
- return now
diff --git a/utils/data-generators/cc/tracker.py b/utils/data-generators/cc/tracker.py
index eab3854..89e90e3 100644
--- a/utils/data-generators/cc/tracker.py
+++ b/utils/data-generators/cc/tracker.py
@@ -3,13 +3,11 @@
import tools
####################################################################################
+tracker_Volume = '''
+<%(datasource_uri)s> a tracker:Volume .
+'''
def generateVolume(index):
me = 'tracker#Volume'
datasource_uri = 'urn:nepomuk:datasource:%d' % index
- # save the last uri
- tools.addUri( me, datasource_uri )
-
- # subsitute into template
- volume = tools.getTemplate( 'tracker#Volume' )
- tools.addResult(me, volume % locals())
+ tools.addItem( me, datasource_uri, tracker_Volume % locals() )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]