Changeset 127 in tailor for vcpx/tailor.py


Ignore:
Timestamp:
08/02/04 17:38:10 (9 years ago)
Author:
lele@…
Hash name:
20040802153810-e4df3-99fb5cf64efcee831e26d2ac025bf588113f1b0b
Message:

Store project's relative names in the new config

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/tailor.py

    r126 r127  
    2121LOG_FILENAME = 'tailor.log' 
    2222 
     23def relpathto(source, dest): 
     24    from os.path import abspath, split, commonprefix 
     25     
     26    source = abspath(source) 
     27    dest = abspath(dest) 
     28 
     29    if source.startswith(dest): 
     30        return source[len(dest)+1:] 
     31     
     32    prefix = commonprefix([source, dest]) 
     33 
     34    source = source[len(prefix):] 
     35    dest = dest[len(prefix):] 
     36 
     37    return '../' * len(dest.split('/')) + source 
     38 
     39 
    2340class TailorConfig(object): 
    2441    def __init__(self, options): 
     42        from os.path import split 
     43         
    2544        self.options = options 
     45        self.basedir = split(options.configfile)[0] 
    2646         
    2747    def __call__(self, args): 
    28         from os.path import abspath 
     48        from os.path import abspath, join 
    2949         
    3050        self.__load() 
    3151 
    3252        if len(args) == 0 and self.options.update: 
    33             args = self.config.keys() 
     53            args = [join(self.basedir, r) for r in self.config.keys()] 
    3454 
    3555        for a in args: 
     
    7090             
    7191    def loadProject(self, project): 
    72         info = self.config.get(project.root) 
    73  
     92        relpath = relpathto(project.root, self.basedir) 
     93         
     94        info = self.config.get(relpath) 
    7495        if info: 
    7596            project.source_kind = info['source_kind'] 
     
    82103         
    83104    def saveProject(self, project): 
    84         self.config[project.root] = {  
     105        relpath = relpathto(project.root, self.basedir) 
     106         
     107        self.config[relpath] = {  
    85108            'source_kind': project.source_kind, 
    86109            'target_kind': project.target_kind, 
Note: See TracChangeset for help on using the changeset viewer.