[tracker] Write contacts ttl into stdout like the other tests.



commit 01b7feb80360cc70419b735c8713840a553b7afd
Author: Carlos Garnacho <carlos gnome org>
Date:   Wed Dec 2 17:08:32 2009 +0200

    Write contacts ttl into stdout like the other tests.

 .../generate-data-for-contact-messages.py          |  242 ++++++++++----------
 1 files changed, 119 insertions(+), 123 deletions(-)
---
diff --git a/utils/data-generators/generate-data-for-contact-messages.py b/utils/data-generators/generate-data-for-contact-messages.py
index 5d95e8c..c3fe7d0 100755
--- a/utils/data-generators/generate-data-for-contact-messages.py
+++ b/utils/data-generators/generate-data-for-contact-messages.py
@@ -18,49 +18,49 @@ def generateCalendarEntry(gen_data, str, random):
     #TODO set eventstart to 00 minutes 00 seconds
     eventStart = datetime.datetime.now() + datetime.timedelta(days=random.randint(0, 30), hours=random.randint(-4, 4))
     eventEnd = eventStart + datetime.timedelta(minutes=(random.randint(1, 4) * 30))
-    f.write('<urn:uuid:' + calendarEntryID + '> a nie:DataObject, ncal:Event, ncal:CalendarDataObject ;\n')
-    f.write('\tncal:attendee [ncal:involvedContact <urn:uuid:1>] ;\n')
-    f.write('\tncal:attendee [ncal:involvedContact <urn:uuid:'+previousContacts[organizerId]+'>] ;\n')
-    f.write('\tncal:transp ncal:transparentTransparency;\n')
-    #f.write('\tnie:dataSource <http://nepomuk.semanticdesktop.org/datawrapper/aperture/rootUri/calendar> ;\n')
-    f.write('\tncal:class ncal:publicClassification ;\n')
-    f.write('\tncal:summary "' + str.replace(gen_data.create_paragraphs(1, 2, 2), "\n", "") + '" ;\n')
-    f.write('\tncal:dtstart [ncal:dateTime "' + eventStart.isoformat().split('.')[0] + '"];\n')
-    f.write('\tncal:dtend [ncal:dateTime "' + eventEnd.isoformat().split('.')[0] + '"];\n')
+    sys.stdout.write('<urn:uuid:' + calendarEntryID + '> a nie:DataObject, ncal:Event, ncal:CalendarDataObject ;\n')
+    sys.stdout.write('\tncal:attendee [ncal:involvedContact <urn:uuid:1>] ;\n')
+    sys.stdout.write('\tncal:attendee [ncal:involvedContact <urn:uuid:'+previousContacts[organizerId]+'>] ;\n')
+    sys.stdout.write('\tncal:transp ncal:transparentTransparency;\n')
+    #sys.stdout.write('\tnie:dataSource <http://nepomuk.semanticdesktop.org/datawrapper/aperture/rootUri/calendar> ;\n')
+    sys.stdout.write('\tncal:class ncal:publicClassification ;\n')
+    sys.stdout.write('\tncal:summary "' + str.replace(gen_data.create_paragraphs(1, 2, 2), "\n", "") + '" ;\n')
+    sys.stdout.write('\tncal:dtstart [ncal:dateTime "' + eventStart.isoformat().split('.')[0] + '"];\n')
+    sys.stdout.write('\tncal:dtend [ncal:dateTime "' + eventEnd.isoformat().split('.')[0] + '"];\n')
     #TODO Add variance to location
-    f.write('\tncal:location "Helsinki, Finland" ;\n')
-    f.write('\tncal:sequence 0 ;\n')
-    f.write('\tncal:url <http://TODO-fillmehere.com> ;\n')
-    f.write('\tncal:organizer [ncal:involvedContact <urn:uuid:'+previousContacts[organizerId]+'>] ;\n')
-    f.write('\tncal:priority 5 ;\n')
+    sys.stdout.write('\tncal:location "Helsinki, Finland" ;\n')
+    sys.stdout.write('\tncal:sequence 0 ;\n')
+    sys.stdout.write('\tncal:url <http://TODO-fillmehere.com> ;\n')
+    sys.stdout.write('\tncal:organizer [ncal:involvedContact <urn:uuid:'+previousContacts[organizerId]+'>] ;\n')
+    sys.stdout.write('\tncal:priority 5 ;\n')
     if (random.randint(0, 4) > 3):
