source: products/quintagroup.themetemplate/trunk/quintagroup/themetemplate/templates/qplone3_theme/distwriters.py @ 1005

Last change on this file since 1005 was 1005, checked in by mylan, 15 years ago

Import package: Copied http://svn.quintagroup.com/products/qtheme.template/trunk@2041 + modifications concerning changed package name, namespace

File size: 933 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    except (TypeError,ValueError,AttributeError,AssertionError):
29        raise DistutilsSetupError(
30            "%r must be a dict (got %r)" % (attr,value)
31        )
Note: See TracBrowser for help on using the repository browser.