Changeset 568 in tailor


Ignore:
Timestamp:
08/15/05 10:30:19 (8 years ago)
Author:
lele@…
Hash name:
20050815083019-97f81-860b34d6a698822684707bdc261d55aef3b1ba27
Message:

M-x whitespace-cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/shwrap.py

    r420 r568  
    44# :Autore:   Lele Gaifax <lele@nautilus.homeip.net> 
    55# :Licenza:  GNU General Public License 
    6 #  
     6# 
    77 
    88__docformat__ = 'reStructuredText' 
     
    2828        from tempfile import mkstemp 
    2929        from os import close 
    30          
     30 
    3131        fd, self.name = mkstemp(suffix, prefix, dir, text) 
    3232        close(fd) 
    33          
     33 
    3434    def __del__(self): 
    3535        self.shutdown() 
    36         
     36 
    3737    def shutdown(self): 
    3838        from os import remove 
    39          
     39 
    4040        remove(self.name) 
    4141 
     
    5252    FORCE_ENCODING = None 
    5353    """Force the output encoding to some other charset instead of user prefs.""" 
    54      
     54 
    5555    def __init__(self, command=None, cwd=None): 
    5656        """Initialize a ExternalCommand instance, specifying the command 
     
    6262        self.cwd = cwd 
    6363        """The working directory, go there before execution.""" 
    64          
     64 
    6565        self.exit_status = None 
    6666        """Once the command has been executed, this is its exit status.""" 
     
    6868        self._last_command = None 
    6969        """Last executed command.""" 
    70          
     70 
    7171    def __str__(self): 
    7272        result = [] 
     
    7878        for arg in self._last_command or self.command: 
    7979            bs_buf = [] 
    80              
     80 
    8181            # Add a space to separate this argument from the others 
    8282            result.append(' ') 
     
    8888            for c in arg: 
    8989                if c == '\\': 
    90                     # Don't know if we need to double yet.  
     90                    # Don't know if we need to double yet. 
    9191                    bs_buf.append(c) 
    9292                elif c == '"': 
    93                     # Double backspaces.  
     93                    # Double backspaces. 
    9494                    result.append('\\' * len(bs_buf)*2) 
    9595                    bs_buf = [] 
     
    102102                    result.append(c) 
    103103 
    104             # Add remaining backspaces, if any.  
     104            # Add remaining backspaces, if any. 
    105105            if bs_buf: 
    106106                result.extend(bs_buf) 
     
    111111 
    112112        return ''.join(result) 
    113          
     113 
    114114    def execute(self, *args, **kwargs): 
    115115        """Execute the command.""" 
     
    118118        from os import environ 
    119119        from cStringIO import StringIO 
    120          
     120 
    121121        self.exit_status = None 
    122122 
     
    126126        else: 
    127127            self._last_command.extend(args) 
    128              
     128 
    129129        if self.VERBOSE: 
    130130            stderr.write(str(self)) 
     
    145145 
    146146        input = kwargs.get('input') 
    147          
     147 
    148148        try: 
    149149            process = Popen(self._last_command, 
     
    158158            self.exit_status = -1 
    159159            return 
    160          
     160 
    161161        if input: 
    162162            input = input.encode(self.FORCE_ENCODING or getdefaultencoding()) 
    163              
     163 
    164164        out = process.communicate(input=input)[0] 
    165165        if out: 
    166166            out = StringIO(out) 
    167167        self.exit_status = process.returncode 
    168              
     168 
    169169        if self.VERBOSE: 
    170170            if not self.exit_status: 
     
    172172            else: 
    173173                stderr.write(" [Status %s]\n" % self.exit_status) 
    174                  
     174 
    175175        return out 
    176  
Note: See TracChangeset for help on using the changeset viewer.