Changeset 4404

Show
Ignore:
Timestamp:
10/06/08 12:37:24 (2 months ago)
Author:
cboos
Message:

GraphvizPlugin: in order to help "plug&play" installs, automatically create the cache_dir folder, but only if this corresponds to the default path.

If one sets explicitly a non-default cache_dir, one can as well make sure that this folder exists.

Closes #2157.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • graphvizplugin/0.11/graphviz/graphviz.py

    r4403 r4404  
    7474    #       some additional processing, see `_load_config()` below. 
    7575 
    76  
    77     cache_dir_option = Option("graphviz", "cache_dir", "gvcache", 
    78             """The directory that will be used to cache the generated images 
    79             (note that the directory must exist). 
     76    DEFAULT_CACHE_DIR = 'gvcache' 
     77 
     78    cache_dir_option = Option("graphviz", "cache_dir", DEFAULT_CACHE_DIR, 
     79            """The directory that will be used to cache the generated images. 
     80            Note that if different than the default (%s), this directory must 
     81            exist. 
    8082            If not given as an absolute path, the path will be relative to  
    8183            the Trac environment's directory. 
    82             """
     84            """ % DEFAULT_CACHE_DIR
    8385 
    8486    encoding = Option("graphviz", "encoding", 'utf-8', 
     
    448450 
    449451        if not os.path.exists(self.cache_dir): 
    450             return _("The cache_dir '%(path)s' doesn't exist, " 
    451                     "please create it.", path=self.cache_dir) 
     452            if self.cache_dir_option == self.DEFAULT_CACHE_DIR: 
     453                os.mkdir(self.cache_dir) 
     454            else: 
     455                return _("The cache_dir '%(path)s' doesn't exist, " 
     456                         "please create it.", path=self.cache_dir) 
    452457 
    453458        # Get optional configuration parameters from trac.ini.