mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 15:40:01 -06:00
Remove (un)wrap_binary_data cruft from */ipautil.py
Remove SAFE_STRING_PATTERN, safe_string_re, needs_base64(), wrap_binary_data(), unwrap_binary_data() from both instances of ipautil.py. This code is no longer in use and the SAFE_STRING_PATTERN regular expression string was causing xgettext to abort because it wasn't a valid ASCII string.
This commit is contained in:
parent
1d6cc1bb7b
commit
9409b5cf2e
@ -284,68 +284,6 @@ class CIDict(dict):
|
|||||||
return (key,value)
|
return (key,value)
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# The safe_string_re regexp and needs_base64 function are extracted from the
|
|
||||||
# python-ldap ldif module, which was
|
|
||||||
# written by Michael Stroeder <michael@stroeder.com>
|
|
||||||
# http://python-ldap.sourceforge.net
|
|
||||||
#
|
|
||||||
# It was extracted because ipaldap.py is naughtily reaching into the ldif
|
|
||||||
# module and squashing this regexp.
|
|
||||||
#
|
|
||||||
SAFE_STRING_PATTERN = '(^(\000|\n|\r| |:|<)|[\000\n\r\200-\377]+|[ ]+$)'
|
|
||||||
safe_string_re = re.compile(SAFE_STRING_PATTERN)
|
|
||||||
|
|
||||||
def needs_base64(s):
|
|
||||||
"""
|
|
||||||
returns 1 if s has to be base-64 encoded because of special chars
|
|
||||||
"""
|
|
||||||
return not safe_string_re.search(s) is None
|
|
||||||
|
|
||||||
|
|
||||||
def wrap_binary_data(data):
|
|
||||||
"""Converts all binary data strings into Binary objects for transport
|
|
||||||
back over xmlrpc."""
|
|
||||||
if isinstance(data, str):
|
|
||||||
if needs_base64(data):
|
|
||||||
return xmlrpclib.Binary(data)
|
|
||||||
else:
|
|
||||||
return data
|
|
||||||
elif isinstance(data, list) or isinstance(data,tuple):
|
|
||||||
retval = []
|
|
||||||
for value in data:
|
|
||||||
retval.append(wrap_binary_data(value))
|
|
||||||
return retval
|
|
||||||
elif isinstance(data, dict):
|
|
||||||
retval = {}
|
|
||||||
for (k,v) in data.iteritems():
|
|
||||||
retval[k] = wrap_binary_data(v)
|
|
||||||
return retval
|
|
||||||
else:
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def unwrap_binary_data(data):
|
|
||||||
"""Converts all Binary objects back into strings."""
|
|
||||||
if isinstance(data, xmlrpclib.Binary):
|
|
||||||
# The data is decoded by the xmlproxy, but is stored
|
|
||||||
# in a binary object for us.
|
|
||||||
return str(data)
|
|
||||||
elif isinstance(data, str):
|
|
||||||
return data
|
|
||||||
elif isinstance(data, list) or isinstance(data,tuple):
|
|
||||||
retval = []
|
|
||||||
for value in data:
|
|
||||||
retval.append(unwrap_binary_data(value))
|
|
||||||
return retval
|
|
||||||
elif isinstance(data, dict):
|
|
||||||
retval = {}
|
|
||||||
for (k,v) in data.iteritems():
|
|
||||||
retval[k] = unwrap_binary_data(v)
|
|
||||||
return retval
|
|
||||||
else:
|
|
||||||
return data
|
|
||||||
|
|
||||||
class GeneralizedTimeZone(datetime.tzinfo):
|
class GeneralizedTimeZone(datetime.tzinfo):
|
||||||
"""This class is a basic timezone wrapper for the offset specified
|
"""This class is a basic timezone wrapper for the offset specified
|
||||||
in a Generalized Time. It is dst-ignorant."""
|
in a Generalized Time. It is dst-ignorant."""
|
||||||
|
@ -116,68 +116,6 @@ class CIDict(dict):
|
|||||||
return (key, value)
|
return (key, value)
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# The safe_string_re regexp and needs_base64 function are extracted from the
|
|
||||||
# python-ldap ldif module, which was
|
|
||||||
# written by Michael Stroeder <michael@stroeder.com>
|
|
||||||
# http://python-ldap.sourceforge.net
|
|
||||||
#
|
|
||||||
# It was extracted because ipaldap.py is naughtily reaching into the ldif
|
|
||||||
# module and squashing this regexp.
|
|
||||||
#
|
|
||||||
SAFE_STRING_PATTERN = '(^(\000|\n|\r| |:|<)|[\000\n\r\200-\377]+|[ ]+$)'
|
|
||||||
safe_string_re = re.compile(SAFE_STRING_PATTERN)
|
|
||||||
|
|
||||||
def needs_base64(s):
|
|
||||||
"""
|
|
||||||
returns 1 if s has to be base-64 encoded because of special chars
|
|
||||||
"""
|
|
||||||
return not safe_string_re.search(s) is None
|
|
||||||
|
|
||||||
|
|
||||||
def wrap_binary_data(data):
|
|
||||||
"""Converts all binary data strings into Binary objects for transport
|
|
||||||
back over xmlrpc."""
|
|
||||||
if isinstance(data, str):
|
|
||||||
if needs_base64(data):
|
|
||||||
return xmlrpclib.Binary(data)
|
|
||||||
else:
|
|
||||||
return data
|
|
||||||
elif isinstance(data, list) or isinstance(data,tuple):
|
|
||||||
retval = []
|
|
||||||
for value in data:
|
|
||||||
retval.append(wrap_binary_data(value))
|
|
||||||
return retval
|
|
||||||
elif isinstance(data, dict):
|
|
||||||
retval = {}
|
|
||||||
for (k, v) in data.iteritems():
|
|
||||||
retval[k] = wrap_binary_data(v)
|
|
||||||
return retval
|
|
||||||
else:
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def unwrap_binary_data(data):
|
|
||||||
"""Converts all Binary objects back into strings."""
|
|
||||||
if isinstance(data, xmlrpclib.Binary):
|
|
||||||
# The data is decoded by the xmlproxy, but is stored
|
|
||||||
# in a binary object for us.
|
|
||||||
return str(data)
|
|
||||||
elif isinstance(data, str):
|
|
||||||
return data
|
|
||||||
elif isinstance(data, list) or isinstance(data,tuple):
|
|
||||||
retval = []
|
|
||||||
for value in data:
|
|
||||||
retval.append(unwrap_binary_data(value))
|
|
||||||
return retval
|
|
||||||
elif isinstance(data, dict):
|
|
||||||
retval = {}
|
|
||||||
for (k, v) in data.iteritems():
|
|
||||||
retval[k] = unwrap_binary_data(v)
|
|
||||||
return retval
|
|
||||||
else:
|
|
||||||
return data
|
|
||||||
|
|
||||||
def get_gsserror(e):
|
def get_gsserror(e):
|
||||||
"""A GSSError exception looks differently in python 2.4 than it does
|
"""A GSSError exception looks differently in python 2.4 than it does
|
||||||
in python 2.5, deal with it."""
|
in python 2.5, deal with it."""
|
||||||
|
Loading…
Reference in New Issue
Block a user