Changeset 360 in tailor for vcpx/shwrap.py


Ignore:
Timestamp:
06/10/05 02:38:43 (8 years ago)
Author:
lele@…
Hash name:
20050610003843-97f81-6ae125e4cb26db223f81cccf7c06e7a2f56d1ab1
Message:

Force output encoding only when given the --encoding option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/shwrap.py

    r359 r360  
    7676    VERBOSE = True 
    7777    """Print the executed command on stderr, at each run.""" 
     78 
     79    FORCE_ENCODING = None 
     80    """Force the output encoding to some other charset instead of user prefs.""" 
    7881     
    7982    def __init__(self, command=None, working_dir=None): 
     
    120123                inp, out = popen2(command) 
    121124                def handleinp(): 
    122                     inp.write(input.encode('utf8')) 
     125                    if self.FORCE_ENCODING: 
     126                        inp.write(input.encode(self.FORCE_ENCODING)) 
     127                    else: 
     128                        inp.write(input) 
    123129                    inp.close() 
    124130                inpthread = threading.Thread(target = handleinp) 
     
    145151            if input: 
    146152                inp, out = popen2(command) 
    147                 inp.write(input) 
     153                if self.FORCE_ENCODING: 
     154                    inp.write(input.encode(self.FORCE_ENCODING)) 
     155                else: 
     156                    inp.write(input) 
    148157                inp.close() 
    149158                out.close() 
Note: See TracChangeset for help on using the changeset viewer.