_current_filename n'existe plus avec zope-2.12. On remlace par son implémentation.
[Photo.git] / standards / xmp / __init__.py
1 from os.path import join
2 from Globals import package_home
3 from _namespaces import namespaces
4
5 home = package_home(globals())
6
7 f = file(join(home, 'accessors.csv'))
8 lines = f.readlines()
9 f.close()
10
11 accessors = {}
12 accessorIds = {}
13 rdfKwnowTypes = {'Seq':True, 'prop':True, 'Alt':True, 'Bag':True}
14
15 prefix2Ns = dict([item[::-1] for item in namespaces.items()])
16
17 for l in [l for l in lines if not l.startswith('#')] :
18 fields = [f.strip() for f in l.split(',')]
19
20 if not filter(None, fields) : continue
21
22 cat, caption, name, root, rdfType = fields
23
24 accessor = { 'id' : name.split(':')[1]
25 , 'root' : root
26 , 'rdfType' : rdfType
27 , 'namespace' : prefix2Ns.get(name.split(':')[0])
28 }
29
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
37
38 accessors[name] = accessor
39 accessorIds[accessor['id']] = True
40
41
42 __all__ = ('namespaces', 'prefix2Ns', 'accessors')