Ignore:
Timestamp:
Nov 1, 2009 11:07:11 AM (14 years ago)
Author:
mylan
Message:

#108: Refactored theme vars storage, some cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.themetemplate/trunk/quintagroup/themetemplate/__init__.py

    r1005 r1357  
    11# 
    2 import os,types 
    3 from StringIO import StringIO 
    4 from ConfigParser import SafeConfigParser 
     2import os 
     3from paste.script import pluginlib 
    54 
    65from quintagroup.themetemplate.qplone3_theme import qPlone3Theme 
    76 
    8 def write_map(cmd, basename, filename, force=False): 
    9     argname = os.path.splitext(basename)[0] 
    10     value = getattr(cmd.distribution, argname, None) 
     7def getEggInfo(output_dir): 
     8    """ Return path to egg info directory, raise error if not found. 
     9    """ 
     10    egg_info = pluginlib.find_egg_info_dir(output_dir) 
     11    assert egg_info is not None, "egg_info directory must present for the package" 
    1112 
    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) 
     13    return egg_info 
    2414 
    2515 
    26 def 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         ) 
     16def getThemeVarsFP(egg_info): 
     17    """ Return file system path to theme vars configurations 
     18    """ 
     19    return os.path.join(egg_info, '..', 'theme_vars.cfg') 
Note: See TracChangeset for help on using the changeset viewer.