-        f.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
+        sys.stdout.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
     #Wow - hard to create uid?
-    f.write('\tncal:uid "040000008200E00074C5B7101A82E00800000000B020A967E159C8010000000000000000100000001F009082EE836A4D9E9F85D0FD610DDC" ;\n')
-    f.write('\tncal:dtstamp "' + datetime.datetime.now().isoformat().split('.')[0] + '" .\n')
-    f.write('\n')
+    sys.stdout.write('\tncal:uid "040000008200E00074C5B7101A82E00800000000B020A967E159C8010000000000000000100000001F009082EE836A4D9E9F85D0FD610DDC" ;\n')
+    sys.stdout.write('\tncal:dtstamp "' + datetime.datetime.now().isoformat().split('.')[0] + '" .\n')
+    sys.stdout.write('\n')
 
 def generateIMAccount(gen_data, str):
-    f.write('<xmpp:' + xmppAddress + '> a nco:IMAccount; \n')
-    f.write('\tnco:imAccountType "jabber" ;\n')
-    f.write('\tnco:imNickname "' + firstName + ' ' + lastName + '" ;\n')
-    #f.write('\tnco:imStatus "online" ;\n')
-    f.write('\tnco:imStatusMessage "' + str.replace(gen_data.create_paragraphs(1, 2, 2), "\n", "") + '" ;\n')
-    f.write('\tnco:imID "' + xmppAddress + '".\n')
-    f.write('\n')
+    sys.stdout.write('<xmpp:' + xmppAddress + '> a nco:IMAccount; \n')
+    sys.stdout.write('\tnco:imAccountType "jabber" ;\n')
+    sys.stdout.write('\tnco:imNickname "' + firstName + ' ' + lastName + '" ;\n')
+    #sys.stdout.write('\tnco:imStatus "online" ;\n')
+    sys.stdout.write('\tnco:imStatusMessage "' + str.replace(gen_data.create_paragraphs(1, 2, 2), "\n", "") + '" ;\n')
+    sys.stdout.write('\tnco:imID "' + xmppAddress + '".\n')
+    sys.stdout.write('\n')
     previousIMAccounts.append ('xmpp:' + xmppAddress)
 
 
 def generatePhoneNumber():
-    f.write('<' + phoneUri + '> a nco:PhoneNumber; \n')
-    f.write('\tnco:phoneNumber "' + phoneNumber + '".\n')
-    f.write('\n')
+    sys.stdout.write('<' + phoneUri + '> a nco:PhoneNumber; \n')
+    sys.stdout.write('\tnco:phoneNumber "' + phoneNumber + '".\n')
+    sys.stdout.write('\n')
 
 ## def generateImplicitContact (telephoneNumber):
 ##     objUID = str(random.randint(0, sys.maxint))
-##     f.write('<urn:uuid:' + objUID +'> a nco:Contact; \n')
-##     f.write('\tnco:hasPhoneNumber <' + telephoneNumber + '> .\n')
-##     f.write('\n')
+##     sys.stdout.write('<urn:uuid:' + objUID +'> a nco:Contact; \n')
+##     sys.stdout.write('\tnco:hasPhoneNumber <' + telephoneNumber + '> .\n')
+##     sys.stdout.write('\n')
 ##     return objUID
 
 
@@ -79,13 +79,13 @@ def generatePhoneCalls (many):
             contactProperty = "nmo:to"
             timeProperty = "nmo:sentDate"
 
