From a3b37d62a2c44533ecb9e2280e43da161f380ff3 Mon Sep 17 00:00:00 2001 From: Wade Berrier Date: Sat, 19 Jan 2013 18:02:10 -0700 Subject: [PATCH] Fix for python 2.6: add position indexes to format strings Turns out that omitting the indexes is only supported in python >= 2.7 It's possible this script would work with python < 2.6 but the old format strings would be necessary --- mutt-ldap.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mutt-ldap.py b/mutt-ldap.py index 94e44b9..7029b60 100755 --- a/mutt-ldap.py +++ b/mutt-ldap.py @@ -62,7 +62,7 @@ def connect(): protocol = 'ldap' if CONFIG.getboolean('connection', 'ssl'): protocol = 'ldaps' - url = '{}://{}:{}'.format( + url = '{0}://{1}:{2}'.format( protocol, CONFIG.get('connection', 'server'), CONFIG.get('connection', 'port')) @@ -88,12 +88,12 @@ def search(query, connection=None): post = '' if query: post = '*' - filterstr = u'(|{})'.format( - u' '.join([u'({}=*{}{})'.format(field, query, post) + filterstr = u'(|{0})'.format( + u' '.join([u'({0}=*{1}{2})'.format(field, query, post) for field in ['cn', 'displayName', 'uid', 'mail']])) query_filter = CONFIG.get('query', 'filter') if query_filter: - filterstr = u'(&({}){})'.format(query_filter, filterstr) + filterstr = u'(&({0}){1})'.format(query_filter, filterstr) r = connection.search_s( CONFIG.get('connection', 'basedn'), ldap.SCOPE_SUBTREE, @@ -120,5 +120,5 @@ if __name__ == '__main__': entries = search(query) addresses = list(itertools.chain( *[format_entry(e) for e in sorted(entries)])) - print('{} addresses found:'.format(len(addresses))) + print('{0} addresses found:'.format(len(addresses))) print('\n'.join(addresses)) -- 2.26.2