-#!/usr/bin/env python
+#!/usr/bin/env python2
#
-# Copy...
+# Copyright (C) 2011-2012 W. Trevor King
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Cleanup the LDIF output from abook_ using `python-ldap`_.
-#!/usr/bin/env python
+#!/usr/bin/env python2
#
# Copyright (C) 2011-2012 W. Trevor King
#
protocol = 'ldap'
if CONFIG.getboolean('connection', 'ssl'):
protocol = 'ldaps'
- url = '%s://%s:%s' % (
+ url = '{}://{}:{}'.format(
protocol,
CONFIG.get('connection', 'server'),
CONFIG.get('connection', 'port'))
post = ''
if query:
post = '*'
- filterstr = '(|%s)' % (
- u' '.join([u'(%s=*%s%s)' % (field, query, post)
- for field in ['cn', 'displayName' 'uid', 'mail']]))
+ filterstr = u'(|{})'.format(
+ u' '.join([u'({}=*{}{})'.format(field, query, post)
+ for field in ['cn', 'displayName', 'uid', 'mail']]))
r = connection.search_s(
CONFIG.get('connection', 'basedn'),
_ldap.SCOPE_SUBTREE,
-#!/usr/bin/env python
+#!/usr/bin/env python2
#
-# Copyright (C) 2008-2011 W. Trevor King
+# Copyright (C) 2008-2012 W. Trevor King
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
protocol = 'ldap'
if CONFIG.getboolean('connection', 'ssl'):
protocol = 'ldaps'
- url = '%s://%s:%s' % (
+ url = '{}://{}:{}'.format(
protocol,
CONFIG.get('connection', 'server'),
CONFIG.get('connection', 'port'))
post = ''
if query:
post = '*'
- filterstr = '(|%s)' % (
- u' '.join([u'(%s=*%s%s)' % (field, query, post)
+ filterstr = u'(|{})'.format(
+ u' '.join([u'({}=*{}{})'.format(field, query, post)
for field in ['cn', 'displayName', 'uid', 'mail']]))
r = connection.search_s(
CONFIG.get('connection', 'basedn'),
entries = search(query)
addresses = list(itertools.chain(
*[format_entry(e) for e in sorted(entries)]))
- print '%d addresses found:' % len(addresses)
- print '\n'.join(addresses)
+ print('{} addresses found:'.format(len(addresses)))
+ print('\n'.join(addresses))