-        f.write ('<urn:uuid:' + callUID + '> a nmo:TelephoneCall; \n')
-        f.write ('\t'+ contactProperty
+        sys.stdout.write ('<urn:uuid:' + callUID + '> a nmo:TelephoneCall; \n')
+        sys.stdout.write ('\t'+ contactProperty
                  +' [a nco:Contact; '
                  +'nco:hasPhoneNumber ' + '<' + phoneUri + '>]; \n')
-        f.write ('\tnmo:duration ' + str(duration) + '; \n')
-        f.write ('\t'+ timeProperty +' "' + getPseudoRandomDate () + '". \n')
-        f.write ('\n')
+        sys.stdout.write ('\tnmo:duration ' + str(duration) + '; \n')
+        sys.stdout.write ('\t'+ timeProperty +' "' + getPseudoRandomDate () + '". \n')
+        sys.stdout.write ('\n')
         #taggableUris.append ("urn:uuid:" + callUID)
 
 def generateSMS (many):
@@ -94,120 +94,119 @@ def generateSMS (many):
 
         smsUID = str(random.randint (0, sys.maxint))
 
-        f.write ('<urn:uuid:' + smsUID + '> a nmo:SMSMessage ;\n')
+        sys.stdout.write ('<urn:uuid:' + smsUID + '> a nmo:SMSMessage ;\n')
         if (random.randint (0,100) % 2 == 0):
             #Sent SMS
-            f.write('\tnmo:to [a nco:Contact; nco:hasPhoneNumber <' + phoneUri + '>];\n')
-            f.write('\tnmo:from [a nco:Contact; nco:hasPhoneNumber <' + myOwnPhoneNumberURI + '>];\n')
+            sys.stdout.write('\tnmo:to [a nco:Contact; nco:hasPhoneNumber <' + phoneUri + '>];\n')
+            sys.stdout.write('\tnmo:from [a nco:Contact; nco:hasPhoneNumber <' + myOwnPhoneNumberURI + '>];\n')
         else:
             #Received SMS
-            f.write('\tnmo:from [a nco:Contact; nco:hasPhoneNumber <' + phoneUri + '>];\n')
-            f.write('\tnmo:to [a nco:Contact; nco:hasPhoneNumber <' + myOwnPhoneNumberURI + '>];\n')
+            sys.stdout.write('\tnmo:from [a nco:Contact; nco:hasPhoneNumber <' + phoneUri + '>];\n')
+            sys.stdout.write('\tnmo:to [a nco:Contact; nco:hasPhoneNumber <' + myOwnPhoneNumberURI + '>];\n')
             
-        f.write('\tnmo:sentDate "' + getPseudoRandomDate () + '";\n')
-        f.write('\tnmo:receivedDate "' + getPseudoRandomDate () + '";\n') 
+        sys.stdout.write('\tnmo:sentDate "' + getPseudoRandomDate () + '";\n')
+        sys.stdout.write('\tnmo:receivedDate "' + getPseudoRandomDate () + '";\n') 
         if (random.randint(0, 4) > 3):
-            f.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
-        f.write('\tnmo:plainTextMessageContent "' + str.replace(gen_data.create_paragraphs(1, 5, 8), "\n", "") + '".\n')
-        f.write('\n')
+            sys.stdout.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
+        sys.stdout.write('\tnmo:plainTextMessageContent "' + str.replace(gen_data.create_paragraphs(1, 5, 8), "\n", "") + '".\n')
+        sys.stdout.write('\n')
 
 
 def generateEmailAddress():
-    f.write('<mailto:' + emailAddress + '> a nco:EmailAddress; \n')
-    f.write('\tnco:emailAddress "' + emailAddress + '".\n')
-    f.write('\n')
+    sys.stdout.write('<mailto:' + emailAddress + '> a nco:EmailAddress; \n')
+    sys.stdout.write('\tnco:emailAddress "' + emailAddress + '".\n')
+    sys.stdout.write('\n')
 
 def generatePostalAddress():
-    f.write('<urn:uuid:' + postalAddressID + '> a nco:PostalAddress; \n')
-    f.write('\tnco:country "US" ;\n')
-    f.write('\tnco:region "' + state + '" ;\n')
-    f.write('\tnco:postalcode "' + zip + '" ;\n')
-    f.write('\tnco:locality "' + city + '" ;\n')
-    f.write('\tnco:streetAddress "' + streetAddress + '" .\n')
-    f.write('\n')
+    sys.stdout.write('<urn:uuid:' + postalAddressID + '> a nco:PostalAddress; \n')
+    sys.stdout.write('\tnco:country "US" ;\n')
+    sys.stdout.write('\tnco:region "' + state + '" ;\n')
+    sys.stdout.write('\tnco:postalcode "' + zip + '" ;\n')
+    sys.stdout.write('\tnco:locality "' + city + '" ;\n')
+    sys.stdout.write('\tnco:streetAddress "' + streetAddress + '" .\n')
+    sys.stdout.write('\n')
 
 def generateEmail(sys, gen_data, str, random):
     emailUID = str(random.randint(0, sys.maxint))
     sentMoment = datetime.datetime.now() - datetime.timedelta(days=random.randint(0, 400), minutes=random.randint(0, 59), seconds=random.randint(0, 59))
     receivedMoment = sentMoment + datetime.timedelta(seconds=random.randint(0, 59))
-    f.write('<urn:uuid:' + emailUID + '> a nmo:Email; \n')
-    f.write('\tnmo:to <urn:uuid:1>;\n')
-    f.write('\tnmo:from <urn:uuid:' + UID + '>;\n')
-    f.write('\tnmo:sentDate "' + sentMoment.isoformat().split('.')[0] + '";\n')
-    f.write('\tnmo:receivedDate "' + receivedMoment.isoformat().split('.')[0] + '";\n')
-    f.write('\tnmo:contentMimeType "text/plain";\n')
-    #if random.randint(0, 11)>9 and len(previousContacts)>1: f.write('\tnmo:isRead true;\n')
-    #else: f.write('\tnmo:isRead false;\n')
-    f.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "User-Agent"; nmo:headerValue "tin/unoff-1.3-BETA-970813 (UNIX) (Linux/2.0.30 (i486)) "];\n')
-    f.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "from"; nmo:headerValue "' + emailAddress + '"];\n')
-    f.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "to"; nmo:headerValue "me me com"];\n')
+    sys.stdout.write('<urn:uuid:' + emailUID + '> a nmo:Email; \n')
+    sys.stdout.write('\tnmo:to <urn:uuid:1>;\n')
+    sys.stdout.write('\tnmo:from <urn:uuid:' + UID + '>;\n')
+    sys.stdout.write('\tnmo:sentDate "' + sentMoment.isoformat().split('.')[0] + '";\n')
+    sys.stdout.write('\tnmo:receivedDate "' + receivedMoment.isoformat().split('.')[0] + '";\n')
+    sys.stdout.write('\tnmo:contentMimeType "text/plain";\n')
+    #if random.randint(0, 11)>9 and len(previousContacts)>1: sys.stdout.write('\tnmo:isRead true;\n')
+    #else: sys.stdout.write('\tnmo:isRead false;\n')
+    sys.stdout.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "User-Agent"; nmo:headerValue "tin/unoff-1.3-BETA-970813 (UNIX) (Linux/2.0.30 (i486)) "];\n')
+    sys.stdout.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "from"; nmo:headerValue "' + emailAddress + '"];\n')
+    sys.stdout.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "to"; nmo:headerValue "me me com"];\n')
     if random.randint(0, 10) > 6 and len(previousContacts) > 1:
         ccid = random.randint(0, len(previousContacts) - 1)
