source: products/qtheme.template/trunk/qthemetemplate/templates/qplone3_theme/distwriters.py @ 458

Last change on this file since 458 was 296, checked in by chervol, 18 years ago

*.pyc removed

File size: 964 bytes
Line 
1#
2import os,types
3from StringIO import StringIO
4from ConfigParser import SafeConfigParser
5
6def write_map(cmd, basename, filename, force=False):
7    argname = os.path.splitext(basename)[0]
8    value = getattr(cmd.distribution, argname, None)
9
10    if value:
11        config = SafeConfigParser()
12        config.add_section('qplone3_theme')
13        for name, val in value.items():
14            val = val and str(val) or ''
15            config.set('qplone3_theme', name, val)
16
17        strvalue = StringIO()
18        config.write(strvalue)
19        value = strvalue.getvalue()
20
21    cmd.write_or_delete_file(argname, filename, value, force)
22
23
24def assert_dict(dist, attr, value):
25    """Verify that value is a dict or None"""
26    try:
27        assert type(value) == types.DictType
28        print 'success assert'
29    except (TypeError,ValueError,AttributeError,AssertionError):
30        raise DistutilsSetupError(
31            "%r must be a dict (got %r)" % (attr,value)
32        )
Note: See TracBrowser for help on using the repository browser.