Changeset 506 in tailor


Ignore:
Timestamp:
08/05/05 12:39:18 (8 years ago)
Author:
lele@…
Hash name:
20050805103918-97f81-2efd1936ea1410722dc75df4d4d3810eb23487b6
Message:

Some notes about using Python scripts for the configuration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • README

    r488 r506  
    264264          template config filled with the values specified by the 
    265265          other options. You can redirect  
     266 
     267 
     268Using a Python script as configuration file 
     269------------------------------------------- 
     270 
     271Instead of executing ``tailor --configfile project.tailor.conf`` 
     272you can prepend the following signature to the config itself:: 
     273 
     274  #!/usr/bin/env /path/to/tailor 
     275 
     276Giving execute mode to it will permit the launch of the tailor 
     277process by running the config script directly:: 
     278 
     279  $ ./project.tailor.conf 
     280 
     281When a config file is signed in this way [#]_, either you pass it as 
     282argument to ``--configfile`` or executed as above, tailor will 
     283actually execute it as a full fledged Python script, that may define 
     284functions that alter the behaviour of tailor itself. 
     285 
     286A common usage of this functionality is to define so called `hooks`, 
     287sequences of functions that are executed at particular points in 
     288the tailorization process. 
     289 
     290For example:: 
     291 
     292    #!/usr/bin/env /home/lele/WiP/tailor/tailor 
     293    """ 
     294    [project] 
     295    source = svn:repository 
     296    target = darcs:repository 
     297    before-commit = transform_crlf_to_lf 
     298    ... 
     299    """ 
     300 
     301    def transform_crlf_to_lf(context, changeset): 
     302        for e in changeset.entries: 
     303            .... 
     304 
     305.. [#] Tailor does actually read just the first two bytes from the 
     306       file, and compare them with "#!", so you are free to choose 
     307       whatever syntax works in your environment. 
     308 
    266309 
    267310State file 
Note: See TracChangeset for help on using the changeset viewer.