-        f.write('\tnmo:cc <urn:uuid:' + previousContacts[ccid] + '>;\n')
-        f.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "cc"; nmo:headerValue "' + previousEmailAddresses[ccid] + '"];\n')
+        sys.stdout.write('\tnmo:cc <urn:uuid:' + previousContacts[ccid] + '>;\n')
+        sys.stdout.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "cc"; nmo:headerValue "' + previousEmailAddresses[ccid] + '"];\n')
     
         
     if random.randint(0, 10) > 7 and len(previousContacts) > 1:
         bccid = random.randint(0, len(previousContacts) - 1)
-        f.write('\tnmo:bcc <urn:uuid:' + previousContacts[bccid] + '>;\n')
-        f.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "bcc"; nmo:headerValue "' + previousEmailAddresses[bccid] + '"];\n')
+        sys.stdout.write('\tnmo:bcc <urn:uuid:' + previousContacts[bccid] + '>;\n')
+        sys.stdout.write('\tnmo:messageHeader [a nmo:MessageHeader; nmo:headerName "bcc"; nmo:headerValue "' + previousEmailAddresses[bccid] + '"];\n')
     #TODO add some sense to the email titles. Some reply chains as well.
     if (random.randint(0, 4) > 3):
-        f.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
+        sys.stdout.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
     
