File: nco.py

package info (click to toggle)
tracker 3.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,096 kB
  • sloc: ansic: 57,908; javascript: 15,606; python: 6,272; cs: 242; perl: 106; sh: 98; xml: 29; makefile: 20
file content (163 lines) | stat: -rw-r--r-- 7,729 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# -*- coding: utf-8 -*-

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

  tools.addItem( me, email_address_uri, nco_EmailAddress % locals() )

####################################################################################
nco_Contact_Email = '''
<%(emailcontact_uri)s> a nco:Contact;
    nco:fullname            "%(emailcontact_name_given)s %(emailcontact_name_family)s";
    nco:nickname            "%(emailcontact_nickname)s" ;
    nco:hasEmailAddress      %(emailcontact_email_address_uri)s .
'''
def generateContactEmail(index):
  me = 'nco#ContactEmail'
  emailcontact_uri              = 'urn:contact:email%d' % index
  emailcontact_name_given       = 'Given%d' % (index % 1000)
  emailcontact_name_family      = 'Family%d' % (index % 1000)
  emailcontact_nickname         = 'Nickname%d' % (index % 1000)
  emailcontact_email_address_uri= '<%s>' % tools.getLastUri( 'nco#EmailAddress' )

  tools.addItem( me, emailcontact_uri, nco_Contact_Email % 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

  tools.addItem( me, phonenumber_uri, nco_PhoneNumber % locals() )

####################################################################################

nco_Contact_Call = '''
<%(callcontact_uri)s> a nco:Contact;
    nco:fullname            "%(callcontact_name_given)s %(callcontact_name_family)s";
    nco:nickname            "%(callcontact_nickname)s" ;
    nco:hasPhoneNumber       %(callcontact_phonenumber_uri)s .
'''
def generateContactCall(index):
  me = 'nco#ContactCall'
  callcontact_uri              = 'urn:contact:call%d' % index
  callcontact_name_given       = 'Given%d' % (index % 1000)
  callcontact_name_family      = 'Family%d' % (index % 1000)
  callcontact_nickname         = 'Nickname%d' % (index % 1000)
  callcontact_phonenumber_uri  = '<%s>' % tools.getLastUri( 'nco#PhoneNumber' )

  tools.addItem( me, callcontact_uri, nco_Contact_Call % locals() )

####################################################################################

nco_PostalAddress = '''
<%(postal_address_uri)s> a nco:PostalAddress;
    nco:country         "%(postal_address_country)s" ;
    nco:pobox           "%(postal_address_pobox)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
  postal_address_country     = 'Country %d' % (index % 1000)
  postal_address_locality    = 'Locality %d' % (index % 1000)
  postal_address_pobox       = str(index)
  postal_address_region      = 'Region %d' % (index % 1000)
  postal_address_postal_code = '%05d' % (index % 100000)
  postal_address_city        = 'City %d' % (index % 1000)
  postal_address_street      = 'Demo Street %d' % (index % 100)

  tools.addItem( me, postal_address_uri, nco_PostalAddress % locals() )

####################################################################################
nco_IMAddress = '''
<%(im_address_uri)s> a nco:IMAddress;
    nco:imID         "%(im_address_imid)s" ;
    nco:imCapability  %(im_address_capability)s .
'''
def generateIMAddress(index):
  me = 'nco#IMAddress'
  im_address_uri          = 'urn:ima:%d' % index
  im_address_imid         = 'IM ID %d' % (index % 1000)
  im_address_capability   = '<%s>' % ('nco:im-capability-text-chat', 'nco:im-capability-audio-calls') [ index %2 ]
  tools.addItem( me, im_address_uri, nco_IMAddress % locals() )

####################################################################################

nco_Contact_IM = '''
<%(imcontact_uri)s> a nco:Contact;
    nco:fullname            "%(imcontact_name_given)s %(imcontact_name_family)s";
    nco:nickname            "%(imcontact_nickname)s" ;
    nco:hasIMAddress         %(imcontact_imaddress_uri)s .
'''
def generateContactIM(index):
  me = 'nco#ContactIM'
  imcontact_uri              = 'urn:contact:im%d' % index
  imcontact_name_given       = 'Given%d' % (index % 1000)
  imcontact_name_family      = 'Family%d' % (index % 1000)
  imcontact_nickname         = 'Nickname%d' % (index % 1000)
  imcontact_imaddress_uri    = '<%s>' % tools.getLastUri( 'nco#IMAddress' )

  tools.addItem( me, imcontact_uri, nco_Contact_IM % locals() )

####################################################################################
nco_PersonContact = '''
<%(contact_uri)s:home> a nco:Affiliation;
    nco:hasEmailAddress      %(email_address_uri)s ;
    nco:hasPhoneNumber       %(phonenumber_uri)s ;
    nco:hasPostalAddress     %(postal_address_uri)s ;
    nco:hasIMAddress         %(im_address_uri)s .

<%(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:nameAdditional      "%(contact_name_additional)s" ;
    nco:nickname            "%(contact_nickname)s" ;
    nco:nameHonorificPrefix "%(contact_honorific_prefix)s" ;
    nco:nameHonorificSuffix "%(contact_honorific_suffix)s" ;
    nco:birthDate           "%(contact_birth_date)s" ;
    nco:gender               %(contact_gender)s ;
    nco:contactUID          "%(contact_uid)s" ;
    nco:note                "%(contact_note)s" ;
    nie:contentCreated      "%(contact_created)s" ;
    nie:contentLastModified "%(contact_modified)s"  ;
    nco:hasAffiliation      <%(contact_uri)s:home> .
'''
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)
  contact_name_additional  = 'Additional%d' % (index % 1000)
  contact_nickname         = 'Nickname%d' % (index % 1000)
  contact_honorific_prefix = ('Sir', 'Master') [index % 2]
  contact_honorific_suffix = ('PhD', 'Deceased') [index % 2]
  contact_birth_date       = '%d-%02d-%02dT%02d:%02d:%02dZ' % (1900 + (index % 100), (index % 12) + 1, (index % 25) + 1, (index % 12) + 1, (index % 12) + 1, (index % 12) + 1)
  contact_gender           = '<%s>' % ('nco:gender-female', 'nco:gender-female') [index % 2]
  contact_uid              = 'uid:contact:%d' % index
  contact_note             = 'Note number %d' % index
  email_address_uri        = '<%s>' % tools.getLastUri( 'nco#EmailAddress' )
  phonenumber_uri          = '<%s>' % tools.getLastUri( 'nco#PhoneNumber' )
  postal_address_uri       = '<%s>' % tools.getLastUri( 'nco#PostalAddress' )
  im_address_uri           = '<%s>' % tools.getLastUri( 'nco#IMAddress' )
  contact_created          = '%d-%02d-%02dT%02d:%02d:%02dZ' % (1950 + (index % 50), (index % 12) + 1, (index % 25) + 1, (index % 12) + 1, (index % 12) + 1, (index % 12) + 1)
  contact_modified         = '%d-%02d-%02dT%02d:%02d:%02dZ' % (1960 + (index % 40), (index % 12) + 1, (index % 25) + 1, (index % 12) + 1, (index % 12) + 1, (index % 12) + 1)

  tools.addItem( me, contact_uri, nco_PersonContact % locals() )