Changeset 4421:16d58ecabc0f in livinglogic.python.xist

Show
Ignore:
Timestamp:
03/17/11 12:14:57 (8 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

uls: --padding and --separator now are unicode.

This fixes the width calculation for fancy characters.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/scripts/uls.py

    r4413 r4421  
    1212 
    1313""" 
    14 ``uls`` is a script that lists directory contents. It is an URL-enabled version 
    15 of the ``ls`` system command. Via :mod:`ll.url` and :mod:`ll.orasql` ``uls`` 
    16 supports ``ssh`` and ``oracle`` URLs too. 
     14``uls`` is a script that lists the content of directories. It is an URL-enabled 
     15version of the ``ls`` system command. Via :mod:`ll.url` and :mod:`ll.orasql` 
     16``uls`` supports ``ssh`` and ``oracle`` URLs too. 
    1717 
    1818 
     
    4242 
    4343    ``-r``, ``--recursive`` : ``false``, ``no``, ``0``, ``true``, ``yes`` or ``1`` 
    44         List directory recursively. 
     44        List directories recursively. 
    4545 
    4646    ``-w``, ``--spacing`` : integer 
    4747        The number of spaces (or padding characters) between columns (only 
    48         relevant when neither ``--long`` nor ``--one`` is specified). 
     48        relevant for multicolumn ouput, i.e. when neither ``--long`` nor 
     49        ``--one`` is specified). 
    4950 
    5051    ``-P``, ``--padding`` : characters 
     
    5556 
    5657    ``-i``, ``--include`` : regular expression 
    57         Only URLs matching the regular expression will be output. 
     58        Only URLs matching this regular expression will be output. 
    5859 
    5960    ``-e``, ``--expression`` : regular expression 
    60         URLs matching the regular expression will be not be output. 
     61        URLs matching this regular expression will be not be output. 
    6162 
    6263    ``-a``, ``--all`` :  ``false``, ``no``, ``0``, ``true``, ``yes`` or ``1`` 
     
    132133style_pad = astyle.Style.fromstr("black:black:bold") 
    133134style_sizeunit = astyle.Style.fromstr("cyan:black") 
     135 
     136 
     137def encodedstring(s): 
     138    return s.decode(sys.stdin.encoding) 
    134139 
    135140 
     
    290295    p.add_argument("-r", "--recursive", dest="recursive", help="Recursive listing? (default: %(default)s)", action=misc.FlagAction, default=False) 
    291296    p.add_argument("-w", "--spacing", dest="spacing", metavar="INTEGER", help="Space between columns (default: %(default)s)", type=int, default=3) 
    292     p.add_argument("-P", "--padding", dest="padding", metavar="CHARS", help="Characters used for column padding (default: %(default)s)", default=" ") 
    293     p.add_argument("-S", "--separator", dest="separator", metavar="CHARS", help="Characters used for separating columns in long format (default: %(default)s)", default="  ") 
     297    p.add_argument("-P", "--padding", dest="padding", metavar="CHARS", help="Characters used for column padding (default: %(default)s)", default=u" ", type=encodedstring) 
     298    p.add_argument("-S", "--separator", dest="separator", metavar="CHARS", help="Characters used for separating columns in long format (default: %(default)s)", default=u"  ", type=encodedstring) 
    294299    p.add_argument("-i", "--include", dest="include", metavar="PATTERN", help="Include only URLs matching PATTERN (default: %(default)s)", type=re.compile) 
    295300    p.add_argument("-e", "--exclude", dest="exclude", metavar="PATTERN", help="Exclude URLs matching PATTERN (default: %(default)s)", type=re.compile)