-    f.write('\tnmo:messageSubject "' + str.replace(gen_data.create_paragraphs(1, 2, 2), "\n", "") + '";\n')
-    f.write('\tnmo:plainTextMessageContent "' + str.replace(gen_data.create_paragraphs(1, 2, 3), "\n", "") + '".\n')
+    sys.stdout.write('\tnmo:messageSubject "' + str.replace(gen_data.create_paragraphs(1, 2, 2), "\n", "") + '";\n')
+    sys.stdout.write('\tnmo:plainTextMessageContent "' + str.replace(gen_data.create_paragraphs(1, 2, 3), "\n", "") + '".\n')
 
 
 
 # BEGIN CREATING.
 if (len(sys.argv) < 2):
-    print "Usage: python get_ttl.py NO_CONTACTS [--with-phone]"
+    sys.stderr.write("Usage: python get_ttl.py NO_CONTACTS [--with-phone]")
     sys.exit(0)
 
 try:
     count = int(sys.argv[1])
 except:
-    print "Usage: python get_ttl.py NO_CONTACTS [--with-phone]"
+    sys.stderr.write("Usage: python get_ttl.py NO_CONTACTS [--with-phone]")
     sys.exit(0)
 
 if (len(sys.argv) > 2):
     if (sys.argv[2] == "--with-phone") :
-        print "Writing %d contacts in 'contacts.ttl' with phone information " %(count)
+        sys.stderr.write("Writing %d contacts in stdout with phone information " %(count))
         withPhone = True
     else:
-        print "WTF?!?!? python get_ttl.py NO_CONTACTS [--with-phone]"
+        sys.stderr.write("WTF?!?!? python get_ttl.py NO_CONTACTS [--with-phone]")
 else:
-    print "Writing %d 'contacts.ttl' without phone information" % (count)
-    print "Add --with-phone option to include phone information"
+    sys.stderr.write("Writing %d contacts in stdout without phone information\n" % (count))
+    sys.stderr.write("Add --with-phone option to include phone information\n")
     withPhone = False
-        
-f=open("./contacts.ttl", 'w' )
-f.write("@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>.\n")
-f.write("@prefix nrl:   <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#>.\n")
-f.write("@prefix nid3:   <http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#>.\n")
-f.write("@prefix nao:   <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#>.\n")
-f.write("@prefix nco:   <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#>.\n")
-f.write("@prefix nmo:   <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#>.\n")
-f.write("@prefix nfo:   <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#>.\n")    
-f.write("@prefix nie:   <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#>.\n")
-f.write("@prefix ncal:   <http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#>.\n")
-
-f.write("@prefix xsd:   <http://www.w3.org/2001/XMLSchema#>.\n")
-f.write('<mailto:me me com> a nco:EmailAddress; \n')
-f.write('\tnco:emailAddress "me me com".\n')
-f.write('\n')
-f.write('<urn:uuid:1> a nco:PersonContact; \n')    
-f.write('\tnco:fullname "Me Myself";\n')
-f.write('\tnco:nameGiven "Me";\n')
-f.write('\tnco:nameFamily "Myself";\n')
-f.write('\tnco:birthDate "2008-01-01";\n')
-f.write('\tnco:hasEmailAddress <mailto:me me com>;\n')
-f.write('\tnco:hasPhoneNumber <tel:+11111111111>.\n')
-f.write('\n')
-f.write('<tel:+11111111111> a nco:PhoneNumber; \n')
-f.write('\tnco:phoneNumber "(111) 111-1111".\n')
-f.write('\n')
+
+sys.stdout.write("@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>.\n")
+sys.stdout.write("@prefix nrl:   <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#>.\n")
+sys.stdout.write("@prefix nid3:   <http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#>.\n")
+sys.stdout.write("@prefix nao:   <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#>.\n")
+sys.stdout.write("@prefix nco:   <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#>.\n")
+sys.stdout.write("@prefix nmo:   <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#>.\n")
+sys.stdout.write("@prefix nfo:   <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#>.\n")    
+sys.stdout.write("@prefix nie:   <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#>.\n")
+sys.stdout.write("@prefix ncal:   <http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#>.\n")
+
+sys.stdout.write("@prefix xsd:   <http://www.w3.org/2001/XMLSchema#>.\n")
+sys.stdout.write('<mailto:me me com> a nco:EmailAddress; \n')
+sys.stdout.write('\tnco:emailAddress "me me com".\n')
+sys.stdout.write('\n')
+sys.stdout.write('<urn:uuid:1> a nco:PersonContact; \n')    
+sys.stdout.write('\tnco:fullname "Me Myself";\n')
+sys.stdout.write('\tnco:nameGiven "Me";\n')
+sys.stdout.write('\tnco:nameFamily "Myself";\n')
+sys.stdout.write('\tnco:birthDate "2008-01-01";\n')
+sys.stdout.write('\tnco:hasEmailAddress <mailto:me me com>;\n')
+sys.stdout.write('\tnco:hasPhoneNumber <tel:+11111111111>.\n')
+sys.stdout.write('\n')
+sys.stdout.write('<tel:+11111111111> a nco:PhoneNumber; \n')
+sys.stdout.write('\tnco:phoneNumber "(111) 111-1111".\n')
+sys.stdout.write('\n')
 
 #TODO need to create some email folders
 myOwnPhoneNumberURI="tel:+11111111111"
