source: products/qtheme.template/trunk/qthemetemplate/__init__.py @ 2539

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

Remove some debugging

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