Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/python/svn/core.py view on Meta::CPAN
# Common prefix was skipped above, next character is compared to
# determine order
return cmp(char1, char2)
def svn_mergeinfo_merge(mergeinfo, changes):
return _libsvncore.svn_swig_mergeinfo_merge(mergeinfo, changes)
def svn_mergeinfo_sort(mergeinfo):
return _libsvncore.svn_swig_mergeinfo_sort(mergeinfo)
def svn_rangelist_merge(rangelist, changes):
return _libsvncore.svn_swig_rangelist_merge(rangelist, changes)
def svn_rangelist_reverse(rangelist):
return _libsvncore.svn_swig_rangelist_reverse(rangelist)
class Stream:
"""A file-object-like wrapper for Subversion svn_stream_t objects."""
def __init__(self, stream):
self._stream = stream
def read(self, amt=None):
if amt is None:
# read the rest of the stream
chunks = [ ]
while True:
data = svn_stream_read(self._stream, SVN_STREAM_CHUNK_SIZE)
if not data:
break
chunks.append(data)
return ''.join(chunks)
# read the amount specified
return svn_stream_read(self._stream, int(amt))
def write(self, buf):
### what to do with the amount written? (the result value)
svn_stream_write(self._stream, buf)
def secs_from_timestr(svn_datetime, pool=None):
"""Convert a Subversion datetime string into seconds since the Epoch."""
aprtime = svn_time_from_cstring(svn_datetime, pool)
# ### convert to a time_t; this requires intimate knowledge of
# ### the apr_time_t type
# ### aprtime is microseconds; turn it into seconds
return aprtime / 1000000
# ============================================================================
# Variations on this code are used in other places:
# - subversion/build/generator/gen_win.py
# - cvs2svn/cvs2svn
# Names that are not to be exported
import sys as _sys
if _sys.platform == "win32":
import re as _re
_escape_shell_arg_re = _re.compile(r'(\\+)(\"|$)')
def escape_shell_arg(arg):
# The (very strange) parsing rules used by the C runtime library are
# described at:
# http://msdn.microsoft.com/library/en-us/vclang/html/_pluslang_Parsing_C.2b2b_.Command.2d.Line_Arguments.asp
# double up slashes, but only if they are followed by a quote character
arg = _re.sub(_escape_shell_arg_re, r'\1\1\2', arg)
# surround by quotes and escape quotes inside
arg = '"' + arg.replace('"', '"^""') + '"'
return arg
def argv_to_command_string(argv):
"""Flatten a list of command line arguments into a command string.
The resulting command string is expected to be passed to the system
shell which os functions like popen() and system() invoke internally.
"""
# According cmd's usage notes (cmd /?), it parses the command line by
# "seeing if the first character is a quote character and if so, stripping
# the leading character and removing the last quote character."
# So to prevent the argument string from being changed we add an extra set
# of quotes around it here.
return '"' + " ".join(map(escape_shell_arg, argv)) + '"'
else:
def escape_shell_arg(str):
return "'" + str.replace("'", "'\\''") + "'"
def argv_to_command_string(argv):
"""Flatten a list of command line arguments into a command string.
The resulting command string is expected to be passed to the system
shell which os functions like popen() and system() invoke internally.
"""
return " ".join(map(escape_shell_arg, argv))
# ============================================================================
# Deprecated functions
def apr_initialize():
"""Deprecated. APR is now initialized automatically. This is
a compatibility wrapper providing the interface of the
Subversion 1.2.x and earlier bindings."""
pass
def apr_terminate():
"""Deprecated. APR is now terminated automatically. This is
a compatibility wrapper providing the interface of the
Subversion 1.2.x and earlier bindings."""
pass
def svn_pool_create(parent_pool=None):
"""Deprecated. Use Pool() instead. This is a compatibility
wrapper providing the interface of the Subversion 1.2.x and
earlier bindings."""
return Pool(parent_pool)
def svn_pool_destroy(pool):
"""Deprecated. Pools are now destroyed automatically. If you
want to manually destroy a pool, use Pool.destroy. This is
a compatibility wrapper providing the interface of the
Subversion 1.2.x and earlier bindings."""
assert pool is not None
# New in 1.3.x: All pools are automatically destroyed when Python shuts
# down. For compatibility with 1.2.x, we won't report an error if your
# app tries to destroy a pool during the shutdown process. Instead, we
# check to make sure the application_pool is still around before calling
# pool.destroy().
if application_pool and application_pool.valid():
pool.destroy()
apr_pool_destroy = svn_pool_destroy
def svn_pool_clear(pool):
"""Deprecated. Use Pool.clear instead. This is a compatibility
wrapper providing the interface of the Subversion 1.2.x and
earlier bindings."""
assert pool is not None
pool.clear()
apr_pool_clear = svn_pool_clear
def run_app(func, *args, **kw):
'''Deprecated: Application-level pools are now created
automatically. APR is also initialized and terminated
automatically. This is a compatibility wrapper providing the
interface of the Subversion 1.2.x and earlier bindings.
Run a function as an "APR application".
APR is initialized, and an application pool is created. Cleanup is
performed as the function exits (normally or via an exception).
'''
return func(application_pool, *args, **kw)
( run in 0.508 second using v1.01-cache-2.11-cpan-5623c5533a1 )