1 from os
.path
import join
2 from Globals
import package_home
3 from _namespaces
import namespaces
5 home
= package_home(globals())
7 f
= file(join(home
, 'accessors.csv'))
13 rdfKwnowTypes
= {'Seq':True, 'prop':True, 'Alt':True, 'Bag':True}
15 prefix2Ns
= dict([item
[::-1] for item
in namespaces
.items()])
17 for l
in [l
for l
in lines
if not l
.startswith('#')] :
18 fields
= [f
.strip() for f
in l
.split(',')]
20 if not filter(None, fields
) : continue
22 cat
, caption
, name
, root
, rdfType
= fields
24 accessor
= { 'id' : name
.split(':')[1]
27 , 'namespace' : prefix2Ns
.get(name
.split(':')[0])
30 assert not accessors
.has_key(name
), "Duplicate definition for %r" % name
31 assert name
.count(':') <=1, "Ambiguous name %r" % name
32 assert not accessorIds
.has_key(accessor
['id']), "Ambiguous name: %r" % name
33 assert rdfKwnowTypes
.has_key(rdfType
), "Unknown rdf type: %r" % rdfType
34 if rdfType
== 'prop' :
35 assert prefix2Ns
.has_key(name
.split(':')[0]), \
36 "Attribute name %r don't match a known namespace prefix" % name
38 accessors
[name
] = accessor
39 accessorIds
[accessor
['id']] = True
42 __all__
= ('namespaces', 'prefix2Ns', 'accessors')