Package svnmailer :: Module util
[show private | hide private]
[frames | no frames]

Module svnmailer.util

svnmailer utilities
Classes
TempFile Tempfile container class
_DummyPopen3 Dummy Popen3 class for platforms which don't provide one in popen2
_DummyPopen4 Dummy Popen4 class for platforms which don't provide one in popen2

Function Summary
popen2.Popen4 or _DummyPopen4 getPipe4(command)
Returns a pipe object (Popen4 or _DummyPopen4 on win32)
str or list getSuitableCommandLine(command, _platform)
Return the revised command suitable for being exec'd
file like object getUnicodeWriter(fp, in_enc, out_enc, err)
Returns the wrapped stream, which accepts unicode and strings
list splitCommand(command)
Split a command string with respect to quotes and such
popen2.Popen3 or _DummyPopen3 getPipe2(command)
Returns a pipe object (Popen3 or _DummyPopen3 on win32)
str or unicode getSuitableFileName(name, enc)
Returns a file name usable on the current system

Function Details

getPipe4(command)

Returns a pipe object (Popen4 or _DummyPopen4 on win32)
Parameters:
command - The command list (the first item is the command itself, the rest represents the arguments)
           (type=list)
Returns:
The pipe object
           (type=popen2.Popen4 or _DummyPopen4)

getSuitableCommandLine(command, _platform=None)

Return the revised command suitable for being exec'd

Currently this means, it's escaped and converted to a string only for Win32, because on this system the shell is called. For other systems the list is just returned.
Parameters:
command - The command to escape
           (type=list)
_platform - A platform string (for testing purposes only)
           (type=str)
Returns:
The escaped command string or the original list
           (type=str or list)

Note:

This is more or less the same as the stuff in svn.fs._escape_msvcrt_shell_command/arg. But it belongs somewhere else - e.g. into a util module...

Perhaps once a day the whole package goes directly into the subversion distribution and then it's all cool.

getUnicodeWriter(fp, in_enc='utf-8', out_enc='utf-8', err=None)

Returns the wrapped stream, which accepts unicode and strings
Parameters:
fp - The file object to wrap
           (type=file like object)
in_enc - The input encoding, that should be assumed, if a pure string is written
           (type=str)
out_enc - The output encoding
           (type=str)
err - The error handling indicator, when an unicode error occurs. (The default is quite lenient and writes replace characters on error)
           (type=str)
Returns:
The wrapped stream
           (type=file like object)

splitCommand(command)

Split a command string with respect to quotes and such

The command string consists of several tokens:
  • whitespace: Those are separators except inside quoted items
  • unquoted items: every token that doesn't start with a double quote (")
  • quoted items: every token that starts with a double quote ("). Those items must be closed with a double quote and may contain whitespaces. The enclosing quotes are stripped. To put a double quote character inside such a token, it has to be escaped with a backslash (\). Therefore - backslashes themselves have to be escaped as well. The escapes are also stripped from the result.
Here's an example: r'foo bar "baz" "zo\"" "\\nk"' resolves to ['foo', 'bar', 'baz', 'zo"', r'\nk']
Parameters:
command - The command string
           (type=str)
Returns:
The splitted command
           (type=list)
Raises:
ValueError - The command string is not valid (unclosed quote or the like)

getPipe2(command)

Returns a pipe object (Popen3 or _DummyPopen3 on win32)
Parameters:
command - The command list (the first item is the command itself, the rest represents the arguments)
           (type=list)
Returns:
The pipe object
           (type=popen2.Popen3 or _DummyPopen3)

getSuitableFileName(name, enc)

Returns a file name usable on the current system
Parameters:
enc - The encoding used for possible recoding
           (type=str)
Returns:
The suitable filename ;-)
           (type=str or unicode)
Raises:
UnicodeError - An error happened while recoding

Generated by Epydoc 2.0 on Mon Feb 14 16:49:18 2005 http://epydoc.sf.net