@@ -246,19 +245,19 @@ for dummy in range (0, count):
         if (withPhone): generatePhoneCalls(3)
         if (withPhone): generateSMS (4)
         
-    f.write('<urn:uuid:'+UID+'> a nco:PersonContact; \n')    
-    f.write('\tnco:fullname "'+firstName+ ' ' + lastName+'";\n')
-    f.write('\tnco:nameGiven "'+firstName+'";\n')
-    f.write('\tnco:nameFamily "'+lastName+'";\n')
-    f.write('\tnco:birthDate "'+str(birthDay)+'";\n')
-    #f.write('\tnco:title "'+jobTitle+'";\n')
-    f.write('\tnco:hasEmailAddress <mailto:'+emailAddress+'>;\n')
-    if hasPhoneNumber: f.write('\tnco:hasPhoneNumber <'+phoneUri+'>;\n')
-    if hasIMAccount: f.write('\tnco:hasIMAccount <xmpp:'+xmppAddress+'>;\n')    	 
+    sys.stdout.write('<urn:uuid:'+UID+'> a nco:PersonContact; \n')    
+    sys.stdout.write('\tnco:fullname "'+firstName+ ' ' + lastName+'";\n')
+    sys.stdout.write('\tnco:nameGiven "'+firstName+'";\n')
+    sys.stdout.write('\tnco:nameFamily "'+lastName+'";\n')
+    sys.stdout.write('\tnco:birthDate "'+str(birthDay)+'";\n')
+    #sys.stdout.write('\tnco:title "'+jobTitle+'";\n')
+    sys.stdout.write('\tnco:hasEmailAddress <mailto:'+emailAddress+'>;\n')
+    if hasPhoneNumber: sys.stdout.write('\tnco:hasPhoneNumber <'+phoneUri+'>;\n')
+    if hasIMAccount: sys.stdout.write('\tnco:hasIMAccount <xmpp:'+xmppAddress+'>;\n')    	 
     if (random.randint(0, 4) > 3):
-        f.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
-    f.write('\tnco:hasPostalAddress <urn:uuid:'+postalAddressID+'>.\n')
-    f.write('\n')
+        sys.stdout.write ('\tnao:hasTag [a nao:Tag ; nao:prefLabel ' +  getRandomTag () +'];\n')
+    sys.stdout.write('\tnco:hasPostalAddress <urn:uuid:'+postalAddressID+'>.\n')
+    sys.stdout.write('\n')
 
         
     #calendarEntryID=str(random.randint(0, sys.maxint))
@@ -270,14 +269,11 @@ for dummy in range (0, count):
         emailcount=random.randint(1, 30)        
         for dummy in range (0, emailcount):
             generateEmail(sys, gen_data, str, random)
-            f.write('\n')
+            sys.stdout.write('\n')
     previousContacts.append(UID)
     previousEmailAddresses.append(emailAddress)
     
     #TODO INSERT IM - Use just a nmo:Message for that for now. 
     
     #TODO: Insert bookmarks
-    
-    
-f.close()
 



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