Changeset 502 in tailor


Ignore:
Timestamp:
08/05/05 11:59:12 (8 years ago)
Author:
lele@…
Hash name:
20050805095912-97f81-9483a9e9fea76f643cdb558b1236d72a8be9399d
Message:

Allow shebang scripts
Now a tailor script can be signed with the usual shebang notation. In
this case, it is treated as full fledged Python script: it gets executed
and it docstring become the actual configuration. This allow runtime
definition of functions that may be referenced from the various hooks

#!/usr/bin/env /home/lele/WiP/tailor/tailor
"""
[project]
...
before-commit = transform_crlf_to_lf
...
"""

def transform_crlf_to_lf(context, changeset):

for e in changeset.entries:

....

Of course, even the docstring may be computed dynamically, explicitly
assigning to the special doc variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/tailor.py

    r496 r502  
    250250    """ 
    251251 
     252    import sys 
    252253    from os import getcwd 
    253254 
     
    279280                defaults[k.replace('_', '-')] = str(v) 
    280281 
    281         if options.configfile: 
     282        if options.configfile or (len(sys.argv)==2 and len(args)==1): 
     283            # Either we have a --configfile, or there are no options 
     284            # and a single argument (to support shebang style scripts) 
     285 
     286            if not options.configfile: 
     287                options.configfile = sys.argv[1] 
     288                args = None 
     289 
    282290            config = Config(open(options.configfile), defaults) 
    283291 
Note: See TracChangeset for help on using the changeset viewer.