Changeset 322 in tailor for vcpx/session.py


Ignore:
Timestamp:
05/24/05 01:04:26 (8 years ago)
Author:
lele@…
Hash name:
20050523230426-97f81-6b302f6ff9ca5090e879545fbbea544d84d3621f
Message:

Accept either a 'yes', a 'true' or 1 as True values for the flags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/session.py

    r320 r322  
    2727""" 
    2828 
    29  
     29def yesno(arg): 
     30    "Return True for '1', 'true' or 'yes', False otherwise." 
     31 
     32    try: 
     33        return bool(int(arg)) 
     34    except ValueError: 
     35        return arg.lower() in ('true', 'yes') 
     36     
    3037class Session(Cmd): 
    3138    """Tailor interactive session.""" 
     
    185192         
    186193        if arg: 
    187             SystemCommand.VERBOSE = bool(arg) 
     194            SystemCommand.VERBOSE = yesno(arg) 
    188195 
    189196        self.__log('Print executed commands: %s\n' % SystemCommand.VERBOSE) 
     
    225232 
    226233        if arg: 
    227             SyncronizableTargetWorkingDir.REMOVE_FIRST_LOG_LINE = bool(arg) 
     234            SyncronizableTargetWorkingDir.REMOVE_FIRST_LOG_LINE = yesno(arg) 
    228235 
    229236        self.__log('Remove first log line: %s\n' % 
     
    241248         
    242249        if arg: 
    243             Changeset.REFILL_MESSAGE = bool(arg) 
     250            Changeset.REFILL_MESSAGE = yesno(arg) 
    244251 
    245252        self.__log('Refill changelogs: %s\n' % Changeset.REFILL_MESSAGE) 
Note: See TracChangeset for help on using the changeset viewer.