summaryrefslogtreecommitdiffstats
path: root/ipapython/entity.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-04-18 11:22:35 -0400
committerMartin Kosek <mkosek@redhat.com>2012-05-09 11:54:20 +0200
commitf19218f7d87f5847d51f79b5d2850f90b0ae8407 (patch)
tree500d3101dc1375d3eb75ffb927040c2593216aa9 /ipapython/entity.py
parentc02fcf5d34ad880e082cbc0c7f59fc3812d11c9e (diff)
downloadfreeipa-f19218f7d87f5847d51f79b5d2850f90b0ae8407.tar.gz
freeipa-f19218f7d87f5847d51f79b5d2850f90b0ae8407.tar.xz
freeipa-f19218f7d87f5847d51f79b5d2850f90b0ae8407.zip
Remove duplicate and unused utility code
IPA has some unused code from abandoned features (Radius, ipa 1.x user input, commant-line tab completion), as well as some duplicate utilities. This patch cleans up the utility modules. Duplicate code consolidated into ipapython.ipautil: {ipalib.util,ipaserver.ipautil,ipapython.ipautil}.realm_to_suffix {ipaserver,ipapython}.ipautil.CIDict (with style improvements from the ipaserver version) {ipapython.entity,ipaserver.ipautil}.utf8_encode_value {ipapython.entity,ipaserver.ipautil}.utf8_encode_values ipalib.util.get_fqdn was removed in favor of the same function in ipaserver.install.installutils Removed unused code: ipalib.util: load_plugins_in_dir import_plugins_subpackage make_repr (was imported but unused; also removed from tests) ipapython.ipautil: format_list parse_key_value_pairs read_pairs_file read_items_file user_input_plain AttributeValueCompleter ItemCompleter ipaserver.ipautil: get_gsserror (a different version exists in ipapython.ipautil) ipaserver.ipautil ended up empty and is removed entirely. https://fedorahosted.org/freeipa/ticket/2650
Diffstat (limited to 'ipapython/entity.py')
-rw-r--r--ipapython/entity.py31
1 files changed, 10 insertions, 21 deletions
diff --git a/ipapython/entity.py b/ipapython/entity.py
index 527adface..27d517879 100644
--- a/ipapython/entity.py
+++ b/ipapython/entity.py
@@ -17,18 +17,7 @@
import copy
-import ipapython.ipautil
-
-def utf8_encode_value(value):
- if isinstance(value,unicode):
- return value.encode('utf-8')
- return value
-
-def utf8_encode_values(values):
- if isinstance(values,list) or isinstance(values,tuple):
- return map(utf8_encode_value, values)
- else:
- return utf8_encode_value(values)
+from ipapython import ipautil
def copy_CIDict(x):
"""Do a deep copy of a CIDict"""
@@ -55,19 +44,19 @@ class Entity:
if entrydata:
if isinstance(entrydata,tuple):
self.dn = entrydata[0]
- self.data = ipapython.ipautil.CIDict(entrydata[1])
+ self.data = ipautil.CIDict(entrydata[1])
elif isinstance(entrydata,str) or isinstance(entrydata,unicode):
self.dn = entrydata
- self.data = ipapython.ipautil.CIDict()
+ self.data = ipautil.CIDict()
elif isinstance(entrydata,dict):
self.dn = entrydata['dn']
del entrydata['dn']
- self.data = ipapython.ipautil.CIDict(entrydata)
+ self.data = ipautil.CIDict(entrydata)
else:
self.dn = ''
- self.data = ipapython.ipautil.CIDict()
+ self.data = ipautil.CIDict()
- self.orig_data = ipapython.ipautil.CIDict(copy_CIDict(self.data))
+ self.orig_data = ipautil.CIDict(copy_CIDict(self.data))
def __nonzero__(self):
"""This allows us to do tests like if entry: returns false if there is no data,
@@ -120,9 +109,9 @@ class Entity:
if (len(value) < 1):
return
if (len(value) == 1):
- self.data[name] = utf8_encode_values(value[0])
+ self.data[name] = ipautil.utf8_encode_values(value[0])
else:
- self.data[name] = utf8_encode_values(value)
+ self.data[name] = ipautil.utf8_encode_values(value)
setValues = setValue
@@ -161,7 +150,7 @@ class Entity:
def toDict(self):
"""Convert the attrs and values to a dict. The dict is keyed on the
attribute name. The value is either single value or a list of values."""
- result = ipapython.ipautil.CIDict(self.data)
+ result = ipautil.CIDict(self.data)
result['dn'] = self.dn
return result
@@ -171,7 +160,7 @@ class Entity:
def origDataDict(self):
"""Returns a dict of the original values of the user. Used for updates."""
- result = ipapython.ipautil.CIDict(self.orig_data)
+ result = ipautil.CIDict(self.orig_data)
result['dn'] = self.dn
return result