Skip to content

Commit

Permalink
removed all dependencies on modules string and types
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder authored and Petr Viktorin committed Nov 22, 2017
1 parent 8622217 commit db60bf1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions Demo/simplebrowse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#

import ldap
import string
from traceback import print_exc

url = "ldap://ldap.openldap.org/"
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions Lib/ldap/modlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from ldap import __version__

import string,ldap,ldap.cidict
import ldap,ldap.cidict


def list_dict(l,case_insensitive=0):
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Lib/ldif.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'LDIFCopy',
]

import urlparse,urllib,base64,re,types
import urlparse,urllib,base64,re

try:
from cStringIO import StringIO
Expand Down Expand Up @@ -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)))
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit db60bf1

Please sign in to comment.