Changeset 454


Ignore:
Timestamp:
01-11-09 17:05:09 (4 years ago)
Author:
thomas
Message:
  • command.py: Allow natural formatting of a list, identified by a line that starts with a space then a dash.
Location:
trunk/moap/extern/command
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/moap/extern/command/ChangeLog

    r453 r454  
     12009-11-01  Thomas Vander Stichele  <thomas at apestaart dot org> 
     2 
     3        * command.py: 
     4          Allow natural formatting of a list, identified by a line that 
     5          starts with a space then a dash. 
     6 
    172009-11-01  Thomas Vander Stichele  <thomas at apestaart dot org> 
    28 
  • trunk/moap/extern/command/command.py

    r453 r454  
    3333 
    3434    def format_description(self, description, width=None): 
    35  
    3635        # textwrap doesn't allow for a way to preserve double newlines 
    3736        # to separate paragraphs, so we do it here. 
    38         blocks = description.split('\n\n') 
     37        paragraphs = description.split('\n\n') 
     38        print paragraphs 
    3939        rets = [] 
    4040 
    41         for block in blocks: 
    42             rets.append(optparse.IndentedHelpFormatter.format_description(self, 
    43                 block)) 
     41        for paragraph in paragraphs: 
     42            # newlines starting with a space/dash are treated as a table, ie as 
     43            # is 
     44            lines = paragraph.split('\n -') 
     45            formatted = [] 
     46            for line in lines: 
     47                formatted.append(optparse.IndentedHelpFormatter.format_description(self, 
     48                line)) 
     49            rets.append(" -".join(formatted)) 
     50 
    4451        ret = "\n".join(rets) 
    4552 
Note: See TracChangeset for help on using the changeset viewer.