From db60bf1238d187726c6d8c75fa6f9d36ed535cca Mon Sep 17 00:00:00 2001 From: stroeder Date: Sat, 18 Nov 2017 17:26:34 +0000 Subject: [PATCH] removed all dependencies on modules string and types --- CHANGES | 1 + Demo/simplebrowse.py | 5 ++--- Lib/ldap/modlist.py | 14 +++++++------- Lib/ldif.py | 6 +++--- setup.py | 9 ++++----- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CHANGES b/CHANGES index 32550b6..15c4d0e 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Modules/ * _ldap.__author__ and _ldap.__license__ also set from ldap.pkginfo Lib/ +* removed all dependencies on modules string and types * new global constant ldap.LIBLDAP_API_INFO * right after importing _ldap there is a call into libldap to initialize it * method .decodeControlValue() of SSSResponseControl and VLVResponseControl diff --git a/Demo/simplebrowse.py b/Demo/simplebrowse.py index f8e7182..804d12f 100644 --- a/Demo/simplebrowse.py +++ b/Demo/simplebrowse.py @@ -5,7 +5,6 @@ # import ldap -import string from traceback import print_exc url = "ldap://ldap.openldap.org/" @@ -71,8 +70,8 @@ if arg == '-': lastdn,dn = dn,lastdn elif arg == '..': - dn = string.join(ldap.explode_dn(dn)[1:], ",") - dn = string.strip(dn) + dn = ldap.explode_dn(dn)[1:].join(",") + dn = dn.strip() else: try: i = int(arg) diff --git a/Lib/ldap/modlist.py b/Lib/ldap/modlist.py index 0d1ac40..9aff147 100644 --- a/Lib/ldap/modlist.py +++ b/Lib/ldap/modlist.py @@ -10,7 +10,7 @@ from ldap import __version__ -import string,ldap,ldap.cidict +import ldap,ldap.cidict def list_dict(l,case_insensitive=0): @@ -31,10 +31,10 @@ def list_dict(l,case_insensitive=0): def addModlist(entry,ignore_attr_types=None): """Build modify list for call of method LDAPObject.add()""" - ignore_attr_types = list_dict(map(string.lower,(ignore_attr_types or []))) + ignore_attr_types = list_dict(map(str.lower,(ignore_attr_types or []))) modlist = [] for attrtype in entry.keys(): - if ignore_attr_types.has_key(string.lower(attrtype)): + if ignore_attr_types.has_key(str.lower(attrtype)): # This attribute type is ignored continue # Eliminate empty attr value strings in list @@ -66,14 +66,14 @@ def modifyModlist( List of attribute type names for which comparison will be made case-insensitive """ - ignore_attr_types = list_dict(map(string.lower,(ignore_attr_types or []))) - case_ignore_attr_types = list_dict(map(string.lower,(case_ignore_attr_types or []))) + ignore_attr_types = list_dict(map(str.lower,(ignore_attr_types or []))) + case_ignore_attr_types = list_dict(map(str.lower,(case_ignore_attr_types or []))) modlist = [] attrtype_lower_map = {} for a in old_entry.keys(): - attrtype_lower_map[string.lower(a)]=a + attrtype_lower_map[str.lower(a)]=a for attrtype in new_entry.keys(): - attrtype_lower = string.lower(attrtype) + attrtype_lower = str.lower(attrtype) if ignore_attr_types.has_key(attrtype_lower): # This attribute type is ignored continue diff --git a/Lib/ldif.py b/Lib/ldif.py index c4ac4e8..8b1cd28 100644 --- a/Lib/ldif.py +++ b/Lib/ldif.py @@ -21,7 +21,7 @@ 'LDIFCopy', ] -import urlparse,urllib,base64,re,types +import urlparse,urllib,base64,re try: from cStringIO import StringIO @@ -193,9 +193,9 @@ def unparse(self,dn,record): # Start with line containing the distinguished name self._unparseAttrTypeandValue('dn',dn) # Dispatch to record type specific writers - if isinstance(record,types.DictType): + if isinstance(record,dict): self._unparseEntryRecord(record) - elif isinstance(record,types.ListType): + elif isinstance(record,list): self._unparseChangeRecord(record) else: raise ValueError('Argument record must be dictionary or list instead of %s' % (repr(record))) diff --git a/setup.py b/setup.py index 841ee55..6bbf595 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from distutils.core import setup, Extension from ConfigParser import ConfigParser -import sys,os,string,time +import sys,os,time sys.path.insert(0, os.path.join(os.getcwd(), 'Lib/ldap')) import pkginfo @@ -36,15 +36,14 @@ class OpenLDAP2: if cfg.has_section('_ldap'): for name in dir(LDAP_CLASS): if cfg.has_option('_ldap', name): - print name + ': ' + cfg.get('_ldap', name) - setattr(LDAP_CLASS, name, string.split(cfg.get('_ldap', name))) + setattr(LDAP_CLASS, name, cfg.get('_ldap', name).split()) for i in range(len(LDAP_CLASS.defines)): LDAP_CLASS.defines[i]=((LDAP_CLASS.defines[i],None)) for i in range(len(LDAP_CLASS.extra_files)): - destdir, origfiles = string.split(LDAP_CLASS.extra_files[i], ':') - origfileslist = string.split(origfiles, ',') + destdir, origfiles = LDAP_CLASS.extra_files[i].split(':') + origfileslist = origfiles.split(',') LDAP_CLASS.extra_files[i]=(destdir, origfileslist) #-- Let distutils/setuptools do the rest