[tracker/tracker-0.8] Add videos to data generation.



commit 7504e1e5edde6ddc072e88f87744afecfc098c05
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Fri Apr 16 12:22:29 2010 +0300

    Add videos to data generation.
    
    Add videos to data generation. Fix some issues with images.

 utils/data-generators/cc/generate                |   10 ++++++
 utils/data-generators/cc/nmm.py                  |   33 +++++++++++++++++++++-
 utils/data-generators/cc/template/nmm_Video.tmpl |   14 +++++++++
 3 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/utils/data-generators/cc/generate b/utils/data-generators/cc/generate
index 0abe7d9..1cdf6d7 100755
--- a/utils/data-generators/cc/generate
+++ b/utils/data-generators/cc/generate
@@ -39,6 +39,7 @@ tools.addType( 'nco#PostalAddress', 11 )
 tools.addType( 'nco#PhoneNumber', 12 )
 tools.addType( 'nco#PersonContact', 13 )
 tools.addType( 'nmm#Photo', 20 )
+tools.addType( 'nmm#Video', 21 )
 tools.addType( 'nmo#MailAccount', 30 )
 tools.addType( 'nmo#MailFolder', 31 )
 tools.addType( 'nmo#Email', 32 )
@@ -155,6 +156,15 @@ for photo in range(1, count_images+1):
   nmm.generatePhoto( photo )
 print "Done"
 
+print "Generate Videos",
+count_videos = config.getint('counts','videos')
+for video in range(1, count_videos+1):
+  if (video % 10 == 0):
+    sys.stdout.write('.')
+    sys.stdout.flush()
+  nmm.generateVideo( video )
+print "Done"
+
 print "Generate plain text documents",
 count_docs = config.getint('counts','docs')
 for doc in range(1, count_docs+1):
diff --git a/utils/data-generators/cc/nmm.py b/utils/data-generators/cc/nmm.py
index 0d9a81d..a99b052 100644
--- a/utils/data-generators/cc/nmm.py
+++ b/utils/data-generators/cc/nmm.py
@@ -8,7 +8,10 @@ def generatePhoto(index):
   photo_filename     = 'photo%d.jpg' % index
   photo_url          = 'file:///path/' + photo_filename
   photo_size         = str(1000000 + index)
-  photo_camera       = 'Canikon 1000 Ultra Mega'
+  if (index % 10 == 0):
+    photo_camera     = "NOKIA"
+  else:
+    photo_camera     = 'Canikon 1000 Ultra Mega'
   photo_exposure     = '0.%d' % index
   photo_fnumber      = '%d.0' % (1 + (index % 20))
   photo_focal_length = '%d.0' % (1 + (index % 500))
@@ -33,6 +36,34 @@ def generatePhoto(index):
   tools.addResult( 'nmm#Photo', photo )
 
 ####################################################################################
+def generateVideo(index):
+  video_uri          = 'urn:video:%d' % index
+  video_filename     = 'video%d.jpg' % index
+  video_url          = 'file:///path/' + video_filename
+  video_size         = str(1000000 + index)
+  video_date         = '%d-%02d-%02dT01:01:01Z' % (2000 + (index % 10), (index % 12) + 1, (index % 25) + 1)
+  video_samplerate   = str(index)
+  video_duration     = str(index)
+  video_tag          = 'TEST%d' % index
+
+  # save the last uri
+  tools.addUri( 'nmm#Video', 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 )
+
+  # save the result
+  tools.addResult( 'nmm#Video', video )
+
+####################################################################################
 def generateArtist(index):
   artist_uri  = 'urn:artist:%d' % index
   artist_name = 'Artist %d' % (index % 1000)
diff --git a/utils/data-generators/cc/template/nmm_Video.tmpl b/utils/data-generators/cc/template/nmm_Video.tmpl
new file mode 100644
index 0000000..c327109
--- /dev/null
+++ b/utils/data-generators/cc/template/nmm_Video.tmpl
@@ -0,0 +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}";
+    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}"] .



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